You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Can you explain the logic behind this unit test? When the client attempts to acquire the lock, it registers the session monitor and starts the background thread that is the callback action.
final AcquireLockOptions options = stdSessionMonitorOptions(2 * heartbeatFreq, intSetter);
final LockItem item = heartClient.acquireLock(options);
This effectively ends up calling:
private void tryAddSessionMonitor(final String lockName, final LockItem lock) {
if (lock.hasSessionMonitor() && lock.hasCallback()) {
final Thread monitorThread = lockSessionMonitorChecker(lockName, lock);
monitorThread.setDaemon(true);
monitorThread.start();
this.sessionMonitors.put(lockName, monitorThread);
}
}
So, it starts the callback thread. When the client is closed, it calls removeKillSessionMonitor as it releases each lock, but that just interrupts the thread, so isn't this effectively a race condition between the callback thread and interrupting it? The only other place it looks like you might prevent the callback from being called is during the lockSessionMonitorChecker call where it checks the millisUntilDangerZone > 0, however since there's not necessarily a heartbeat sent yet, that value might be negative and appears to be another race condition to short-circuit the callback from ever being called.
Can you explain the logic behind this unit test and the expected behavior? Thanks!
The text was updated successfully, but these errors were encountered:
Can you explain the logic behind this unit test? When the client attempts to acquire the lock, it registers the session monitor and starts the background thread that is the callback action.
This effectively ends up calling:
So, it starts the callback thread. When the client is closed, it calls
removeKillSessionMonitor
as it releases each lock, but that just interrupts the thread, so isn't this effectively a race condition between the callback thread and interrupting it? The only other place it looks like you might prevent the callback from being called is during thelockSessionMonitorChecker
call where it checks themillisUntilDangerZone > 0
, however since there's not necessarily a heartbeat sent yet, that value might be negative and appears to be another race condition to short-circuit the callback from ever being called.Can you explain the logic behind this unit test and the expected behavior? Thanks!
The text was updated successfully, but these errors were encountered: