You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bookkeeper.apache.org by yo...@apache.org on 2023/05/19 01:40:55 UTC

[bookkeeper] branch master updated: Fix npe when iterate pendingLedgersUpdates and pendingDeletedLedgers. (#3955)

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

yong 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 a122b6b9ec Fix npe when iterate pendingLedgersUpdates and pendingDeletedLedgers. (#3955)
a122b6b9ec is described below

commit a122b6b9ec21fe92e389fae42236b7daef84cb52
Author: Yan Zhao <ho...@apache.org>
AuthorDate: Fri May 19 09:40:49 2023 +0800

    Fix npe when iterate pendingLedgersUpdates and pendingDeletedLedgers. (#3955)
    
    Descriptions of the changes in this PR:
    Fixes #3954
    
    2023-05-12T16:58:26,212 - INFO  - [db-storage-cleanup-5-1:EntryLocationIndex@244] - Deleted indexes from 10 ledgers in 0.006 seconds
    2023-05-12T16:58:26,203 - ERROR - [SyncThread-7-1:SyncThread@111] - Exception in SyncThread
    java.lang.NullPointerException: null
            at org.apache.bookkeeper.bookie.storage.ldb.LedgerMetadataIndex.flush(LedgerMetadataIndex.java:303) ~[classes/:?]
---
 .../apache/bookkeeper/bookie/storage/ldb/LedgerMetadataIndex.java | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/storage/ldb/LedgerMetadataIndex.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/storage/ldb/LedgerMetadataIndex.java
index 989969c483..c93bc0b7db 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/storage/ldb/LedgerMetadataIndex.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/storage/ldb/LedgerMetadataIndex.java
@@ -298,8 +298,8 @@ public class LedgerMetadataIndex implements Closeable {
         LongWrapper key = LongWrapper.get();
 
         int updatedLedgers = 0;
-        while (!pendingLedgersUpdates.isEmpty()) {
-            Entry<Long, LedgerData> entry = pendingLedgersUpdates.poll();
+        Entry<Long, LedgerData> entry;
+        while ((entry = pendingLedgersUpdates.poll()) != null) {
             key.set(entry.getKey());
             byte[] value = entry.getValue().toByteArray();
             ledgersDb.put(key.array, value);
@@ -318,8 +318,8 @@ public class LedgerMetadataIndex implements Closeable {
         LongWrapper key = LongWrapper.get();
 
         int deletedLedgers = 0;
-        while (!pendingDeletedLedgers.isEmpty()) {
-            long ledgerId = pendingDeletedLedgers.poll();
+        Long ledgerId;
+        while ((ledgerId = pendingDeletedLedgers.poll()) != null) {
             key.set(ledgerId);
             ledgersDb.delete(key.array);
         }