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