From d873d139e4188b0b9d5518da768dad6dd7f8c990 Mon Sep 17 00:00:00 2001 From: Vitaly Khalmansky Date: Tue, 1 Aug 2023 15:43:16 +0200 Subject: [PATCH] fix(uat): switch from file to in-memory persistence module in paho-java --- .../mqtt311/client/paho/Mqtt311ConnectionImpl.java | 7 ++++--- .../testing/mqtt5/client/paho/MqttConnectionImpl.java | 8 +++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/uat/custom-components/client-java-paho/src/main/java/com/aws/greengrass/testing/mqtt311/client/paho/Mqtt311ConnectionImpl.java b/uat/custom-components/client-java-paho/src/main/java/com/aws/greengrass/testing/mqtt311/client/paho/Mqtt311ConnectionImpl.java index 965703736..069d8c5d6 100644 --- a/uat/custom-components/client-java-paho/src/main/java/com/aws/greengrass/testing/mqtt311/client/paho/Mqtt311ConnectionImpl.java +++ b/uat/custom-components/client-java-paho/src/main/java/com/aws/greengrass/testing/mqtt311/client/paho/Mqtt311ConnectionImpl.java @@ -24,6 +24,7 @@ import org.eclipse.paho.client.mqttv3.MqttCallback; import org.eclipse.paho.client.mqttv3.MqttConnectOptions; import org.eclipse.paho.client.mqttv3.MqttMessage; +import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence; import java.io.IOException; import java.security.GeneralSecurityException; @@ -189,9 +190,9 @@ public MqttSubscribeReply unsubscribe(long timeout, @NonNull List filter */ private IMqttAsyncClient createAsyncClient(MqttLib.ConnectionParams connectionParams) throws org.eclipse.paho.client.mqttv3.MqttException { - String uri = createUri(connectionParams.getHost(), connectionParams.getPort(), - connectionParams.getCert() != null); - return new MqttAsyncClient(uri, connectionParams.getClientId()); + final boolean hasTls = connectionParams.getCert() != null; + final String uri = createUri(connectionParams.getHost(), connectionParams.getPort(), hasTls); + return new MqttAsyncClient(uri, connectionParams.getClientId(), new MemoryPersistence()); } private MqttConnectOptions convertParams(MqttLib.ConnectionParams connectionParams) diff --git a/uat/custom-components/client-java-paho/src/main/java/com/aws/greengrass/testing/mqtt5/client/paho/MqttConnectionImpl.java b/uat/custom-components/client-java-paho/src/main/java/com/aws/greengrass/testing/mqtt5/client/paho/MqttConnectionImpl.java index 250230206..497472887 100644 --- a/uat/custom-components/client-java-paho/src/main/java/com/aws/greengrass/testing/mqtt5/client/paho/MqttConnectionImpl.java +++ b/uat/custom-components/client-java-paho/src/main/java/com/aws/greengrass/testing/mqtt5/client/paho/MqttConnectionImpl.java @@ -23,6 +23,7 @@ import org.eclipse.paho.mqttv5.client.MqttCallback; import org.eclipse.paho.mqttv5.client.MqttConnectionOptions; import org.eclipse.paho.mqttv5.client.MqttDisconnectResponse; +import org.eclipse.paho.mqttv5.client.persist.MemoryPersistence; import org.eclipse.paho.mqttv5.common.MqttMessage; import org.eclipse.paho.mqttv5.common.MqttSubscription; import org.eclipse.paho.mqttv5.common.packet.MqttProperties; @@ -264,9 +265,10 @@ public MqttSubscribeReply unsubscribe(long timeout, @NonNull List filter */ private IMqttAsyncClient createAsyncClient(MqttLib.ConnectionParams connectionParams) throws org.eclipse.paho.mqttv5.common.MqttException { - String uri = createUri(connectionParams.getHost(), connectionParams.getPort(), - connectionParams.getCert() != null); - return new MqttAsyncClient(uri, connectionParams.getClientId()); + final boolean hasTls = connectionParams.getCert() != null; + final String uri = createUri(connectionParams.getHost(), connectionParams.getPort(), hasTls); + + return new MqttAsyncClient(uri, connectionParams.getClientId(), new MemoryPersistence()); } private void disconnectAndClose(long timeout, int reasonCode, List userProperties)