Fixing OpenWireConnectionTimeoutTest.

- It seems checking configuredOk can't be done that early.
- Falling back to let the Timer be created and make sure it is disposed of.
This commit is contained in:
Axel Sanguinetti 2023-11-15 10:26:27 -03:00
parent 40bedf7f0c
commit e8cf40e24f
No known key found for this signature in database
GPG Key ID: F2D72359EE2954E9
2 changed files with 20 additions and 5 deletions

View File

@ -437,6 +437,17 @@ public abstract class AbstractInactivityMonitor extends TransportFilter {
synchronized (AbstractInactivityMonitor.class) { synchronized (AbstractInactivityMonitor.class) {
READ_CHECK_TIMER.purge(); READ_CHECK_TIMER.purge();
CHECKER_COUNTER--; CHECKER_COUNTER--;
if (CHECKER_COUNTER == 0) {
if (READ_CHECK_TIMER != null) {
READ_CHECK_TIMER.cancel();
READ_CHECK_TIMER = null;
}
try {
ThreadPoolUtils.shutdownGraceful(ASYNC_TASKS, 0);
} finally {
ASYNC_TASKS = null;
}
}
} }
} }
} }
@ -497,10 +508,14 @@ public abstract class AbstractInactivityMonitor extends TransportFilter {
READ_CHECK_TIMER.purge(); READ_CHECK_TIMER.purge();
CHECKER_COUNTER--; CHECKER_COUNTER--;
if (CHECKER_COUNTER == 0) { if (CHECKER_COUNTER == 0) {
WRITE_CHECK_TIMER.cancel(); if (WRITE_CHECK_TIMER != null) {
READ_CHECK_TIMER.cancel(); WRITE_CHECK_TIMER.cancel();
WRITE_CHECK_TIMER = null; WRITE_CHECK_TIMER = null;
READ_CHECK_TIMER = null; }
if (READ_CHECK_TIMER != null) {
READ_CHECK_TIMER.cancel();
READ_CHECK_TIMER = null;
}
try { try {
ThreadPoolUtils.shutdownGraceful(ASYNC_TASKS, 0); ThreadPoolUtils.shutdownGraceful(ASYNC_TASKS, 0);
} finally { } finally {

View File

@ -46,7 +46,7 @@ public class InactivityMonitor extends AbstractInactivityMonitor {
@Override @Override
public void start() throws Exception { public void start() throws Exception {
if (!isMonitorStarted() && configuredOk()) { if (!isMonitorStarted()) {
startConnectCheckTask(); startConnectCheckTask();
} }
super.start(); super.start();