From 113e88bb890e9ff59a9cdff6b214ac5a71b0ab6a Mon Sep 17 00:00:00 2001 From: graysonzeng Date: Tue, 6 Feb 2024 20:14:29 +0800 Subject: [PATCH 1/2] [fix][Offload] fix indexEntries is null error --- .../offload/jcloud/impl/OffloadIndexBlockImpl.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tiered-storage/jcloud/src/main/java/org/apache/bookkeeper/mledger/offload/jcloud/impl/OffloadIndexBlockImpl.java b/tiered-storage/jcloud/src/main/java/org/apache/bookkeeper/mledger/offload/jcloud/impl/OffloadIndexBlockImpl.java index ef7c84e917268..6373486453a1f 100644 --- a/tiered-storage/jcloud/src/main/java/org/apache/bookkeeper/mledger/offload/jcloud/impl/OffloadIndexBlockImpl.java +++ b/tiered-storage/jcloud/src/main/java/org/apache/bookkeeper/mledger/offload/jcloud/impl/OffloadIndexBlockImpl.java @@ -51,7 +51,7 @@ public class OffloadIndexBlockImpl implements OffloadIndexBlock { private LedgerMetadata segmentMetadata; private long dataObjectLength; private long dataHeaderLength; - private TreeMap indexEntries; + private volatile TreeMap indexEntries; private final Handle recyclerHandle; @@ -94,8 +94,10 @@ public void recycle() { dataObjectLength = -1; dataHeaderLength = -1; segmentMetadata = null; - indexEntries.clear(); - indexEntries = null; + if (indexEntries != null) { + indexEntries.clear(); + indexEntries = null; + } if (recyclerHandle != null) { recyclerHandle.recycle(this); } From 507ada408d844448479ca02f96645869008fccf9 Mon Sep 17 00:00:00 2001 From: graysonzeng Date: Wed, 7 Feb 2024 09:22:42 +0800 Subject: [PATCH 2/2] [fix][Offload] remove indexEntries.clear() to aviod NullPointerException --- .../mledger/offload/jcloud/impl/OffloadIndexBlockImpl.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/tiered-storage/jcloud/src/main/java/org/apache/bookkeeper/mledger/offload/jcloud/impl/OffloadIndexBlockImpl.java b/tiered-storage/jcloud/src/main/java/org/apache/bookkeeper/mledger/offload/jcloud/impl/OffloadIndexBlockImpl.java index 6373486453a1f..1be133f0761d6 100644 --- a/tiered-storage/jcloud/src/main/java/org/apache/bookkeeper/mledger/offload/jcloud/impl/OffloadIndexBlockImpl.java +++ b/tiered-storage/jcloud/src/main/java/org/apache/bookkeeper/mledger/offload/jcloud/impl/OffloadIndexBlockImpl.java @@ -51,7 +51,7 @@ public class OffloadIndexBlockImpl implements OffloadIndexBlock { private LedgerMetadata segmentMetadata; private long dataObjectLength; private long dataHeaderLength; - private volatile TreeMap indexEntries; + private TreeMap indexEntries; private final Handle recyclerHandle; @@ -94,10 +94,7 @@ public void recycle() { dataObjectLength = -1; dataHeaderLength = -1; segmentMetadata = null; - if (indexEntries != null) { - indexEntries.clear(); - indexEntries = null; - } + indexEntries = null; if (recyclerHandle != null) { recyclerHandle.recycle(this); }