cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util IntrospectionUtils.java
remm2005/09/08 08:00:57 Modified:catalina/src/share/org/apache/catalina/loader WebappClassLoader.java webapps/docs changelog.xml util/java/org/apache/tomcat/util IntrospectionUtils.java Log: - 36558: Clear introspection utils cache, which could leak a reference to the webapp classloader. Revision ChangesPath 1.50 +4 -1 jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/loader/WebappClassLoader.java Index: WebappClassLoader.java === RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/loader/WebappClassLoader.java,v retrieving revision 1.49 retrieving revision 1.50 diff -u -r1.49 -r1.50 --- WebappClassLoader.java4 May 2005 07:30:24 - 1.49 +++ WebappClassLoader.java8 Sep 2005 15:00:54 - 1.50 @@ -56,6 +56,7 @@ import org.apache.naming.JndiPermission; import org.apache.naming.resources.Resource; import org.apache.naming.resources.ResourceAttributes; +import org.apache.tomcat.util.IntrospectionUtils; import org.apache.tomcat.util.compat.JdkCompat; /** @@ -1514,6 +1515,8 @@ org.apache.commons.logging.LogFactory.release(this); // Clear the classloader reference in the VM's bean introspector java.beans.Introspector.flushCaches(); +// Clear the IntrospectionUtils cache +IntrospectionUtils.clear(); } 1.370 +4 -0 jakarta-tomcat-catalina/webapps/docs/changelog.xml Index: changelog.xml === RCS file: /home/cvs/jakarta-tomcat-catalina/webapps/docs/changelog.xml,v retrieving revision 1.369 retrieving revision 1.370 diff -u -r1.369 -r1.370 --- changelog.xml 8 Sep 2005 10:45:14 - 1.369 +++ changelog.xml 8 Sep 2005 15:00:54 - 1.370 @@ -52,6 +52,10 @@ fix bug36534/bug: fix equals for URLs returned by ServletContext.getResource() (luehe) /fix + fix +bug36558/bug: Clear IntrospectionUtils cache when stopping a webapp, as it +could leak to keeping a reference to the classloader (remm) + /fix /changelog /subsection 1.16 +4 -0 jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/IntrospectionUtils.java Index: IntrospectionUtils.java === RCS file: /home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/IntrospectionUtils.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- IntrospectionUtils.java 26 Jun 2005 21:19:28 - 1.15 +++ IntrospectionUtils.java 8 Sep 2005 15:00:55 - 1.16 @@ -757,6 +757,10 @@ } // other utils +public static void clear() { +objectMethods.clear(); +} + public static String[] findVoidSetters(Class c) { Method m[] = findMethods(c); if (m == null) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util IntrospectionUtils.java
pero2005/06/26 14:19:28 Modified:util/java/org/apache/tomcat/util IntrospectionUtils.java Log: add boolean isporperty support to getProperty Revision ChangesPath 1.15 +4 -0 jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/IntrospectionUtils.java Index: IntrospectionUtils.java === RCS file: /home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/IntrospectionUtils.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- IntrospectionUtils.java 16 Dec 2004 03:51:41 - 1.14 +++ IntrospectionUtils.java 26 Jun 2005 21:19:28 - 1.15 @@ -370,6 +370,7 @@ public static Object getProperty(Object o, String name) { String getter = get + capitalize(name); +String isGetter = is + capitalize(name); try { Method methods[] = findMethods(o.getClass()); @@ -381,6 +382,9 @@ if (getter.equals(methods[i].getName()) paramT.length == 0) { return methods[i].invoke(o, (Object[]) null); } +if (isGetter.equals(methods[i].getName()) paramT.length == 0) { +return methods[i].invoke(o, (Object[]) null); +} if (getProperty.equals(methods[i].getName())) { getPropertyMethod = methods[i]; - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util IntrospectionUtils.java
billbarker2004/12/15 19:51:42 Modified:util/java/org/apache/tomcat/util IntrospectionUtils.java Log: Ignore '$' chars that aren't part of a '${' replacement pattern. Unlike with ant (which of course is what this is based off of), with this patch you no longer have $$ - $. Based on patch by: Richard Clark [EMAIL PROTECTED] Fix for Bug #32719 Revision ChangesPath 1.14 +2 -2 jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/IntrospectionUtils.java Index: IntrospectionUtils.java === RCS file: /home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/IntrospectionUtils.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- IntrospectionUtils.java 4 Oct 2004 09:25:55 - 1.13 +++ IntrospectionUtils.java 16 Dec 2004 03:51:41 - 1.14 @@ -473,8 +473,8 @@ sb.append('$'); prev = pos + 1; } else if (value.charAt(pos + 1) != '{') { -sb.append(value.charAt(pos + 1)); -prev = pos + 2; // XXX +sb.append('$'); +prev = pos + 1; // XXX } else { int endName = value.indexOf('}', pos); if (endName 0) { - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util IntrospectionUtils.java
remm2004/10/04 02:25:55 Modified:catalina/src/share/org/apache/catalina/mbeans ConnectorMBean.java util/java/org/apache/tomcat/util IntrospectionUtils.java Log: - Fix issue with getProperty in IntrospectionUtils (somehow, it took me forever to spot it). Revision ChangesPath 1.10 +1 -6 jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/mbeans/ConnectorMBean.java Index: ConnectorMBean.java === RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/mbeans/ConnectorMBean.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- ConnectorMBean.java 29 Sep 2004 09:55:37 - 1.9 +++ ConnectorMBean.java 4 Oct 2004 09:25:55 - 1.10 @@ -25,7 +25,6 @@ import javax.management.modelmbean.InvalidTargetObjectTypeException; import org.apache.catalina.connector.Connector; -import org.apache.coyote.ProtocolHandler; import org.apache.tomcat.util.IntrospectionUtils; @@ -88,10 +87,6 @@ try { Connector connector = (Connector) getManagedResource(); result = IntrospectionUtils.getProperty(connector, name); -// FIXME: I don't understand why this is needed -if (result == null) { -result = IntrospectionUtils.getProperty(connector.getProtocolHandler(), name); -} } catch (InstanceNotFoundException e) { throw new MBeanException(e); } catch (InvalidTargetObjectTypeException e) { 1.13 +1 -4 jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/IntrospectionUtils.java Index: IntrospectionUtils.java === RCS file: /home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/IntrospectionUtils.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- IntrospectionUtils.java 17 Sep 2004 21:57:55 - 1.12 +++ IntrospectionUtils.java 4 Oct 2004 09:25:55 - 1.13 @@ -385,16 +385,13 @@ if (getProperty.equals(methods[i].getName())) { getPropertyMethod = methods[i]; } -if (getAttribute.equals(methods[i].getName())) { -getPropertyMethod = methods[i]; -} } // Ok, no setXXX found, try a getProperty(name) if (getPropertyMethod != null) { Object params[] = new Object[1]; params[0] = name; -getPropertyMethod.invoke(o, params); +return getPropertyMethod.invoke(o, params); } } catch (IllegalArgumentException ex2) { - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util IntrospectionUtils.java
costin 2002/06/05 17:58:45 Modified:util/java/org/apache/tomcat/util IntrospectionUtils.java Log: Few additions to the introspector to manage gets. Also a bit of cleanup in replaceProperties - explicitely set the Hashtable and the source for dynamic properties. Revision ChangesPath 1.5 +99 -6 jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/IntrospectionUtils.java Index: IntrospectionUtils.java === RCS file: /home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/IntrospectionUtils.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- IntrospectionUtils.java 17 May 2002 02:32:12 - 1.4 +++ IntrospectionUtils.java 6 Jun 2002 00:58:45 - 1.5 @@ -114,6 +114,26 @@ return; } + +/** + * Call void getAttribute( String ) + */ +public static Object getAttribute( Object proxy, String n) + throws Exception +{ + Method executeM=null; + Class c=proxy.getClass(); + Class params[]=new Class[1]; + params[0]= String.class; + executeM=findMethod( c, getAttribute, params ); + if( executeM == null ) { + System.out.println(No getAttribute in + proxy.getClass() ); + return null; + } + return executeM.invoke(proxy, new Object[] { n }); +} + + /** Construct a URLClassLoader. Will compile and work in JDK1.1 too. */ public static ClassLoader getURLClassLoader( URL urls[], @@ -372,6 +392,58 @@ } } +public static Object getProperty( Object o, String name ) { + String getter= get +capitalize(name); + + try { + Method methods[]=findMethods( o.getClass() ); + Method getPropertyMethod=null; + + // First, the ideal case - a getFoo() method + for( int i=0; i methods.length; i++ ) { + Class paramT[]=methods[i].getParameterTypes(); + if( getter.equals( methods[i].getName() ) + paramT.length == 0 ) { + return methods[i].invoke( o, null ); + } + + if( getProperty.equals( methods[i].getName())) { + getPropertyMethod=methods[i]; + } + if( getAttribute.equals( methods[i].getName())) { + getPropertyMethod=methods[i]; + } + } + + // Ok, no setXXX found, try a getProperty(name) + if( getPropertyMethod != null ) { + Object params[]=new Object[1]; + params[0]=name; + getPropertyMethod.invoke( o, params ); + } + + } catch( IllegalArgumentException ex2 ) { +System.err.println(IAE + o + + name ); +ex2.printStackTrace(); + } catch( SecurityException ex1 ) { + if( dbg 0 ) + d(SecurityException for + o.getClass() + + + name + ) ); + if( dbg 1 ) ex1.printStackTrace(); + } catch (IllegalAccessException iae) { + if( dbg 0 ) + d(IllegalAccessException for + + o.getClass() + + name +) ); + if( dbg 1 ) iae.printStackTrace(); + } catch (InvocationTargetException ie) { + if( dbg 0 ) + d(InvocationTargetException for + o.getClass() + + + name +) ); + if( dbg 1 ) ie.printStackTrace(); + } +return null; +} + /** */ public static void setProperty( Object o, String name ) { @@ -396,12 +468,27 @@ } /** Replace ${NAME} with the property value + * @deprecated. Use the explicit method */ public static String replaceProperties(String value, Object getter ) { +if( getter instanceof Hashtable ) +return replaceProperties( value, (Hashtable)getter, null ); + +if( getter instanceof PropertySource ) { +PropertySource src[]=new PropertySource[] {(PropertySource)getter}; +return replaceProperties( value, null, src); +} +return value; +} + +/** Replace ${NAME} with the property value + */ +public static String replaceProperties(String value, +Hashtable staticProp, PropertySource dynamicProp[] ) +{ StringBuffer sb=new StringBuffer(); -int i=0; int prev=0; // assert value!=nil int pos; @@ -425,10 +512,16 @@ } String n=value.substring( pos+2, endName ); String v= null; - if( getter instanceof Hashtable ) { -
cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util IntrospectionUtils.java
billbarker02/05/16 19:32:12 Modified:util/java/org/apache/tomcat/util IntrospectionUtils.java Log: Fix for brain-dead 1.1.x JDK implementations of java.io.File. It seems that at least some version of 1.1.x believe that: new File(/lib/).getParent() == /lib By stripping the File.separator off the end, it is possible to guess $TOMCAT_INSTALL from the jar file location. At least Sun's 1.3.1 is still happy with this. If any other JDK doesn't like this, we can try to be smarter. Fix for bug #9165. Reported by: Alberto Squassabia [EMAIL PROTECTED] Revision ChangesPath 1.4 +3 -1 jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/IntrospectionUtils.java Index: IntrospectionUtils.java === RCS file: /home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/IntrospectionUtils.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- IntrospectionUtils.java 10 May 2002 23:32:14 - 1.3 +++ IntrospectionUtils.java 17 May 2002 02:32:12 - 1.4 @@ -187,7 +187,9 @@ try { if( .equals(home) ) { home=new File(./).getCanonicalPath(); -} +} else if( home.endsWith(File.separator) ) { + home = home.substring(0,home.length()-1); + } File f=new File( home ); String parentDir = f.getParent(); if(parentDir == null) -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util IntrospectionUtils.java
costin 02/05/10 16:32:14 Modified:util/java/org/apache/tomcat/util IntrospectionUtils.java Log: Very strange, sometimes it's Boolean. Revision ChangesPath 1.3 +6 -2 jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/IntrospectionUtils.java Index: IntrospectionUtils.java === RCS file: /home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/IntrospectionUtils.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- IntrospectionUtils.java 22 Mar 2002 04:12:01 - 1.2 +++ IntrospectionUtils.java 10 May 2002 23:32:14 - 1.3 @@ -349,6 +349,9 @@ setPropertyMethod.invoke( o, params ); } + } catch( IllegalArgumentException ex2 ) { +System.err.println(IAE + o + + name + + value); +ex2.printStackTrace(); } catch( SecurityException ex1 ) { if( dbg 0 ) d(SecurityException for + o.getClass() + + @@ -623,6 +626,7 @@ getOptions1, new Class[] {} )) { args0=(String[])callMethod0( proxy, getOptions1); } + if( args0==null ) { //args0=findVoidSetters(proxy.getClass()); args0=findBooleanSetters(proxy.getClass()); @@ -706,10 +710,10 @@ for( int i=0; im.length; i++ ) { if( m[i].getName().startsWith(set) m[i].getParameterTypes().length == 1 - boolean.equals( m[i].getParameterTypes()[0].getName()) ) { + boolean.equalsIgnoreCase( m[i].getParameterTypes()[0].getName()) ) { String arg=m[i].getName().substring( 3 ); v.addElement( unCapitalize( arg )); - } + } } String s[]=new String[v.size()]; for( int i=0; is.length; i++ ) { -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util IntrospectionUtils.java
costin 02/01/25 23:29:04 Added: util/java/org/apache/tomcat/util IntrospectionUtils.java Log: Added the introspection util, needed to set the worker. I hope it doesn't affect 4.0.2 release - I can move it to jk.util if needed. Revision ChangesPath 1.1 jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/IntrospectionUtils.java Index: IntrospectionUtils.java === /* * * * The Apache Software License, Version 1.1 * * Copyright (c) 1999 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright *notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright *notice, this list of conditions and the following disclaimer in *the documentation and/or other materials provided with the *distribution. * * 3. The end-user documentation included with the redistribution, if *any, must include the following acknowlegement: * This product includes software developed by the *Apache Software Foundation (http://www.apache.org/). *Alternately, this acknowlegement may appear in the software itself, *if and wherever such third-party acknowlegements normally appear. * * 4. The names The Jakarta Project, Tomcat, and Apache Software *Foundation must not be used to endorse or promote products derived *from this software without prior written permission. For written *permission, please contact [EMAIL PROTECTED] * * 5. Products derived from this software may not be called Apache *nor may Apache appear in their names without prior written *permission of the Apache Group. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * http://www.apache.org/. * * [Additional notices, if required by prior licensing conditions] * */ package org.apache.tomcat.util; import java.lang.reflect.*; import java.net.*; import java.io.*; import java.util.*; // Depends: JDK1.1 /** * Utils for introspection and reflection */ public final class IntrospectionUtils { /** Call execute() - any ant-like task should work */ public static void execute( Object proxy, String method ) throws Exception { Method executeM=null; Class c=proxy.getClass(); Class params[]=new Class[0]; // params[0]=args.getClass(); executeM=findMethod( c, method, params ); if( executeM == null ) { throw new RuntimeException(No execute in + proxy.getClass() ); } executeM.invoke(proxy, null );//new Object[] { args }); } /** * Call void setAttribute( String ,Object ) */ public static void setAttribute( Object proxy, String n, Object v) throws Exception { if( proxy instanceof AttributeHolder ) { ((AttributeHolder)proxy).setAttribute( n, v ); return; } Method executeM=null; Class c=proxy.getClass(); Class params[]=new Class[2]; params[0]= String.class; params[1]= Object.class; executeM=findMethod( c, setAttribute, params ); if( executeM == null ) { System.out.println(No setAttribute in + proxy.getClass() ); return; } if( false ) System.out.println(Setting + n + = + v + in + proxy); executeM.invoke(proxy, new Object[] { n, v }); return; }