Skip to content

Commit

Permalink
Resource Leak
Browse files Browse the repository at this point in the history
  • Loading branch information
bretambrose committed Feb 6, 2025
1 parent 8f361fe commit cdc25dd
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ static private Mqtt5Client createMqtt5Client() {
try (TlsContextOptions contextOptions = TlsContextOptions.createWithMtlsFromPath(
AWS_TEST_MQTT5_IOT_CORE_RSA_CERT,
AWS_TEST_MQTT5_IOT_CORE_RSA_KEY);) {
try (TlsContext tlsContext = new TlsContext(contextOptions);) {
try (TlsContext tlsContext = new TlsContext(contextOptions);
SocketOptions socketOptions = new SocketOptions();) {
CompletableFuture<Boolean> connected = new CompletableFuture<Boolean>();

String clientId = "aws-crt-java-" + (UUID.randomUUID()).toString();
Expand All @@ -122,7 +123,6 @@ static private Mqtt5Client createMqtt5Client() {
AWS_TEST_MQTT5_IOT_CORE_HOST,
(long) 8883);

SocketOptions socketOptions = new SocketOptions();
socketOptions.connectTimeoutMs = 10000;
socketOptions.domain = SocketOptions.SocketDomain.IPv4;
builder.withSocketOptions(socketOptions);
Expand Down Expand Up @@ -167,7 +167,8 @@ static private MqttClientConnection createMqtt311Client() {
try (TlsContextOptions contextOptions = TlsContextOptions.createWithMtlsFromPath(
AWS_TEST_MQTT5_IOT_CORE_RSA_CERT,
AWS_TEST_MQTT5_IOT_CORE_RSA_KEY);) {
try (TlsContext tlsContext = new TlsContext(contextOptions);) {
try (TlsContext tlsContext = new TlsContext(contextOptions);
SocketOptions socketOptions = new SocketOptions();) {
String clientId = "aws-crt-java-" + (UUID.randomUUID()).toString();

try (MqttClient client = new MqttClient(tlsContext);
Expand All @@ -176,8 +177,7 @@ static private MqttClientConnection createMqtt311Client() {
config.setClientId(clientId);
config.setEndpoint(AWS_TEST_MQTT5_IOT_CORE_HOST);
config.setPort(8883);

SocketOptions socketOptions = new SocketOptions();

socketOptions.connectTimeoutMs = 10000;
socketOptions.domain = SocketOptions.SocketDomain.IPv4;
config.setSocketOptions(socketOptions);
Expand Down

0 comments on commit cdc25dd

Please sign in to comment.