Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,9 @@ public ReadConcern getReadConcern() {
}

@Override
@Nullable
public Long getTimeout(final TimeUnit timeUnit) {
return null;
return delegate.getTimeout(timeUnit);
}
Comment thread
stIncMale marked this conversation as resolved.

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,11 @@ public ReadConcern getReadConcern() {
}

@Override
@Nullable
public Long getTimeout(final TimeUnit timeUnit) {
notNull("timeUnit", timeUnit);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I added the notNull checks to MongoClusterImpl and not MongoClientImpl to be consistent with the rest of the code. However, the approach is wrong, and the checks should be in MongoClientImpl instead, because at run time an application directly calls methods of MongoClientImpl, not MongoClusterImpl.

Long timeoutMS = mongoOperationPublisher.getTimeoutMS();
return timeoutMS != null ? MILLISECONDS.convert(timeoutMS, timeUnit) : null;
return timeoutMS == null ? null : timeUnit.convert(timeoutMS, MILLISECONDS);
Comment thread
stIncMale marked this conversation as resolved.
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ public ReadConcern getReadConcern() {
}

@Override
@Nullable
public Long getTimeout(final TimeUnit timeUnit) {
return delegate.getTimeout(timeUnit);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
import static com.mongodb.assertions.Assertions.isTrueArgument;
import static com.mongodb.assertions.Assertions.notNull;
import static com.mongodb.internal.TimeoutContext.createTimeoutContext;
import static java.util.concurrent.TimeUnit.MILLISECONDS;

final class MongoClusterImpl implements MongoCluster {
@Nullable
Expand Down Expand Up @@ -163,8 +164,9 @@ public ReadConcern getReadConcern() {
@Override
@Nullable
public Long getTimeout(final TimeUnit timeUnit) {
notNull("timeUnit", timeUnit);
Long timeoutMS = timeoutSettings.getTimeoutMS();
return timeoutMS == null ? null : timeUnit.convert(timeoutMS, TimeUnit.MILLISECONDS);
return timeoutMS == null ? null : timeUnit.convert(timeoutMS, MILLISECONDS);
Comment thread
stIncMale marked this conversation as resolved.
}

@Override
Expand Down