Skip to content

Commit df2cb88

Browse files
committed
Update javadoc.
Remove redundant methods. JAVA-5530
1 parent e6a0a7e commit df2cb88

File tree

9 files changed

+75
-85
lines changed

9 files changed

+75
-85
lines changed

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

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -122,49 +122,6 @@ static AsyncRunnable beginAsync() {
122122
return (c) -> c.complete(c);
123123
}
124124

125-
/**
126-
* Must be invoked at end of async chain
127-
* @param runnable the sync code to invoke (under non-exceptional flow)
128-
* prior to the callback
129-
* @param callback the callback provided by the method the chain is used in
130-
*/
131-
default void thenRunAndFinish(final Runnable runnable, final SingleResultCallback<Void> callback) {
132-
this.finish((r, e) -> {
133-
if (e != null) {
134-
callback.completeExceptionally(e);
135-
return;
136-
}
137-
try {
138-
runnable.run();
139-
} catch (Throwable t) {
140-
callback.completeExceptionally(t);
141-
return;
142-
}
143-
callback.complete(callback);
144-
});
145-
}
146-
147-
/**
148-
* See {@link #thenRunAndFinish(Runnable, SingleResultCallback)}, but the runnable
149-
* will always be executed, including on the exceptional path.
150-
* @param runnable the runnable
151-
* @param callback the callback
152-
*/
153-
default void thenAlwaysRunAndFinish(final Runnable runnable, final SingleResultCallback<Void> callback) {
154-
this.finish((r, e) -> {
155-
try {
156-
runnable.run();
157-
} catch (Throwable t) {
158-
if (e != null) {
159-
t.addSuppressed(e);
160-
}
161-
callback.completeExceptionally(t);
162-
return;
163-
}
164-
callback.onResult(r, e);
165-
});
166-
}
167-
168125
/**
169126
* @param runnable The async runnable to run after this runnable
170127
* @return the composition of this runnable and the runnable, a runnable

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

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,30 @@ default void finish(final SingleResultCallback<T> callback) {
8282
}
8383

8484
/**
85-
* The runnable will always be executed, including on the exceptional path.
85+
* Must be invoked at end of async chain
86+
* @param runnable the sync code to invoke (under non-exceptional flow)
87+
* prior to the callback
88+
* @param callback the callback provided by the method the chain is used in
89+
*/
90+
default void thenRunAndFinish(final Runnable runnable, final SingleResultCallback<T> callback) {
91+
this.finish((r, e) -> {
92+
if (e != null) {
93+
callback.completeExceptionally(e);
94+
return;
95+
}
96+
try {
97+
runnable.run();
98+
} catch (Throwable t) {
99+
callback.completeExceptionally(t);
100+
return;
101+
}
102+
callback.onResult(r, null);
103+
});
104+
}
105+
106+
/**
107+
* See {@link #thenRunAndFinish(Runnable, SingleResultCallback)}, but the runnable
108+
* will always be executed, including on the exceptional path.
86109
* @param runnable the runnable
87110
* @param callback the callback
88111
*/

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@
1616
package com.mongodb.internal.async;
1717

1818
import com.mongodb.annotations.NotThreadSafe;
19-
import com.mongodb.assertions.Assertions;
2019
import com.mongodb.lang.Nullable;
2120

