Details
Description
I'm using the 4/16 5.2 SNAPSHOT code.
I'm reporting a new issue here, but this may be related or same as: AMQ-1482, and AMQ-1582.
The issue is that if there is an exception on a connection, such as the process goes away (could be an AMQBroker going away or a client process), the InactivityMonitor is not properly reporting this. If maxInactivityDuration is set to 0, and the client process goes away, the AMQBroker never cleans up anything for this client, and the client can never reconnect (it will get InvalidClientID exceptions). If maxInactivityDuration is non-zero, the connection will eventually get cleaned up when the inactivity timer pops.
The issue turns out to be this line of code in InactivityMonitor::onException
if (!failed.compareAndSet(false,true)) {
This means that when the connection goes away, this call returns true, but the if statement is negating that so the next two lines of code in onException are never executed at this time. Only later (if maxInactivityDuration is non-zero) will this check result in true, such that the next two lines in onException are called.
I think that this is just an issue in misinterpreting what AtomicBoolean will return for the compareAndSet method? Assuming this to be the case, I changed this line to take out the "!". Now everything works exactly as it should.
I've attached the changed source.