Skip to content

The AbstractCloseable.doCloseImmediately() race condition #700

@artembilan

Description

@artembilan

Version

2.15.0

Bug description

The code there is like this:

    protected void doCloseImmediately() {
        closeFuture.setClosed();
        state.set(State.Closed);
    }

So, we fulfill CloseFuture first, and then set the state to Closed.
This way Closeable.close(Closeable closeable) exits earlier than we mark that Closeable as Closed.

Actual behavior

In my case the unit test is failing sporadically for this:

session.close();
assertThat(clientSession.isClosed()).isTrue();

Expected behavior

The AbstractCloseable.doCloseImmediately() has those expressions swapped:

    protected void doCloseImmediately() {
        state.set(State.Closed);
        closeFuture.setClosed();
     }

Relevant log output

Other information

No response

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions