From: markt Date: Thu, 31 Mar 2011 13:11:26 +0000 (+0000) Subject: Feedback on https://issues.apache.org/bugzilla/show_bug.cgi?id=50991 X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=c2aa2b55462c134820e5cf3778ec268c94b319bf;p=tomcat7.0 Feedback on https://issues.apache.org/bugzilla/show_bug.cgi?id=50991 No point trying to close a non-singleton resource git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1087291 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/org/apache/catalina/deploy/NamingResources.java b/java/org/apache/catalina/deploy/NamingResources.java index bd556f128..84c386c5c 100644 --- a/java/org/apache/catalina/deploy/NamingResources.java +++ b/java/org/apache/catalina/deploy/NamingResources.java @@ -980,18 +980,21 @@ public class NamingResources extends LifecycleMBeanBase implements Serializable return; } for (ContextResource cr: resources.values()) { - String closeMethod = cr.getCloseMethod(); - if (closeMethod != null && closeMethod.length() > 0) { - String name = cr.getName(); - Object resource; - try { - resource = ctxt.lookup(name); - } catch (NamingException e) { - log.warn(sm.getString("namingResources.cleanupNoResource", - cr.getName(), container), e); - continue; + if (cr.getSingleton()) { + String closeMethod = cr.getCloseMethod(); + if (closeMethod != null && closeMethod.length() > 0) { + String name = cr.getName(); + Object resource; + try { + resource = ctxt.lookup(name); + } catch (NamingException e) { + log.warn(sm.getString( + "namingResources.cleanupNoResource", + cr.getName(), container), e); + continue; + } + cleanUp(resource, name, closeMethod); } - cleanUp(resource, name, closeMethod); } } } diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 71dbc5430..65930df45 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -119,7 +119,7 @@ Provide a configuration option that lets the close method to be used for a JNDI Resource to be defined by the user. This change also disables using the close method unless one is explicitly defined for the - resource. (markt) + resource and limits it to singleton resources. (markt) Correctly track changes to context.xml files and trigger redeployment diff --git a/webapps/docs/config/context.xml b/webapps/docs/config/context.xml index e8a52102d..d99858875 100644 --- a/webapps/docs/config/context.xml +++ b/webapps/docs/config/context.xml @@ -1014,10 +1014,12 @@ -

Name of zero-argument method to call on the resource when it is no - longer required to speed up clean-up of resources that would otherwise - happen as part of garbage collection. If not specificed, no default is - defined and no close method will be called.

+

Name of the zero-argument method to call on a singleton resource when + it is no longer required. This is intended to speed up clean-up of + resources that would otherwise happen as part of garbage collection. + This attribute is ignored if the singleton attribute is + false. If not specificed, no default is defined and no close method will + be called.