Skip to content

Commit 3ebe0c6

Browse files
committed
Implement Closeable directly in MongoClient
Some tools are generating spurious warnings about this, because while MongoClient implements Closeable, the close method itself is implemented in the deprecated Mongo superclass. JAVA-3099
1 parent 21dbd43 commit 3ebe0c6

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

driver-legacy/src/main/com/mongodb/MongoClient.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,14 @@ public <TResult> ChangeStreamIterable<TResult> watch(final ClientSession clientS
695695
return createChangeStreamIterable(clientSession, pipeline, resultClass);
696696
}
697697

698+
/**
699+
* Closes all resources associated with this instance, in particular any open network connections. Once called, this instance and any
700+
* databases obtained from it can no longer be used.
701+
*/
702+
public void close() {
703+
super.close();
704+
}
705+
698706
private <TResult> ChangeStreamIterable<TResult> createChangeStreamIterable(@Nullable final ClientSession clientSession,
699707
final List<? extends Bson> pipeline,
700708
final Class<TResult> resultClass) {

0 commit comments

Comments
 (0)