Skip to content

Conversation

@jyemin
Copy link
Collaborator

@jyemin jyemin commented Feb 10, 2022

@jyemin jyemin requested a review from stIncMale February 10, 2022 16:54
import static com.mongodb.connection.ClusterType.LOAD_BALANCED;

public class ClientSessionBinding implements AsyncReadWriteBinding {
public class ClientSessionBinding extends AbstractReferenceCounted implements AsyncReadWriteBinding {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might have been overkill to change this class since it doesn't need to be thread safe, but once I marked getCount as VisibleForTesting(otherwise=PRIVATE) I didn't want to use it any more in production code. But take a close look because my initial attempts here were buggy and caused unit tests to fail.

}

private void closeSessionIfCountIsZero() {
if (getCount() == 0 && ownsSession) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stop using getCount and instead give this class its own reference count so that release can properly close the session.


@Override
public ConnectionDescription getDescription() {
isTrue("open", getCount() > 0);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just get rid of superfluous use of getCount

JAVA-4490
@jyemin jyemin merged commit 058d9f4 into mongodb:master Feb 10, 2022
@jyemin jyemin deleted the j4490 branch February 10, 2022 21:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants