Skip to content

Commit d84dabb

Browse files
authored
Fix reactive streams MongoClient.getTimeout always returning null (#2009)
JAVA-6246
1 parent aad04d1 commit d84dabb

4 files changed

Lines changed: 9 additions & 3 deletions

File tree

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,9 @@ public ReadConcern getReadConcern() {
291291
}
292292

293293
@Override
294+
@Nullable
294295
public Long getTimeout(final TimeUnit timeUnit) {
295-
return null;
296+
return delegate.getTimeout(timeUnit);
296297
}
297298

298299
@Override

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,11 @@ public ReadConcern getReadConcern() {
9191
}
9292

9393
@Override
94+
@Nullable
9495
public Long getTimeout(final TimeUnit timeUnit) {
96+
notNull("timeUnit", timeUnit);
9597
Long timeoutMS = mongoOperationPublisher.getTimeoutMS();
96-
return timeoutMS != null ? MILLISECONDS.convert(timeoutMS, timeUnit) : null;
98+
return timeoutMS == null ? null : timeUnit.convert(timeoutMS, MILLISECONDS);
9799
}
98100

99101
@Override

driver-sync/src/main/com/mongodb/client/internal/MongoClientImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ public ReadConcern getReadConcern() {
167167
}
168168

169169
@Override
170+
@Nullable
170171
public Long getTimeout(final TimeUnit timeUnit) {
171172
return delegate.getTimeout(timeUnit);
172173
}

driver-sync/src/main/com/mongodb/client/internal/MongoClusterImpl.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
import static com.mongodb.assertions.Assertions.isTrueArgument;
7979
import static com.mongodb.assertions.Assertions.notNull;
8080
import static com.mongodb.internal.TimeoutContext.createTimeoutContext;
81+
import static java.util.concurrent.TimeUnit.MILLISECONDS;
8182

8283
final class MongoClusterImpl implements MongoCluster {
8384
@Nullable
@@ -163,8 +164,9 @@ public ReadConcern getReadConcern() {
163164
@Override
164165
@Nullable
165166
public Long getTimeout(final TimeUnit timeUnit) {
167+
notNull("timeUnit", timeUnit);
166168
Long timeoutMS = timeoutSettings.getTimeoutMS();
167-
return timeoutMS == null ? null : timeUnit.convert(timeoutMS, TimeUnit.MILLISECONDS);
169+
return timeoutMS == null ? null : timeUnit.convert(timeoutMS, MILLISECONDS);
168170
}
169171

170172
@Override

0 commit comments

Comments
 (0)