21+
import static com.mongodb.assertions.Assertions.assertNotNull;
22+
2223
@NotThreadSafe
2324
public final class MutableValue<T> {
2425
private T value;
@@ -32,7 +33,7 @@ public MutableValue() {
3233
}
3334

3435
public T get() {
35-
return Assertions.assertNotNull(value);
36+
return assertNotNull(value);
3637
}
3738

3839
@Nullable

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

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ public interface MongoCluster {
391391
* @mongodb.server.release 8.0
392392
* @mongodb.driver.manual reference/command/bulkWrite/ bulkWrite
393393
*/
394-
Publisher<ClientBulkWriteResult> bulkWrite(List<? extends ClientNamespacedWriteModel> models) throws ClientBulkWriteException;
394+
Publisher<ClientBulkWriteResult> bulkWrite(List<? extends ClientNamespacedWriteModel> models);
395395

396396
/**
397397
* Executes a client-level bulk write operation.
@@ -406,18 +406,24 @@ public interface MongoCluster {
406406
*
407407
* @param models The {@linkplain ClientNamespacedWriteModel individual write operations}.
408408
* @param options The options.
409-
* @return The {@link Publisher} with a single element which could be: The {@link ClientBulkWriteResult} if the operation is successful.
410-
* The {@link ClientBulkWriteException} if and only if the operation is unsuccessful or partially unsuccessful,
411-
* and there is at least one of the following pieces of information to report:
412-
* {@link ClientBulkWriteException#getWriteConcernErrors()}, {@link ClientBulkWriteException#getWriteErrors()},
413-
* {@link ClientBulkWriteException#getPartialResult()}. The {@link MongoException} only if the operation is unsuccessful.
409+
* @return The {@link Publisher} signalling at most one element {@link ClientBulkWriteResult} if the operation is successful,
410+
* or the following errors:
411+
* <ul>
412+
* <li>
413+
* {@link ClientBulkWriteException} - If and only if the operation is unsuccessful or partially unsuccessful,
414+
* and there is at least one of the following pieces of information to report:
415+
* {@link ClientBulkWriteException#getWriteConcernErrors()}, {@link ClientBulkWriteException#getWriteErrors()},
416+
* {@link ClientBulkWriteException#getPartialResult()}.</li>
417+
* <li>
418+
* {@link MongoException} - Only if the operation is unsuccessful.</li>
419+
* </ul>
414420
* @since 5.3
415421
* @mongodb.server.release 8.0
416422
* @mongodb.driver.manual reference/command/bulkWrite/ bulkWrite
417423
*/
418424
Publisher<ClientBulkWriteResult> bulkWrite(
419425
List<? extends ClientNamespacedWriteModel> models,
420-
ClientBulkWriteOptions options) throws ClientBulkWriteException;
426+
ClientBulkWriteOptions options);
421427

422428
/**
423429
* Executes a client-level bulk write operation.
@@ -434,18 +440,24 @@ Publisher<ClientBulkWriteResult> bulkWrite(
434440
*
435441
* @param clientSession The {@linkplain ClientSession client session} with which to associate this operation.
436442
* @param models The {@linkplain ClientNamespacedWriteModel individual write operations}.
437-
* @return The {@link Publisher} with a single element which could be: The {@link ClientBulkWriteResult} if the operation is successful.
438-
* The {@link ClientBulkWriteException} if and only if the operation is unsuccessful or partially unsuccessful,
439-
* and there is at least one of the following pieces of information to report:
440-
* {@link ClientBulkWriteException#getWriteConcernErrors()}, {@link ClientBulkWriteException#getWriteErrors()},
441-
* {@link ClientBulkWriteException#getPartialResult()}. The {@link MongoException} only if the operation is unsuccessful.
443+
* @return The {@link Publisher} signalling at most one element {@link ClientBulkWriteResult} if the operation is successful,
444+
* or the following errors:
445+
* <ul>
446+
* <li>
447+
* {@link ClientBulkWriteException} - If and only if the operation is unsuccessful or partially unsuccessful,
448+
* and there is at least one of the following pieces of information to report:
449+
* {@link ClientBulkWriteException#getWriteConcernErrors()}, {@link ClientBulkWriteException#getWriteErrors()},
450+
* {@link ClientBulkWriteException#getPartialResult()}.</li>
451+
* <li>
452+
* {@link MongoException} - Only if the operation is unsuccessful.</li>
453+
* </ul>
442454
* @since 5.3
443455
* @mongodb.server.release 8.0
444456
* @mongodb.driver.manual reference/command/bulkWrite/ bulkWrite
445457
*/
446458
Publisher<ClientBulkWriteResult> bulkWrite(
447459
ClientSession clientSession,
448-
List<? extends ClientNamespacedWriteModel> models) throws ClientBulkWriteException;
460+
List<? extends ClientNamespacedWriteModel> models);
449461

