Author: markt Date: Thu Mar 31 13:11:26 2011 New Revision: 1087291 URL: http://svn.apache.org/viewvc?rev=1087291&view=rev Log: Feedback on https://issues.apache.org/bugzilla/show_bug.cgi?id=50991 No point trying to close a non-singleton resource
Modified: tomcat/trunk/java/org/apache/catalina/deploy/NamingResources.java tomcat/trunk/webapps/docs/changelog.xml tomcat/trunk/webapps/docs/config/context.xml Modified: tomcat/trunk/java/org/apache/catalina/deploy/NamingResources.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/deploy/NamingResources.java?rev=1087291&r1=1087290&r2=1087291&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/deploy/NamingResources.java (original) +++ tomcat/trunk/java/org/apache/catalina/deploy/NamingResources.java Thu Mar 31 13:11:26 2011 @@ -980,18 +980,21 @@ public class NamingResources extends Lif 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); } } } Modified: tomcat/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1087291&r1=1087290&r2=1087291&view=diff ============================================================================== --- tomcat/trunk/webapps/docs/changelog.xml (original) +++ tomcat/trunk/webapps/docs/changelog.xml Thu Mar 31 13:11:26 2011 @@ -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) </add> <fix> Correctly track changes to context.xml files and trigger redeployment Modified: tomcat/trunk/webapps/docs/config/context.xml URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/config/context.xml?rev=1087291&r1=1087290&r2=1087291&view=diff ============================================================================== --- tomcat/trunk/webapps/docs/config/context.xml (original) +++ tomcat/trunk/webapps/docs/config/context.xml Thu Mar 31 13:11:26 2011 @@ -1014,10 +1014,12 @@ </attribute> <attribute name="closeMethod" required="false"> - <p>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.</p> + <p>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 <code>singleton</code> attribute is + false. If not specificed, no default is defined and no close method will + be called.</p> </attribute> <attribute name="description" required="false"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org