GitHub user BewareMyPower added a comment to the discussion: [QUESTION] Thread 
safe problem about HandlerState#changeToReadyState

Is following implementation better?

```java
    private static boolean notClosed(State state) {
        return state == State.Uninitialized || state == State.Connecting || 
state == State.RegisteringSchema;
    }

    // moves the state to ready if it wasn't closed
    protected boolean changeToReadyState() {
        return STATE_UPDATER.getAndUpdate(this, state -> (notClosed(state) ? 
State.Ready : state)) == State.Ready;
    }

```

GitHub link: 
https://github.com/apache/pulsar/discussions/18401#discussioncomment-4103573

----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]

Reply via email to