Skip to content

Commit

Permalink
fix(uat): switch from file to in-memory persistence module in paho-java
Browse files Browse the repository at this point in the history
  • Loading branch information
bgklika committed Aug 1, 2023
1 parent 57b22e2 commit d873d13
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -189,9 +190,9 @@ public MqttSubscribeReply unsubscribe(long timeout, @NonNull List<String> 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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -264,9 +265,10 @@ public MqttSubscribeReply unsubscribe(long timeout, @NonNull List<String> 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<Mqtt5Properties> userProperties)
Expand Down

0 comments on commit d873d13

Please sign in to comment.