Skip to content

Commit

Permalink
Fix adding message to list potential issue (#14377)
Browse files Browse the repository at this point in the history
(cherry picked from commit b22445f)
  • Loading branch information
Technoboy- authored and gaoran10 committed Mar 1, 2022
1 parent d6867b4 commit 44408bf
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1771,18 +1771,17 @@ private CompletableFuture<List<MessageIdData>> getRedeliveryMessageIdData(List<M
return CompletableFuture.completedFuture(Collections.emptyList());
}
List<MessageIdData> data = new ArrayList<>(messageIds.size());
List<CompletableFuture<Boolean>> futures = new ArrayList<>(messageIds.size());
List<CompletableFuture<Void>> futures = new ArrayList<>(messageIds.size());
messageIds.forEach(messageId -> {
CompletableFuture<Boolean> future = processPossibleToDLQ(messageId);
futures.add(future);
future.thenAccept(sendToDLQ -> {
futures.add(future.thenAccept(sendToDLQ -> {
if (!sendToDLQ) {
data.add(new MessageIdData()
.setPartition(messageId.getPartitionIndex())
.setLedgerId(messageId.getLedgerId())
.setEntryId(messageId.getEntryId()));
}
});
}));
});
return FutureUtil.waitForAll(futures).thenCompose(v -> CompletableFuture.completedFuture(data));
}
Expand Down

0 comments on commit 44408bf

Please sign in to comment.