Skip to content

Commit c426b53

Browse files
author
Ian Craggs
committed
Missed part of #330 fix
1 parent 7e13cdf commit c426b53

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

  • org.eclipse.paho.client.mqttv3/src/main/java/org/eclipse/paho/client/mqttv3/internal

org.eclipse.paho.client.mqttv3/src/main/java/org/eclipse/paho/client/mqttv3/internal/CommsSender.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,11 @@ public void start(String threadName, ExecutorService executorService) {
6767
synchronized (lifecycle) {
6868
if (!running) {
6969
running = true;
70-
senderFuture = executorService.submit(this);
70+
if (executorService == null) {
71+
new Thread(this).start();
72+
} else {
73+
senderFuture = executorService.submit(this);
74+
}
7175
}
7276
}
7377
}
@@ -85,7 +89,6 @@ public void stop() {
8589
//@TRACE 800=stopping sender
8690
log.fine(CLASS_NAME,methodName,"800");
8791
if (running) {
88-
running = false;
8992
if (!Thread.currentThread().equals(sendThread)) {
9093
try {
9194
while (running) {
@@ -99,6 +102,7 @@ public void stop() {
99102
runningSemaphore.release();
100103
}
101104
}
105+
running = false;
102106
}
103107
sendThread=null;
104108
//@TRACE 801=stopped
@@ -187,4 +191,8 @@ private void handleRunException(MqttWireMessage message, Exception ex) {
187191
running = false;
188192
clientComms.shutdownConnection(null, mex);
189193
}
194+
195+
public boolean isRunning() {
196+
return running;
197+
}
190198
}

0 commit comments

Comments
 (0)