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/02/03 03:38:09 UTC

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

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

 ##########
 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:
   Makes sense to me.
   I think it would also worth to cover this behavior with unit tests.

----------------------------------------------------------------
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