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/configuration FileProvider.java
Date Wed, 24 Jul 2002 16:59:14 GMT
dims        2002/07/24 09:59:14

  Modified:    java/src/org/apache/axis/components/bytecode BCEL.java
               java/src/org/apache/axis/utils ClassUtils.java
               java/src/org/apache/axis/configuration FileProvider.java
  Log:
  Fix for 10916 -  AXIS config crashes w/ NullPointerException when classloader = null
  
  Revision  Changes    Path
  1.3       +2 -2      xml-axis/java/src/org/apache/axis/components/bytecode/BCEL.java
  
  Index: BCEL.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/components/bytecode/BCEL.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- BCEL.java	19 Jul 2002 21:15:11 -0000	1.2
  +++ BCEL.java	24 Jul 2002 16:59:14 -0000	1.3
  @@ -61,6 +61,7 @@
   import org.apache.bcel.classfile.LocalVariable;
   import org.apache.bcel.classfile.LocalVariableTable;
   import org.apache.bcel.classfile.Method;
  +import org.apache.axis.utils.ClassUtils;
   
   import java.io.IOException;
   import java.io.InputStream;
  @@ -105,8 +106,7 @@
               try {
                   String className = c.getName();
                   String classFile = className.replace('.', '/');
  -                InputStream is =
  -                        c.getClassLoader().getResourceAsStream(classFile + ".class");
  +                InputStream is = ClassUtils.getResourceAsStream(c, classFile + ".class");
   
                   ClassParser parser = new ClassParser(is, className);
                   bclass = parser.parse();
  
  
  
  1.3       +18 -0     xml-axis/java/src/org/apache/axis/utils/ClassUtils.java
  
  Index: ClassUtils.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/ClassUtils.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ClassUtils.java	27 Jun 2002 17:22:32 -0000	1.2
  +++ ClassUtils.java	24 Jul 2002 16:59:14 -0000	1.3
  @@ -56,6 +56,7 @@
   
   import java.security.AccessController;
   import java.security.PrivilegedAction;
  +import java.io.InputStream;
   
   /**
    * Utility methods for Class Loading.
  @@ -211,5 +212,22 @@
           } else {
               throw new ClassNotFoundException(_className);
           }
  +    }
  +
  +    public static InputStream getResourceAsStream(Class clazz, String resource) {
  +        InputStream myInputStream = null;
  +
  +        if(clazz.getClass().getClassLoader()!=null) {
  +            // Try the class loader that loaded this class.
  +            myInputStream = clazz.getClassLoader().getResourceAsStream(resource);
  +        } else {
  +            // Try the system class loader.
  +            myInputStream = ClassLoader.getSystemClassLoader().getResourceAsStream(resource);
  +        }
  +        if (myInputStream == null) {
  +            // if not found in classpath fall back to default
  +            myInputStream = clazz.getResourceAsStream(resource);
  +        }
  +        return myInputStream;
       }
   }
  
  
  
  1.34      +3 -10     xml-axis/java/src/org/apache/axis/configuration/FileProvider.java
  
  Index: FileProvider.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/configuration/FileProvider.java,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- FileProvider.java	3 Jul 2002 17:50:33 -0000	1.33
  +++ FileProvider.java	24 Jul 2002 16:59:14 -0000	1.34
  @@ -69,6 +69,7 @@
   import org.apache.axis.utils.Admin;
   import org.apache.axis.utils.XMLUtils;
   import org.apache.axis.utils.JavaUtils;
  +import org.apache.axis.utils.ClassUtils;
   import org.apache.axis.InternalException;
   
   import org.apache.axis.components.logger.LogFactory;
  @@ -196,16 +197,8 @@
                   try {
                       myInputStream = new FileInputStream(configFile);
                   } catch (Exception e) {
  -                    if (searchClasspath) {
  -                        // look for custom configuration files outside of engine package
  -                        myInputStream = engine.getClass().getClassLoader().
  -                                getResourceAsStream(filename);
  -                        if (myInputStream == null) { 
  -                            // if not found in classpath fall back to default config file
in engine package
  -                            myInputStream = engine.getClass().
  -                                getResourceAsStream(filename);
  -                        }
  -                    }
  +                    if (searchClasspath)
  +                        myInputStream = ClassUtils.getResourceAsStream(engine.getClass(),
filename);
                   }
               }
   
  
  
  

Mime
View raw message