eolivelli commented on code in PR #18340:
URL: https://github.com/apache/pulsar/pull/18340#discussion_r1014728322
##########
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java:
##########
@@ -2707,6 +2707,26 @@ 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() {
+ if (STATE_UPDATER.compareAndSet(this, State.Uninitialized,
State.Closing)){
Review Comment:
https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.html#updateAndGet-T-java.util.function.UnaryOperator-
What about using updateAndGet?
This way we can use a switch 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]