[avmfritz] Properly interrupt monitor thread upon dispose (#9201)
* Properly interrupt monitor thread upon dispose Signed-off-by: Kai Kreuzer <kai@openhab.org>
This commit is contained in:
parent
72b0c1473c
commit
a736e64402
|
@ -75,6 +75,10 @@ public class CallMonitor {
|
||||||
*/
|
*/
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
reconnectJob.cancel(true);
|
reconnectJob.cancel(true);
|
||||||
|
CallMonitorThread monitorThread = this.monitorThread;
|
||||||
|
if (monitorThread != null) {
|
||||||
|
monitorThread.interrupt();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class CallMonitorThread extends Thread {
|
public class CallMonitorThread extends Thread {
|
||||||
|
@ -120,11 +124,13 @@ public class CallMonitor {
|
||||||
handler.setStatusInfo(ThingStatus.ONLINE, ThingStatusDetail.NONE, null);
|
handler.setStatusInfo(ThingStatus.ONLINE, ThingStatusDetail.NONE, null);
|
||||||
while (!interrupted) {
|
while (!interrupted) {
|
||||||
try {
|
try {
|
||||||
String line = reader.readLine();
|
if (reader.ready()) {
|
||||||
if (line != null) {
|
String line = reader.readLine();
|
||||||
logger.debug("Received raw call string from fbox: {}", line);
|
if (line != null) {
|
||||||
CallEvent ce = new CallEvent(line);
|
logger.debug("Received raw call string from fbox: {}", line);
|
||||||
handleCallEvent(ce);
|
CallEvent ce = new CallEvent(line);
|
||||||
|
handleCallEvent(ce);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
if (interrupted) {
|
if (interrupted) {
|
||||||
|
@ -136,8 +142,9 @@ public class CallMonitor {
|
||||||
break;
|
break;
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
sleep(1000L);
|
sleep(500L);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
|
interrupted = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue