labuladong commented on code in PR #18340:
URL: https://github.com/apache/pulsar/pull/18340#discussion_r1014955184
##########
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java:
##########
@@ -2707,6 +2707,25 @@ public void operationFailed(ManagedLedgerException
exception) {
});
}
+ /**
+ * Try set {@link #state} to {@link State#Closing}.
+ * @return false if the {@link #state} already is {@link State#Closing} or
{@link State#Closed}.
+ */
+ private boolean trySetStateToClosing() {
+ final AtomicBoolean notClosing = new AtomicBoolean(false);
+ STATE_UPDATER.updateAndGet(this, state -> {
+ switch (state){
+ case Closing:
+ case Closed: return state;
+ default: {
+ notClosing.set(true);
+ return State.Closing;
+ }
Review Comment:
Or, we can add `notClosing.set(false)` in `Closing` and `Closed` cases to
make this operation idempotent.
--
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]