sijie closed pull request #1249: Fixed Journal static empty array list recycling URL: https://github.com/apache/bookkeeper/pull/1249
This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): 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 7dd663feb..4915d7749 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 @@ 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 @@ private RecyclableArrayList(Handle<RecyclableArrayList<T>> handle, int initialCa 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 775219bca..e21f4d133 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 @@ 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. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services