You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/08/02 03:02:05 UTC

[GitHub] [pulsar] mattisonchao commented on a diff in pull request #16910: Avoid using `ArrayList` in the concurrent environment.

mattisonchao commented on code in PR #16910:
URL: https://github.com/apache/pulsar/pull/16910#discussion_r935071389


##########
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java:
##########
@@ -1347,7 +1347,7 @@ public Set<? extends Position> asyncReplayEntries(final Set<? extends Position>
     @Override
     public Set<? extends Position> asyncReplayEntries(Set<? extends Position> positions,
             ReadEntriesCallback callback, Object ctx, boolean sortEntries) {
-        List<Entry> entries = Lists.newArrayListWithExpectedSize(positions.size());
+        List<Entry> entries = Collections.synchronizedList(new ArrayList<>(positions.size()));

Review Comment:
   We will invoke `entries.add` method at callback in different thread.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org