Details
Description
I am trying to achieve a clean shutdown of an embedded broker in a web application running in Tomcat. When the web application is shut down, Tomcat is always complaining about a running thread:
09:09:55.948 WARN [o.a.c.loader.WebappClassLoaderBase] [] The web application [xxx] appears to have started a thread named [ActiveMQ Transport Server Thread Handler: tcp://0.0.0.0:12345] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread: sun.misc.Unsafe.park(Native Method) java.util.concurrent.locks.LockSupport.parkNanos(Unknown Source) java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(Unknown Source) java.util.concurrent.LinkedBlockingQueue.poll(Unknown Source) org.apache.activemq.transport.tcp.TcpTransportServer$2.run(TcpTransportServer.java:427) java.lang.Thread.run(Unknown Source)
I am pretty sure this can be easily fixed by interrupting the socket handler thread, as suggested by Andreas Hartmann in AMQ-3451. Please see attached patch.