BewareMyPower commented on code in PR #23951:
URL: https://github.com/apache/pulsar/pull/23951#discussion_r1947838828
##########
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java:
##########
@@ -1144,16 +1144,14 @@ public ManagedCursor newNonDurableCursor(Position
startCursorPosition, String cu
return cachedCursor;
}
- NonDurableCursorImpl cursor = new NonDurableCursorImpl(bookKeeper,
this, cursorName,
- startCursorPosition, initialPosition, isReadCompacted);
- cursor.setActive();
-
- log.info("[{}] Opened new cursor: {}", name, cursor);
synchronized (this) {
+ NonDurableCursorImpl cursor = new NonDurableCursorImpl(bookKeeper,
this, cursorName,
+ startCursorPosition, initialPosition, isReadCompacted);
+ cursor.setActive();
+ log.info("[{}] Opened new cursor: {}", name, cursor);
addCursor(cursor);
+ return cursor;
Review Comment:
Since there is no test to protect this change (it might be hard to add the
test), to avoid possible regression in futurem you'd better add some comments
here to explain why the creation of the `NonDurableCursorImpl` should be put
inside the synchronized block.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]