From 7170723cc32a9af0d6c8a24843f2f9721c879591 Mon Sep 17 00:00:00 2001 From: kkolinko Date: Fri, 25 Jun 2010 14:13:26 +0000 Subject: [PATCH] Additional fix for https://issues.apache.org/bugzilla/show_bug.cgi?id=49030 When initializing/starting/stopping connectors and one of them fails, do not ignore the others. These changes are already included in the BZ 49030 patch that I proposed for TC6. git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@957960 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/catalina/core/LocalStrings.properties | 5 ++- java/org/apache/catalina/core/StandardService.java | 48 +++++++++++++++++----- webapps/docs/changelog.xml | 4 ++ 3 files changed, 45 insertions(+), 12 deletions(-) diff --git a/java/org/apache/catalina/core/LocalStrings.properties b/java/org/apache/catalina/core/LocalStrings.properties index b85aa1fed..f628319b6 100644 --- a/java/org/apache/catalina/core/LocalStrings.properties +++ b/java/org/apache/catalina/core/LocalStrings.properties @@ -189,8 +189,11 @@ standardHost.warRequired=URL to web application archive is required standardHost.warURL=Invalid URL for web application archive: {0} standardServer.onameFail=MBean name specified for Server [{0}] is not valid standardServer.shutdownViaPort=A valid shutdown command was received via the shutdown port. Stopping the Server instance. -standardService.connector.initFailed=Failed to initialise connector [{0}] +standardService.connector.initFailed=Failed to initialize connector [{0}] standardService.connector.destroyFailed=Failed to destroy connector [{0}] +standardService.connector.pauseFailed=Failed to pause connector [{0}] +standardService.connector.startFailed=Failed to start connector [{0}] +standardService.connector.stopFailed=Failed to stop connector [{0}] standardService.initialize.failed=Service initializing at {0} failed standardService.onameFail=MBean name specified for Service [{0}] is not valid standardService.register.failed=Error registering Service at domain {0} diff --git a/java/org/apache/catalina/core/StandardService.java b/java/org/apache/catalina/core/StandardService.java index 56883c217..80d396f7d 100644 --- a/java/org/apache/catalina/core/StandardService.java +++ b/java/org/apache/catalina/core/StandardService.java @@ -230,7 +230,9 @@ public class StandardService extends LifecycleMBeanBase implements Service { try { connector.start(); } catch (LifecycleException e) { - log.error("Connector.start", e); + log.error(sm.getString( + "standardService.connector.startFailed", + connector), e); } } @@ -294,7 +296,9 @@ public class StandardService extends LifecycleMBeanBase implements Service { try { connectors[j].stop(); } catch (LifecycleException e) { - log.error("Connector.stop", e); + log.error(sm.getString( + "standardService.connector.stopFailed", + connectors[j]), e); } } connector.setService(null); @@ -433,7 +437,13 @@ public class StandardService extends LifecycleMBeanBase implements Service { // Start our defined Connectors second synchronized (connectors) { for (int i = 0; i < connectors.length; i++) { - connectors[i].start(); + try { + connectors[i].start(); + } catch (Exception e) { + log.error(sm.getString( + "standardService.connector.startFailed", + connectors[i]), e); + } } } } @@ -453,7 +463,13 @@ public class StandardService extends LifecycleMBeanBase implements Service { // Stop our defined Connectors first synchronized (connectors) { for (int i = 0; i < connectors.length; i++) { - connectors[i].pause(); + try { + connectors[i].pause(); + } catch (Exception e) { + log.error(sm.getString( + "standardService.connector.pauseFailed", + connectors[i]), e); + } } } @@ -478,11 +494,18 @@ public class StandardService extends LifecycleMBeanBase implements Service { // Stop our defined Connectors first synchronized (connectors) { for (int i = 0; i < connectors.length; i++) { - // If Service fails to start, connectors may not have been - // started - if (!LifecycleState.INITIALIZED - .equals(connectors[i].getState())) { + if (LifecycleState.INITIALIZED.equals( + connectors[i].getState())) { + // If Service fails to start, connectors may not have been + // started + continue; + } + try { connectors[i].stop(); + } catch (Exception e) { + log.error(sm.getString( + "standardService.connector.stopFailed", + connectors[i]), e); } } } @@ -522,9 +545,12 @@ public class StandardService extends LifecycleMBeanBase implements Service { try { connector.init(); } catch (Exception e) { - log.error(sm.getString( - "standardService.connector.initFailed", connector), - e); + String message = sm.getString( + "standardService.connector.initFailed", connector); + log.error(message, e); + + if (Boolean.getBoolean("org.apache.catalina.startup.EXIT_ON_INIT_FAILURE")) + throw new LifecycleException(message); } } } diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 07d02f5f2..4a123e5be 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -56,6 +56,10 @@ Add entryPoint support to the CSRF prevention filter. (markt) + 49030: When initializing/starting/stopping connectors and + one of them fails, do not ignore the others. (markt/kkolinko) + + 49230: Enhance JRE leak prevention listener with protection for the keep-alive thread started by sun.net.www.http.HttpClient. Based on a patch provided by -- 2.11.0