450462
/**
451463
* Executes a client-level bulk write operation.
@@ -461,17 +473,23 @@ Publisher<ClientBulkWriteResult> bulkWrite(
461473
* @param clientSession The {@linkplain ClientSession client session} with which to associate this operation.
462474
* @param models The {@linkplain ClientNamespacedWriteModel individual write operations}.
463475
* @param options The options.
464-
* @return The {@link Publisher} with a single element which could be: The {@link ClientBulkWriteResult} if the operation is successful.
465-
* The {@link ClientBulkWriteException} if and only if the operation is unsuccessful or partially unsuccessful,
466-
* and there is at least one of the following pieces of information to report:
467-
* {@link ClientBulkWriteException#getWriteConcernErrors()}, {@link ClientBulkWriteException#getWriteErrors()},
468-
* {@link ClientBulkWriteException#getPartialResult()}. The {@link MongoException} only if the operation is unsuccessful.
476+
* @return The {@link Publisher} signalling at most one element {@link ClientBulkWriteResult} if the operation is successful,
477+
* or the following errors:
478+
* <ul>
479+
* <li>
480+
* {@link ClientBulkWriteException} - If and only if the operation is unsuccessful or partially unsuccessful,
481+
* and there is at least one of the following pieces of information to report:
482+
* {@link ClientBulkWriteException#getWriteConcernErrors()}, {@link ClientBulkWriteException#getWriteErrors()},
483+
* {@link ClientBulkWriteException#getPartialResult()}.</li>
484+
* <li>
485+
* {@link MongoException} - Only if the operation is unsuccessful.</li>
486+
* </ul>
469487
* @since 5.3
470488
* @mongodb.server.release 8.0
471489
* @mongodb.driver.manual reference/command/bulkWrite/ bulkWrite
472490
*/
473491
Publisher<ClientBulkWriteResult> bulkWrite(
474492
ClientSession clientSession,
475493
List<? extends ClientNamespacedWriteModel> models,
476-
ClientBulkWriteOptions options) throws ClientBulkWriteException;
494+
ClientBulkWriteOptions options);
477495
}

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

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package com.mongodb.reactivestreams.client.internal;
1818

1919
import com.mongodb.AutoEncryptionSettings;
20-
import com.mongodb.ClientBulkWriteException;
2120
import com.mongodb.ClientSessionOptions;
2221
import com.mongodb.ContextProvider;
2322
import com.mongodb.MongoClientSettings;
@@ -234,29 +233,26 @@ public <TResult> ChangeStreamPublisher<TResult> watch(
234233
}
235234

