Skip to content

Commit 17a5cc2

Browse files
committed
JAVA-2815: Remove autoStartTransaction option
1 parent 99c2e19 commit 17a5cc2

File tree

9 files changed

+2
-792
lines changed

9 files changed

+2
-792
lines changed

driver-async/src/main/com/mongodb/async/client/ClientSessionImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public void onResult(final Void result, final Throwable t) {
126126
}
127127

128128
private boolean canCommitOrAbort() {
129-
return inTransaction || getOptions().getAutoStartTransaction();
129+
return inTransaction;
130130
}
131131

132132
// TODO: should there be a version of this that takes a callback?

driver-async/src/main/com/mongodb/async/client/OperationExecutorImpl.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,6 @@ private AsyncReadWriteBinding getReadWriteBinding(final ReadPreference readPrefe
124124
AsyncReadWriteBinding readWriteBinding = new AsyncClusterBinding(mongoClient.getCluster(),
125125
getReadPreferenceForBinding(readPreference, session), readConcern);
126126
if (session != null) {
127-
if (!session.hasActiveTransaction() && session.getOptions().getAutoStartTransaction()) {
128-
session.startTransaction();
129-
}
130127
readWriteBinding = new ClientSessionBinding(session, ownsSession, readWriteBinding);
131128
}
132129
return readWriteBinding;

driver-async/src/test/functional/com/mongodb/async/client/TransactionsTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,6 @@ private ClientSession createSession(final String sessionName) {
181181
.getDocument(sessionName, new BsonDocument());
182182
final ClientSessionOptions options = ClientSessionOptions.builder()
183183
.causallyConsistent(optionsDocument.getBoolean("causalConsistency", BsonBoolean.TRUE).getValue())
184-
.autoStartTransaction(optionsDocument.getBoolean("autoStartTransaction", BsonBoolean.FALSE).getValue())
185184
.defaultTransactionOptions(createDefaultTransactionOptions(optionsDocument))
186185
.build();
187186
return new MongoOperation<ClientSession>() {

driver-core/src/main/com/mongodb/ClientSessionOptions.java

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
public final class ClientSessionOptions {
3636

3737
private final Boolean causallyConsistent;
38-
private final boolean autoStartTransaction;
3938
private final TransactionOptions defaultTransactionOptions;
4039

4140
/**
@@ -50,17 +49,6 @@ public Boolean isCausallyConsistent() {
5049
return causallyConsistent;
5150
}
5251

53-
/**
54-
* Gets whether a transaction should be automatically started along with the session.
55-
*
56-
* @return whether a transaction should be automatically started along with the session. The default is false.
57-
* @since 3.8
58-
* @mongodb.server.release 4.0
59-
*/
60-
public boolean getAutoStartTransaction() {
61-
return autoStartTransaction;
62-
}
63-
6452
/**
6553
* Gets the default transaction options for the session.
6654
*
@@ -83,9 +71,6 @@ public boolean equals(final Object o) {
8371

8472
ClientSessionOptions that = (ClientSessionOptions) o;
8573

86-
if (autoStartTransaction != that.autoStartTransaction) {
87-
return false;
88-
}
8974
if (causallyConsistent != null ? !causallyConsistent.equals(that.causallyConsistent) : that.causallyConsistent != null) {
9075
return false;
9176
}
@@ -100,7 +85,6 @@ public boolean equals(final Object o) {
10085
@Override
10186
public int hashCode() {
10287
int result = causallyConsistent != null ? causallyConsistent.hashCode() : 0;
103-
result = 31 * result + (autoStartTransaction ? 1 : 0);
10488
result = 31 * result + (defaultTransactionOptions != null ? defaultTransactionOptions.hashCode() : 0);
10589
return result;
10690
}
@@ -109,7 +93,6 @@ public int hashCode() {
10993
public String toString() {
11094
return "ClientSessionOptions{"
11195
+ "causallyConsistent=" + causallyConsistent
112-
+ ", autoStartTransaction=" + autoStartTransaction
11396
+ ", defaultTransactionOptions=" + defaultTransactionOptions
11497
+ '}';
11598
}
@@ -134,7 +117,6 @@ public static Builder builder(final ClientSessionOptions options) {
134117
notNull("options", options);
135118
Builder builder = new Builder();
136119
builder.causallyConsistent = options.isCausallyConsistent();
137-
builder.autoStartTransaction = options.getAutoStartTransaction();
138120
builder.defaultTransactionOptions = options.getDefaultTransactionOptions();
139121
return builder;
140122
}
@@ -145,7 +127,6 @@ public static Builder builder(final ClientSessionOptions options) {
145127
@NotThreadSafe
146128
public static final class Builder {
147129
private Boolean causallyConsistent;
148-
private boolean autoStartTransaction;
149130
private TransactionOptions defaultTransactionOptions = TransactionOptions.builder().build();
150131

151132
/**
@@ -160,20 +141,6 @@ public Builder causallyConsistent(final boolean causallyConsistent) {
160141
return this;
161142
}
162143

163-
/**
164-
* Sets whether operations using the session should causally consistent with each other.
165-
*
166-
* @param autoStartTransaction whether a transaction should be started automatically when the session is started.
167-
*
168-
* @return this
169-
* @since 3.8
170-
* @mongodb.server.release 4.0
171-
*/
172-
public Builder autoStartTransaction(final boolean autoStartTransaction) {
173-
this.autoStartTransaction = autoStartTransaction;
174-
return this;
175-
}
176-
177144
/**
178145
* Sets whether operations using the session should causally consistent with each other.
179146
*
@@ -202,7 +169,6 @@ private Builder() {
202169

203170
private ClientSessionOptions(final Builder builder) {
204171
this.causallyConsistent = builder.causallyConsistent;
205-
this.autoStartTransaction = builder.autoStartTransaction;
206172
this.defaultTransactionOptions = builder.defaultTransactionOptions;
207173
}
208174
}

0 commit comments

Comments
 (0)