Index: java/org/apache/catalina/core/ContainerBase.java
===================================================================
--- java/org/apache/catalina/core/ContainerBase.java (revision 1611495)
+++ java/org/apache/catalina/core/ContainerBase.java (working copy)
@@ -1335,14 +1335,28 @@
@Override
public void run() {
- while (!threadDone) {
- try {
- Thread.sleep(backgroundProcessorDelay * 1000L);
- } catch (InterruptedException e) {
- // Ignore
+ Throwable t = null;
+ String unexpectedDeathMessage = sm.getString(
+ "containerBase.backgroundProcess.unexpectedThreadDeath",
+ Thread.currentThread().getName());
+ try {
+ while (!threadDone) {
+ try {
+ Thread.sleep(backgroundProcessorDelay * 1000L);
+ } catch (InterruptedException e) {
+ // Ignore
+ }
+ if (!threadDone) {
+ processChildren(ContainerBase.this);
+ }
}
+ } catch (RuntimeException|Error e) {
+ t = e;
+ throw e;
+ } finally {
+ thread = null;
if (!threadDone) {
- processChildren(ContainerBase.this);
+ log.error(unexpectedDeathMessage, t);
}
}
}
Index: java/org/apache/catalina/core/LocalStrings.properties
===================================================================
--- java/org/apache/catalina/core/LocalStrings.properties (revision 1611495)
+++ java/org/apache/catalina/core/LocalStrings.properties (working copy)
@@ -81,6 +81,7 @@
containerBase.backgroundProcess.cluster=Exception processing cluster {0} background process
containerBase.backgroundProcess.realm=Exception processing realm {0} background process
containerBase.backgroundProcess.valve=Exception processing valve {0} background process
+containerBase.backgroundProcess.unexpectedThreadDeath=Unexpected death of background thread {0}
defaultInstanceManager.invalidInjection=Invalid method resource injection annotation
filterChain.filter=Filter execution threw an exception
filterChain.servlet=Servlet execution threw an exception
Index: webapps/docs/changelog.xml
===================================================================
--- webapps/docs/changelog.xml (revision 1611495)
+++ webapps/docs/changelog.xml (working copy)
@@ -64,6 +64,10 @@
MapperListener
during repeated starts of embedded Tomcat.
(kkolinko)
+
+ 56724: Write an error message to Tomcat logs if container
+ background thread is aborted unexpectedly. (kkolinko)
+