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 cefdeb6  Fixed Journal static empty array list recycling
cefdeb6 is described below

commit cefdeb6e3c6f4231ca8d09e93cc7f3dedd3a058f
Author: Matteo Merli <[email protected]>
AuthorDate: Mon Mar 12 18:35:30 2018 -0700

    Fixed Journal static empty array list recycling
    
    When `journalSyncData=false`, we passing `EMPTY_ARRAY_LIST` to the 
`ForceWriteThread` when the journal is rolled over.
    
    I have seen this exception:
    
    ```
    18:39:52.285 [ForceWriteThread] ERROR 
org.apache.bookkeeper.bookie.BookieCriticalThread - Uncaught exception in 
thread ForceWriteThread and is exiting!
    java.lang.NullPointerException: null
        at io.netty.util.Recycler$DefaultHandle.recycle(Recycler.java:219) 
~[io.netty-netty-all-4.1.21.Final.jar:4.1.21.Final]
        at 
org.apache.bookkeeper.common.collections.RecyclableArrayList.recycle(RecyclableArrayList.java:55)
 
~[org.apache.bookkeeper-bookkeeper-server-shaded-4.7.0-SNAPSHOT.jar:4.7.0-SNAPSHOT]
        at 
org.apache.bookkeeper.bookie.Journal$ForceWriteRequest.recycle(Journal.java:402)
 
~[org.apache.bookkeeper-bookkeeper-server-shaded-4.7.0-SNAPSHOT.jar:4.7.0-SNAPSHOT]
        at 
org.apache.bookkeeper.bookie.Journal$ForceWriteRequest.access$1(Journal.java:399)
 
~[org.apache.bookkeeper-bookkeeper-server-shaded-4.7.0-SNAPSHOT.jar:4.7.0-SNAPSHOT]
        at 
org.apache.bookkeeper.bookie.Journal$ForceWriteThread.run(Journal.java:506) 
~[org.apache.bookkeeper-bookkeeper-server-shaded-4.7.0-SNAPSHOT.jar:4.7.0-SNAPSHOT]
    ```
    
    This is due to calling `recycle()` twice on the same `EMPTY_ARRAY_LIST`  
instance. The solution is that `EMPTY_ARRAY_LIST` should not be a pooled 
instance and we should check that before recycling.
    
    Author: Matteo Merli <[email protected]>
    
    Reviewers: Sijie Guo <[email protected]>
    
    This closes #1249 from merlimat/fix-journal-list-recycle
---
 .../bookkeeper/common/collections/RecyclableArrayList.java   | 12 +++++++++++-
 .../src/main/java/org/apache/bookkeeper/bookie/Journal.java  |  2 +-
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git 
a/bookkeeper-common/src/main/java/org/apache/bookkeeper/common/collections/RecyclableArrayList.java
 
b/bookkeeper-common/src/main/java/org/apache/bookkeeper/common/collections/RecyclableArrayList.java
index 7dd663f..4915d77 100644
--- 
a/bookkeeper-common/src/main/java/org/apache/bookkeeper/common/collections/RecyclableArrayList.java
+++ 
b/bookkeeper-common/src/main/java/org/apache/bookkeeper/common/collections/RecyclableArrayList.java
@@ -45,6 +45,14 @@ public final class RecyclableArrayList<T> extends 
ArrayList<T> {
 
     private final Handle<RecyclableArrayList<T>> handle;
 
+    /**
+     * Default non-pooled instance.
+     */
+    public RecyclableArrayList() {
+        super();
+        this.handle = null;
+    }
+
     private RecyclableArrayList(Handle<RecyclableArrayList<T>> handle, int 
initialCapacity) {
         super(initialCapacity);
         this.handle = handle;
@@ -52,6 +60,8 @@ public final class RecyclableArrayList<T> extends 
ArrayList<T> {
 
     public void recycle() {
         clear();
-        handle.recycle(this);
+        if (handle != null) {
+            handle.recycle(this);
+        }
     }
 }
diff --git 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Journal.java 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Journal.java
index 775219b..e21f4d1 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Journal.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Journal.java
@@ -66,7 +66,7 @@ public class Journal extends BookieCriticalThread implements 
CheckpointSource {
 
     private static final RecyclableArrayList.Recycler<QueueEntry> 
entryListRecycler =
         new RecyclableArrayList.Recycler<QueueEntry>();
-    private static final RecyclableArrayList<QueueEntry> EMPTY_ARRAY_LIST = 
entryListRecycler.newInstance();
+    private static final RecyclableArrayList<QueueEntry> EMPTY_ARRAY_LIST = 
new RecyclableArrayList<>();
 
     /**
      * Filter to pickup journals.

-- 
To stop receiving notification emails like this one, please contact
[email protected].

Reply via email to