You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bookkeeper.apache.org by si...@apache.org on 2018/10/05 22:36:05 UTC

[bookkeeper] branch master updated: ISSUE #1703: IllegalReferenceCountException at closing EntryLogManagerForSingleEntryLog

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

sijie 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 ba6d3ee  ISSUE #1703: IllegalReferenceCountException at closing EntryLogManagerForSingleEntryLog
ba6d3ee is described below

commit ba6d3ee3d0005c809d926f952b1c1b4d33215dd5
Author: Sijie Guo <gu...@gmail.com>
AuthorDate: Fri Oct 5 15:36:00 2018 -0700

    ISSUE #1703: IllegalReferenceCountException at closing EntryLogManagerForSingleEntryLog
    
    Descriptions of the changes in this PR:
    
    *Motivation*
    
    Fixes #1703.
    
    The active entry log channel in EntryLogManagerForSingleEntryLog is closed twice during shutdown.
    One is by EntryLogManagerForSingleEntryLog#close and the other one is EntryLogManagerForSingleEntryLog#forceClose().
    
    *Changes*
    
    This change is adding logic in BufferedChannel to make sure BufferedChannel can be closed multiple times.
    
    
    
    
    Author: Sijie Guo <si...@apache.org>
    
    Reviewers: Charan Reddy Guttapalem <re...@gmail.com>, Enrico Olivelli <eo...@gmail.com>, Andrey Yegorov <None>
    
    This closes #1735 from sijie/issue_1703, closes #1703
---
 .../src/main/java/org/apache/bookkeeper/bookie/BufferedChannel.java | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/BufferedChannel.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/BufferedChannel.java
index b2dd4be..633c540 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/BufferedChannel.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/BufferedChannel.java
@@ -63,6 +63,8 @@ public class BufferedChannel extends BufferedReadChannel implements Closeable {
      */
     protected final AtomicLong unpersistedBytes;
 
+    private boolean closed = false;
+
     // make constructor to be public for unit test
     public BufferedChannel(FileChannel fc, int capacity) throws IOException {
         // Use the same capacity for read and write buffers.
@@ -88,8 +90,12 @@ public class BufferedChannel extends BufferedReadChannel implements Closeable {
 
     @Override
     public synchronized void close() throws IOException {
+        if (closed) {
+            return;
+        }
         ReferenceCountUtil.safeRelease(writeBuffer);
         fileChannel.close();
+        closed = true;
     }
 
     /**