This is an automated email from the ASF dual-hosted git repository.

ivank pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git


The following commit(s) were added to refs/heads/master by this push:
     new 5902ee2  fix potential NPE when releasing entry that is null
5902ee2 is described below

commit 5902ee27be2fb7eeade53f5e8e4afd3fe573ad5c
Author: Boyang Jerry Peng <[email protected]>
AuthorDate: Tue Mar 26 09:33:54 2019 -0500

    fix potential NPE when releasing entry that is null
    
    Descriptions of the changes in this PR:
    
    ### Motivation
    A interrupt exception can occur during the poll operation of the blocking 
and cause a NPE to be thrown
    
    ### Changes
    Check if entry is null before trying to release it
    
    
    Reviewers: Ivan Kelly <[email protected]>, Sijie Guo <[email protected]>, 
Matteo Merli <[email protected]>
    
    This closes #1998 from jerrypeng/fix_NPE
---
 .../apache/distributedlog/impl/logsegment/BKLogSegmentEntryReader.java | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git 
a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/logsegment/BKLogSegmentEntryReader.java
 
b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/logsegment/BKLogSegmentEntryReader.java
index 813e974..f414bf4 100644
--- 
a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/logsegment/BKLogSegmentEntryReader.java
+++ 
b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/logsegment/BKLogSegmentEntryReader.java
@@ -21,6 +21,7 @@ import static com.google.common.base.Charsets.UTF_8;
 
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.collect.Lists;
+import io.netty.util.ReferenceCountUtil;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Enumeration;
@@ -800,7 +801,7 @@ public class BKLogSegmentEntryReader implements 
SafeRunnable, LogSegmentEntryRea
                         return;
                     }
                 } finally {
-                    removedEntry.release();
+                    ReferenceCountUtil.safeRelease(removedEntry);
                 }
             } else if (skipBrokenEntries && 
BKException.Code.DigestMatchException == entry.getRc()) {
                 // skip this entry and move forward

Reply via email to