diff --git a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java index ed5bf2f2a9fce..b9f52fb9def19 100644 --- a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java +++ b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java @@ -3076,12 +3076,12 @@ private List buildBatchEntryDeletio if (!config.isDeletionAtBatchIndexLevelEnabled() || batchDeletedIndexes.isEmpty()) { return Collections.emptyList(); } - MLDataFormats.BatchedEntryDeletionIndexInfo batchDeletedIndexInfoBuilder = new MLDataFormats - .BatchedEntryDeletionIndexInfo(); List result = new ArrayList<>(); Iterator> iterator = batchDeletedIndexes.entrySet().iterator(); while (iterator.hasNext() && result.size() < config.getMaxBatchDeletedIndexToPersist()) { Map.Entry entry = iterator.next(); + MLDataFormats.BatchedEntryDeletionIndexInfo batchDeletedIndexInfoBuilder = new MLDataFormats + .BatchedEntryDeletionIndexInfo(); batchDeletedIndexInfoBuilder.setPosition() .setLedgerId(entry.getKey().getLedgerId()) .setEntryId(entry.getKey().getEntryId()); @@ -3089,7 +3089,6 @@ private List buildBatchEntryDeletio for (long l : array) { batchDeletedIndexInfoBuilder.addDeleteSet(l); } - batchDeletedIndexInfoBuilder.clearDeleteSet(); result.add(batchDeletedIndexInfoBuilder); } return result;