Skip to content

Commit 5e4e96a

Browse files
committed
Remove reactive streams ClientSession#getWrapped method
* Also remove the com.mongodb.internal.async.client.AsyncClientSession internal type JAVA-4790
1 parent 501b7f6 commit 5e4e96a

File tree

7 files changed

+14
-129
lines changed

7 files changed

+14
-129
lines changed

driver-core/src/main/com/mongodb/internal/async/client/AsyncClientSession.java

Lines changed: 0 additions & 49 deletions
This file was deleted.

driver-core/src/test/functional/com/mongodb/internal/async/client/TestHelper.groovy

Lines changed: 0 additions & 51 deletions
This file was deleted.

driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/ClientSession.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
package com.mongodb.reactivestreams.client;
1919

2020
import com.mongodb.TransactionOptions;
21-
import com.mongodb.internal.async.client.AsyncClientSession;
2221
import org.reactivestreams.Publisher;
2322

2423
/**
@@ -62,13 +61,6 @@ public interface ClientSession extends com.mongodb.session.ClientSession {
6261
*/
6362
TransactionOptions getTransactionOptions();
6463

65-
/**
66-
* For internal use only.
67-
*
68-
* @return the wrapped session
69-
*/
70-
AsyncClientSession getWrapped();
71-
7264
/**
7365
* Start a transaction in the context of this session with default transaction options. A transaction can not be started if there is
7466
* already an active transaction on this session.

driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/internal/ClientSessionBinding.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import com.mongodb.connection.ClusterType;
2424
import com.mongodb.connection.ServerDescription;
2525
import com.mongodb.internal.async.SingleResultCallback;
26-
import com.mongodb.internal.async.client.AsyncClientSession;
2726
import com.mongodb.internal.binding.AbstractReferenceCounted;
2827
import com.mongodb.internal.binding.AsyncClusterAwareReadWriteBinding;
2928
import com.mongodb.internal.binding.AsyncConnectionSource;
@@ -33,19 +32,19 @@
3332
import com.mongodb.internal.session.ClientSessionContext;
3433
import com.mongodb.internal.session.SessionContext;
3534
import com.mongodb.lang.Nullable;
35+
import com.mongodb.reactivestreams.client.ClientSession;
3636
import org.bson.BsonTimestamp;
3737

3838
import static com.mongodb.assertions.Assertions.notNull;
3939
import static com.mongodb.connection.ClusterType.LOAD_BALANCED;
4040

4141
public class ClientSessionBinding extends AbstractReferenceCounted implements AsyncReadWriteBinding {
4242
private final AsyncClusterAwareReadWriteBinding wrapped;
43-
private final AsyncClientSession session;
43+
private final ClientSession session;
4444
private final boolean ownsSession;
4545
private final ClientSessionContext sessionContext;
4646

47-
public ClientSessionBinding(final AsyncClientSession session, final boolean ownsSession,
48-
final AsyncClusterAwareReadWriteBinding wrapped) {
47+
public ClientSessionBinding(final ClientSession session, final boolean ownsSession, final AsyncClusterAwareReadWriteBinding wrapped) {
4948
this.wrapped = notNull("wrapped", wrapped).retain();
5049
this.ownsSession = ownsSession;
5150
this.session = notNull("session", session);
@@ -239,9 +238,9 @@ public int release() {
239238

240239
private final class AsyncClientSessionContext extends ClientSessionContext implements SessionContext {
241240

242-
private final AsyncClientSession clientSession;
241+
private final ClientSession clientSession;
243242

244-
AsyncClientSessionContext(final AsyncClientSession clientSession) {
243+
AsyncClientSessionContext(final ClientSession clientSession) {
245244
super(clientSession);
246245
this.clientSession = clientSession;
247246
}

driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/internal/ClientSessionPublisherImpl.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import com.mongodb.ReadConcern;
2424
import com.mongodb.TransactionOptions;
2525
import com.mongodb.WriteConcern;
26-
import com.mongodb.internal.async.client.AsyncClientSession;
2726
import com.mongodb.internal.operation.AbortTransactionOperation;
2827
import com.mongodb.internal.operation.AsyncReadOperation;
2928
import com.mongodb.internal.operation.AsyncWriteOperation;
@@ -43,7 +42,7 @@
4342
import static com.mongodb.assertions.Assertions.notNull;
4443
import static java.util.concurrent.TimeUnit.MILLISECONDS;
4544

46-
final class ClientSessionPublisherImpl extends BaseClientSessionImpl implements ClientSession, AsyncClientSession {
45+
final class ClientSessionPublisherImpl extends BaseClientSessionImpl implements ClientSession {
4746

4847
private final OperationExecutor executor;
4948
private TransactionState transactionState = TransactionState.NONE;
@@ -124,11 +123,6 @@ public void startTransaction(final TransactionOptions transactionOptions) {
124123
clearTransactionContext();
125124
}
126125

127-
@Override
128-
public AsyncClientSession getWrapped() {
129-
return this;
130-
}
131-
132126
@Override
133127
public Publisher<Void> commitTransaction() {
134128
if (transactionState == TransactionState.ABORTED) {

driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/internal/OperationExecutorImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ private AsyncReadWriteBinding getReadWriteBinding(final RequestContext requestCo
167167

168168
final AsyncClusterAwareReadWriteBinding asyncReadWriteBinding = readWriteBinding;
169169
if (session != null) {
170-
return new ClientSessionBinding(session.getWrapped(), ownsSession, asyncReadWriteBinding);
170+
return new ClientSessionBinding(session, ownsSession, asyncReadWriteBinding);
171171
} else {
172172
return asyncReadWriteBinding;
173173
}

driver-reactive-streams/src/test/unit/com/mongodb/reactivestreams/client/internal/ClientSessionBindingSpecification.groovy

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,20 @@ import com.mongodb.connection.ServerConnectionState
2727
import com.mongodb.connection.ServerDescription
2828
import com.mongodb.connection.ServerType
2929
import com.mongodb.internal.IgnorableRequestContext
30-
import com.mongodb.internal.async.client.AsyncClientSession
3130
import com.mongodb.internal.binding.AsyncClusterAwareReadWriteBinding
3231
import com.mongodb.internal.binding.AsyncClusterBinding
3332
import com.mongodb.internal.binding.AsyncConnectionSource
3433
import com.mongodb.internal.connection.Cluster
3534
import com.mongodb.internal.connection.Server
3635
import com.mongodb.internal.connection.ServerTuple
3736
import com.mongodb.internal.session.ClientSessionContext
37+
import com.mongodb.reactivestreams.client.ClientSession
3838
import spock.lang.Specification
3939

4040
class ClientSessionBindingSpecification extends Specification {
4141
def 'should return the session context from the binding'() {
4242
given:
43-
def session = Stub(AsyncClientSession)
43+
def session = Stub(ClientSession)
4444
def wrappedBinding = Stub(AsyncClusterAwareReadWriteBinding)
4545
def binding = new ClientSessionBinding(session, false, wrappedBinding)
4646

@@ -53,7 +53,7 @@ class ClientSessionBindingSpecification extends Specification {
5353

5454
def 'should return the session context from the connection source'() {
5555
given:
56-
def session = Stub(AsyncClientSession)
56+
def session = Stub(ClientSession)
5757
def wrappedBinding = Mock(AsyncClusterAwareReadWriteBinding) {
5858
getCluster() >> {
5959
Mock(Cluster) {
@@ -99,7 +99,7 @@ class ClientSessionBindingSpecification extends Specification {
9999

100100
def 'should close client session when binding reference count drops to zero if it is owned by the binding'() {
101101
given:
102-
def session = Mock(AsyncClientSession)
102+
def session = Mock(ClientSession)
103103
def wrappedBinding = createStubBinding()
104104
def binding = new ClientSessionBinding(session, true, wrappedBinding)
105105
binding.retain()
@@ -119,7 +119,7 @@ class ClientSessionBindingSpecification extends Specification {
119119

120120
def 'should close client session when binding reference count drops to zero due to connection source if it is owned by the binding'() {
121121
given:
122-
def session = Mock(AsyncClientSession)
122+
def session = Mock(ClientSession)
123123
def wrappedBinding = createStubBinding()
124124
def binding = new ClientSessionBinding(session, true, wrappedBinding)
125125
def futureResultCallback = new FutureResultCallback<AsyncConnectionSource>()
@@ -150,7 +150,7 @@ class ClientSessionBindingSpecification extends Specification {
150150

151151
def 'should not close client session when binding reference count drops to zero if it is not owned by the binding'() {
152152
given:
153-
def session = Mock(AsyncClientSession)
153+
def session = Mock(ClientSession)
154154
def wrappedBinding = createStubBinding()
155155
def binding = new ClientSessionBinding(session, false, wrappedBinding)
156156
binding.retain()
@@ -170,7 +170,7 @@ class ClientSessionBindingSpecification extends Specification {
170170

171171
def 'owned session is implicit'() {
172172
given:
173-
def session = Mock(AsyncClientSession)
173+
def session = Mock(ClientSession)
174174
def wrappedBinding = createStubBinding()
175175

176176
when:

0 commit comments

Comments
 (0)