From 821ecb18c146387cac80130dbfd92c14486e26b8 Mon Sep 17 00:00:00 2001 From: markt Date: Tue, 11 May 2010 11:06:02 +0000 Subject: [PATCH] No need to remove LifecycleListeners from destroyed components git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@943081 13f79535-47bb-0310-9956-ffa450edef68 --- .../catalina/connector/LocalStrings.properties | 2 +- .../apache/catalina/connector/MapperListener.java | 22 ++++++++-------------- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/java/org/apache/catalina/connector/LocalStrings.properties b/java/org/apache/catalina/connector/LocalStrings.properties index dd9af68a1..5f85ebcd2 100644 --- a/java/org/apache/catalina/connector/LocalStrings.properties +++ b/java/org/apache/catalina/connector/LocalStrings.properties @@ -82,6 +82,6 @@ mapperListener.unregisterContext=Unregister Context {0} mapperListener.registerWrapper=Register Wrapper {0} in Context {1} mapperListener.addMBeanListenerFail=Failed to add MBean notification listener for connector [{0}] in domain [{1}]. Adding Hosts, Contexts and Wrappers will not be visible to the connector. mapperListener.removeMBeanListenerFail=Failed to remove MBean notification listener for connector [{0}] in domain [{1}]. This may result in a memory leak. -mapperLister.lifecycleListenerFail=Failed to call method [{0}] on object [{1}]. Changes in the object state may not be correctly reflected in the mapper for connector [{2}] in domain [{3}]. +mapperLister.lifecycleListenerFail=Failed to add Lifecycle listener to object [{0}]. Changes in the object state may not be correctly reflected in the mapper for connector [{1}] in domain [{2}]. inputBuffer.streamClosed=Stream closed diff --git a/java/org/apache/catalina/connector/MapperListener.java b/java/org/apache/catalina/connector/MapperListener.java index fd21b994a..22ad67b14 100644 --- a/java/org/apache/catalina/connector/MapperListener.java +++ b/java/org/apache/catalina/connector/MapperListener.java @@ -204,14 +204,8 @@ public class MapperListener return; } - String methodName = null; - if (notification.getType().equals + if (!notification.getType().equals (MBeanServerNotification.REGISTRATION_NOTIFICATION)) { - methodName = "addLifecycleListener"; - } else if (notification.getType().equals - (MBeanServerNotification.UNREGISTRATION_NOTIFICATION)) { - methodName = "removeLifecycleListener"; - } else { return; } @@ -230,21 +224,21 @@ public class MapperListener if ("Servlet".equals(type) || "WebModule".equals(type) || "Host".equals(type)) { try { - mBeanServer.invoke(objectName, methodName, + mBeanServer.invoke(objectName, "addLifecycleListener", new Object[] {this}, new String[] {"org.apache.catalina.LifecycleListener"}); } catch (ReflectionException e) { log.error(sm.getString( - "mapperLister.lifecycleListenerFail", methodName, - objectName, connector, domain), e); + "mapperLister.lifecycleListenerFail", objectName, + connector, domain), e); } catch (MBeanException e) { log.error(sm.getString( - "mapperLister.lifecycleListenerFail", methodName, - objectName, connector, domain), e); + "mapperLister.lifecycleListenerFail", objectName, + connector, domain), e); } catch (InstanceNotFoundException e) { log.error(sm.getString( - "mapperLister.lifecycleListenerFail", methodName, - objectName, connector, domain), e); + "mapperLister.lifecycleListenerFail", objectName, + connector, domain), e); } } } -- 2.11.0