236235
@Override
237-
public Publisher<ClientBulkWriteResult> bulkWrite(final List<? extends ClientNamespacedWriteModel> models)
238-
throws ClientBulkWriteException {
236+
public Publisher<ClientBulkWriteResult> bulkWrite(final List<? extends ClientNamespacedWriteModel> models) {
239237
return delegate.bulkWrite(models);
240238
}
241239

242240
@Override
243241
public Publisher<ClientBulkWriteResult> bulkWrite(final List<? extends ClientNamespacedWriteModel> models,
244-
final ClientBulkWriteOptions options)
245-
throws ClientBulkWriteException {
242+
final ClientBulkWriteOptions options) {
246243
return delegate.bulkWrite(models, options);
247244
}
248245

249246
@Override
250247
public Publisher<ClientBulkWriteResult> bulkWrite(final ClientSession clientSession,
251-
final List<? extends ClientNamespacedWriteModel> models)
252-
throws ClientBulkWriteException {
248+
final List<? extends ClientNamespacedWriteModel> models) {
253249
return delegate.bulkWrite(clientSession, models);
254250
}
255251

256252
@Override
257253
public Publisher<ClientBulkWriteResult> bulkWrite(final ClientSession clientSession,
258254
final List<? extends ClientNamespacedWriteModel> models,
259-
final ClientBulkWriteOptions options) throws ClientBulkWriteException {
255+
final ClientBulkWriteOptions options) {
260256
return delegate.bulkWrite(clientSession, models, options);
261257
}
262258

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ public final class MongoOperationPublisher<T> {
9595

9696
private final AsyncOperations<T> operations;
9797
private final UuidRepresentation uuidRepresentation;
98+
@Nullable
9899
private final AutoEncryptionSettings autoEncryptionSettings;
99100
private final OperationExecutor executor;
100101

@@ -249,7 +250,7 @@ Publisher<Void> createCollection(
249250
@Nullable final ClientSession clientSession, final String collectionName, final CreateCollectionOptions options) {
250251
return createWriteOperationMono(
251252
operations::getTimeoutSettings,
252-
operations.createCollection(collectionName, options, autoEncryptionSettings), clientSession);
253+
() -> operations.createCollection(collectionName, options, autoEncryptionSettings), clientSession);
253254
}
254255

255256
Publisher<Void> createView(
@@ -522,11 +523,6 @@ <R> Mono<R> createWriteOperationMono(final Supplier<TimeoutSettings> timeoutSett
522523
return getExecutor(timeoutSettingsSupplier.get())
523524
.execute(writeOperation, getReadConcern(), clientSession);
524525
}
525-
<R> Mono<R> createWriteOperationMono(final Supplier<TimeoutSettings> timeoutSettingsSupplier,
526-
final AsyncWriteOperation<R> writeOperation, @Nullable final ClientSession clientSession) {
527-
return getExecutor(timeoutSettingsSupplier.get())
528-
.execute(writeOperation, getReadConcern(), clientSession);
529-
}
530526

531527
private Mono<BulkWriteResult> createSingleWriteRequestMono(
532528
final Supplier<AsyncWriteOperation<BulkWriteResult>> operation,

driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/unified/UnifiedReactiveStreamsTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ protected UnifiedReactiveStreamsTest() {
4646

4747
@Override
4848
protected MongoClient createMongoClient(final MongoClientSettings settings) {
49-
com.mongodb.reactivestreams.client.MongoClient wrapped = MongoClients.create(settings);
50-
return new SyncMongoClient(wrapped);
49+
return new SyncMongoClient(MongoClients.create(settings));
5150
}
5251

5352
@Override

driver-sync/src/test/functional/com/mongodb/client/CrudProseTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,8 +430,9 @@ protected void testBulkWriteErrorsForAutoEncryption() {
430430
assertTrue(
431431
assertThrows(
432432
IllegalStateException.class,
433-
() -> client.bulkWrite(singletonList(insertOne(NAMESPACE, new Document("a", "b")))))
434-
.getMessage().contains("bulkWrite does not currently support automatic encryption"));
433+
() -> client.bulkWrite(singletonList(insertOne(NAMESPACE, new Document("a", "b"))))
434+
).getMessage().contains("bulkWrite does not currently support automatic encryption")
435+
);
435436
}
436437
}
437438

driver-sync/src/test/functional/com/mongodb/client/unified/UnifiedTestModifications.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public static void doSkips(final TestDef def) {
4747
// change-streams
4848
def.skipNoncompliantReactive("error required from change stream initialization") // TODO reason?
4949
.test("change-streams", "change-streams", "Test with document comment - pre 4.4");
50-
def.skipNoncompliantReactive("event sensitive tests. We can't guarantee the amount of GetMore commands sent in the reactive driver")
50+
def.skipNoncompliantReactive("event sensitive tests") // TODO reason?
5151
.test("change-streams", "change-streams", "Test that comment is set on getMore")
5252
.test("change-streams", "change-streams", "Test that comment is not set on getMore - pre 4.4");
5353
def.modify(IGNORE_EXTRA_EVENTS)
@@ -197,7 +197,6 @@ public static void doSkips(final TestDef def) {
197197
.test("retryable-writes", "findOneAndDelete-errorLabels", "FindOneAndDelete succeeds after WriteConcernError ShutdownInProgress")
198198
.test("retryable-writes", "findOneAndReplace-errorLabels", "FindOneAndReplace succeeds after WriteConcernError ShutdownInProgress")
199199
//.testContains("retryable-writes", "succeeds after retryable writeConcernError")
200-
.test("retryable-writes", "client bulkWrite retryable writes", "client bulkWrite with no multi: true operations succeeds after retryable writeConcernError")
201200
.test("retryable-writes", "retryable-writes insertOne serverErrors", "InsertOne succeeds after retryable writeConcernError")
202201
.test("retryable-writes", "retryable-writes bulkWrite serverErrors", "BulkWrite succeeds after retryable writeConcernError in first batch");
203202
def.skipJira("https://jira.mongodb.org/browse/JAVA-5341")

0 commit comments

Comments
 (0)