Description
The Failovertransport throws NullPointer Exceptions in case of a failover to another primary host for the following broker url:
failover:(tcp://primary_1:61616,tcp://primary_2:61616,tcp://secondary_1:61616,tcp://secondary_2:61616)?randomize=false&priorityBackup=true&priorityURIs=tcp://primary_1:61616,tcp://primary_2:61616&jms.alwaysSyncSend=true
Stack trace:
Exception in thread "ActiveMQ Task-2" java.lang.NullPointerException
at org.apache.activemq.transport.failover.FailoverTransport.disposeTransport(FailoverTransport.java:231)
at org.apache.activemq.transport.failover.FailoverTransport.doReconnect(FailoverTransport.java:954)
at org.apache.activemq.transport.failover.FailoverTransport$2.iterate(FailoverTransport.java:143)
at org.apache.activemq.thread.PooledTaskRunner.runTask(PooledTaskRunner.java:129)
at org.apache.activemq.thread.PooledTaskRunner$1.run(PooledTaskRunner.java:47)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
I assume that this is a copy-paste bug, since in the current revision (1478184, see link below) of the FailoverTransport on line #966, the variable 'old' should be checked for null instead of 'transport'. However, I have no clue why 'old' is null even though the transport was handling messages before the failover.
Current code:
955 Transport old = this.connectedTransport.getAndSet(null);
966 if (transport != null) {
967 disposeTransport(old);
968 }
Corrected code:
955 Transport old = this.connectedTransport.getAndSet(null);
966 if (old!= null) {
967 disposeTransport(old);
968 }