axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject cvs commit: xml-axis/java/src/org/apache/axis/description ServiceDesc.java
Date Fri, 20 Sep 2002 14:29:52 GMT
dims        2002/09/20 07:29:52

  Modified:    java/src/org/apache/axis/utils/bytecode
                        ParamNameExtractor.java
               java/src/org/apache/axis/description ServiceDesc.java
  Log:
  Fix for Bug 12853 - ArrayIndexOutOfBoundsException caused by utils.bytecode
  
  Notes:
  - Remove the cache from ParamNameExtractor as it is NEVER cleaned up.
  - ParamNameExtractor is now stateless, so there should not be problems caused by multiple
threads...
  - Add a cache to ServiceDesc itself
  - Add a synchronized block around this cache.
  - Since the cache is in ServiceDesc, it should theoretically get cleaned up when this ServiceDesc
goes out of scope...
  
  Revision  Changes    Path
  1.5       +11 -30    xml-axis/java/src/org/apache/axis/utils/bytecode/ParamNameExtractor.java
  
  Index: ParamNameExtractor.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/bytecode/ParamNameExtractor.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ParamNameExtractor.java	18 Sep 2002 16:10:43 -0000	1.4
  +++ ParamNameExtractor.java	20 Sep 2002 14:29:52 -0000	1.5
  @@ -75,14 +75,6 @@
               LogFactory.getLog(ParamNameExtractor.class.getName());
   
       /**
  -     * Cache of ParamReader objects which correspond to particular
  -     * Java classes.
  -     *
  -     * !!! NOTE : AT PRESENT WE DO NOT CLEAN UP THIS CACHE.
  -     */
  -    private static Hashtable paramCache = new Hashtable();
  -
  -    /**
        * Retrieve a list of function parameter names from a method
        * Returns null if unable to read parameter names (i.e. bytecode not
        * built with debug).
  @@ -95,27 +87,16 @@
   
           // get declaring class
           Class c = method.getDeclaringClass();
  -        
  -        // Try to obtain a ParamReader class object from cache
  -        ParamReader pr = (ParamReader) paramCache.get(c);
  -
  -        if (pr == null) {
  -            try {
  -                // get a parameter reader
  -                pr = new ParamReader(c);
  -                // cache it
  -                paramCache.put(c, pr);
  -            } catch (IOException e) {
  -                // log it and leave
  -                log.info(Messages.getMessage("error00") + ":" + e);
  -                return null;
  -            }
  +        try {
  +            // get a parameter reader
  +            ParamReader pr = new ParamReader(c);
  +            // get the paramter names
  +            String[] names = pr.getParameterNames(method);
  +            return names;
  +        } catch (IOException e) {
  +            // log it and leave
  +            log.info(Messages.getMessage("error00") + ":" + e);
  +            return null;
           }
  -
  -        // get the paramter names
  -        String[] names = pr.getParameterNames(method);
  -
  -        return names;
       }
  -}
  -
  +}
  \ No newline at end of file
  
  
  
  1.57      +13 -2     xml-axis/java/src/org/apache/axis/description/ServiceDesc.java
  
  Index: ServiceDesc.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/description/ServiceDesc.java,v
  retrieving revision 1.56
  retrieving revision 1.57
  diff -u -r1.56 -r1.57
  --- ServiceDesc.java	20 Sep 2002 14:06:52 -0000	1.56
  +++ ServiceDesc.java	20 Sep 2002 14:29:52 -0000	1.57
  @@ -154,6 +154,7 @@
       private HashMap name2OperationsMap = null;
       private HashMap qname2OperationsMap = null;
       private HashMap method2OperationMap = new HashMap();
  +    private HashMap method2ParamsMap = new HashMap();
   
       /** Method names for which we have completed any introspection necessary */
       private ArrayList completedNames = new ArrayList();
  @@ -959,8 +960,7 @@
           operation.setReturnClass(retClass);
           operation.setReturnType(tm.getTypeQName(method.getReturnType()));
   
  -        String [] paramNames =
  -                ParamNameExtractor.getParameterNamesFromDebugInfo(method);
  +        String [] paramNames = getParamNames(method);
   
           for (int k = 0; k < paramTypes.length; k++) {
               Class type = paramTypes[k];
  @@ -1058,6 +1058,17 @@
   
           addOperationDesc(operation);
           method2OperationMap.put(method, operation);
  +    }
  +
  +    private String[] getParamNames(Method method) {
  +        synchronized (method2ParamsMap) {
  +            String [] paramNames = (String []) method2ParamsMap.get(method);
  +            if(paramNames != null)
  +                return paramNames;
  +            paramNames = ParamNameExtractor.getParameterNamesFromDebugInfo(method);
  +            method2ParamsMap.put(method, paramNames);
  +            return paramNames;
  +        }
       }
   
       public void setNamespaceMappings(List namespaces) {
  
  
  

Mime
View raw message