Skip to content

Commit 9810ce4

Browse files
committed
Clean up TLS Socket Factory in key management service
JAVA-3734
1 parent 868821a commit 9810ce4

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

driver-async/src/main/com/mongodb/async/client/internal/Crypt.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ public void close() {
242242
commandMarker.close();
243243
}
244244
keyRetriever.close();
245+
keyManagementService.close();
245246
}
246247

247248
private void executeStateMachine(final MongoCryptContext cryptContext, final String databaseName,

driver-async/src/main/com/mongodb/async/client/internal/KeyManagementService.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,24 @@
4040

4141
class KeyManagementService {
4242
private final int defaultPort;
43+
private final TlsChannelStreamFactoryFactory tlsChannelStreamFactoryFactory;
4344
private final StreamFactory streamFactory;
4445

4546
KeyManagementService(final SSLContext sslContext, final int defaultPort, final int timeoutMillis) {
4647
this.defaultPort = defaultPort;
47-
this.streamFactory = new TlsChannelStreamFactoryFactory().create(SocketSettings.builder()
48+
this.tlsChannelStreamFactoryFactory = new TlsChannelStreamFactoryFactory();
49+
this.streamFactory = tlsChannelStreamFactoryFactory.create(SocketSettings.builder()
4850
.connectTimeout(timeoutMillis, TimeUnit.MILLISECONDS)
4951
.readTimeout(timeoutMillis, TimeUnit.MILLISECONDS)
5052
.build(),
5153
SslSettings.builder().enabled(true).context(sslContext).build());
5254
}
5355

56+
57+
public void close() {
58+
tlsChannelStreamFactoryFactory.close();
59+
}
60+
5461
void decryptKey(final MongoKeyDecryptor keyDecryptor, final SingleResultCallback<Void> callback) {
5562
streamOpen(keyDecryptor, callback);
5663
}

0 commit comments

Comments
 (0)