mirror of https://github.com/OpenVidu/openvidu.git
Improve error handling and logging in polling thread of OpenViduEventManager
parent
2d319ac131
commit
3f37b61b0d
|
|
@ -126,16 +126,21 @@ public class OpenViduEventManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.pollingThread = new Thread(() -> {
|
this.pollingThread = new Thread(() -> {
|
||||||
while (!this.isInterrupted.get()) {
|
try {
|
||||||
this.getEventsFromBrowser();
|
while (!this.isInterrupted.get()) {
|
||||||
this.emitEvents();
|
this.getEventsFromBrowser();
|
||||||
try {
|
this.emitEvents();
|
||||||
Thread.sleep(25);
|
try {
|
||||||
} catch (InterruptedException e) {
|
Thread.sleep(25);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
log.info("Polling thread is now interrupted!");
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("Polling thread crashed: {}", e.getMessage());
|
||||||
|
} finally {
|
||||||
|
this.pollingLatch.countDown();
|
||||||
}
|
}
|
||||||
log.info("Polling thread is now interrupted!");
|
|
||||||
this.pollingLatch.countDown();
|
|
||||||
});
|
});
|
||||||
this.pollingThread.setUncaughtExceptionHandler(h);
|
this.pollingThread.setUncaughtExceptionHandler(h);
|
||||||
this.pollingThread.start();
|
this.pollingThread.start();
|
||||||
|
|
@ -261,7 +266,9 @@ public class OpenViduEventManager {
|
||||||
|
|
||||||
public void resetEventThread(boolean clearData) throws InterruptedException {
|
public void resetEventThread(boolean clearData) throws InterruptedException {
|
||||||
this.stopPolling(true, clearData);
|
this.stopPolling(true, clearData);
|
||||||
this.pollingLatch.await();
|
if (!this.pollingLatch.await(10, TimeUnit.SECONDS)) {
|
||||||
|
log.warn("Polling thread did not stop within 10 seconds");
|
||||||
|
}
|
||||||
this.execService.shutdownNow();
|
this.execService.shutdownNow();
|
||||||
this.execService.awaitTermination(10, TimeUnit.SECONDS);
|
this.execService.awaitTermination(10, TimeUnit.SECONDS);
|
||||||
this.execService = Executors.newCachedThreadPool();
|
this.execService = Executors.newCachedThreadPool();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue