Set TCCL of shutdown thread when triggered by the shutdown endpoint
Previously, the shutdown endpoint would spawn a new thread to perform
the shutdown but did not explicitly configure its thread context
class loader (TCCL). This mean that the new thread would use the
request thread's TCCL as its TCCL. This meant that a different TCCL
would be used compared to a shutdown triggered by the shutdown hook
and also caused problems with Tomcat's thread leak detection logic.
This commit updates the shutdown endpoint to explicitly configure the
TCCL of the shutdown thread to be the ClassLoader that loaded the
endpoint's class.
Closes gh-6361
@ -58,7 +59,7 @@ public class ShutdownEndpoint extends AbstractEndpoint<Map<String, Object>>
@@ -58,7 +59,7 @@ public class ShutdownEndpoint extends AbstractEndpoint<Map<String, Object>>
}
finally{
newThread(newRunnable(){
Threadthread=newThread(newRunnable(){
@Override
publicvoidrun(){
try{
@ -69,8 +70,9 @@ public class ShutdownEndpoint extends AbstractEndpoint<Map<String, Object>>
@@ -69,8 +70,9 @@ public class ShutdownEndpoint extends AbstractEndpoint<Map<String, Object>>
@ -53,18 +58,30 @@ public class ShutdownEndpointTests extends AbstractEndpointTests<ShutdownEndpoin
@@ -53,18 +58,30 @@ public class ShutdownEndpointTests extends AbstractEndpointTests<ShutdownEndpoin
@ -77,6 +94,8 @@ public class ShutdownEndpointTests extends AbstractEndpointTests<ShutdownEndpoin
@@ -77,6 +94,8 @@ public class ShutdownEndpointTests extends AbstractEndpointTests<ShutdownEndpoin