You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@zookeeper.apache.org by GitBox <gi...@apache.org> on 2020/01/08 06:10:59 UTC

[GitHub] [zookeeper] maoling commented on a change in pull request #1203: ZOOKEEPER-3676: Clean Up TxnLogProposalIterator

maoling commented on a change in pull request #1203: ZOOKEEPER-3676: Clean Up TxnLogProposalIterator
URL: https://github.com/apache/zookeeper/pull/1203#discussion_r364076527
 
 

 ##########
 File path: zookeeper-server/src/main/java/org/apache/zookeeper/server/TxnLogProposalIterator.java
 ##########
 @@ -87,23 +87,16 @@ public void remove() {
      * transaction records
      */
     public void close() {
-        if (itr != null) {
-            try {
-                itr.close();
-            } catch (IOException ioe) {
-                LOG.warn("Error closing file iterator", ioe);
-            }
+        try {
+            itr.close();
+        } catch (IOException ioe) {
+            LOG.warn("Error closing file iterator", ioe);
         }
     }
 
-    private TxnLogProposalIterator() {
-    }
-
-    public TxnLogProposalIterator(TxnIterator itr) {
-        if (itr != null) {
-            this.itr = itr;
-            hasNext = (itr.getHeader() != null);
-        }
+    public TxnLogProposalIterator(final TxnIterator itr) {
+        this.itr = Objects.requireNonNull(itr);
+        this.hasNext = (itr.getHeader() != null);
 
 Review comment:
   - AFAIK, `Objects.requireNonNull` will throw an `NPE` when `itr` is null, is the new code changes the logic? Actually, `itr` can be null

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services