servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1400142 - in /servicemix/smx4/specs/trunk: jaxp-api-1.4/src/main/java/javax/xml/datatype/ jaxp-api-1.4/src/main/java/javax/xml/parsers/ jaxp-api-1.4/src/main/java/javax/xml/transform/ jaxp-api-1.4/src/main/java/org/xml/sax/helpers/ jaxws-a...
Date Fri, 19 Oct 2012 15:57:03 GMT
Author: dkulp
Date: Fri Oct 19 15:57:02 2012
New Revision: 1400142

URL: http://svn.apache.org/viewvc?rev=1400142&view=rev
Log:
[SMX4-1265] Be much more careful about having the class.getClassLoader() calls return null.

Modified:
    servicemix/smx4/specs/trunk/jaxp-api-1.4/src/main/java/javax/xml/datatype/FactoryFinder.java
    servicemix/smx4/specs/trunk/jaxp-api-1.4/src/main/java/javax/xml/parsers/FactoryFinder.java
    servicemix/smx4/specs/trunk/jaxp-api-1.4/src/main/java/javax/xml/transform/FactoryFinder.java
    servicemix/smx4/specs/trunk/jaxp-api-1.4/src/main/java/org/xml/sax/helpers/XMLReaderFactory.java
    servicemix/smx4/specs/trunk/jaxws-api-2.0/src/main/java/javax/xml/ws/spi/FactoryFinder.java
    servicemix/smx4/specs/trunk/jaxws-api-2.1/src/main/java/javax/xml/ws/spi/FactoryFinder.java
    servicemix/smx4/specs/trunk/jaxws-api-2.2/src/main/java/javax/xml/ws/spi/FactoryFinder.java
    servicemix/smx4/specs/trunk/saaj-api-1.3/pom.xml
    servicemix/smx4/specs/trunk/saaj-api-1.3/src/main/java/javax/xml/soap/FactoryFinder.java

Modified: servicemix/smx4/specs/trunk/jaxp-api-1.4/src/main/java/javax/xml/datatype/FactoryFinder.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/specs/trunk/jaxp-api-1.4/src/main/java/javax/xml/datatype/FactoryFinder.java?rev=1400142&r1=1400141&r2=1400142&view=diff
==============================================================================
--- servicemix/smx4/specs/trunk/jaxp-api-1.4/src/main/java/javax/xml/datatype/FactoryFinder.java
(original)
+++ servicemix/smx4/specs/trunk/jaxp-api-1.4/src/main/java/javax/xml/datatype/FactoryFinder.java
Fri Oct 19 15:57:02 2012
@@ -123,10 +123,16 @@ final class FactoryFinder {
             // if we have no Context ClassLoader
             // so use the current ClassLoader
             classLoader = FactoryFinder.class.getClassLoader();
-            if (debug) debugPrintln(
+            if (debug && classLoader != null) debugPrintln(
                 "Using the class loader of FactoryFinder: "
                 + classLoader);                
         }
+        if (classLoader == null) {
+            classLoader = ClassLoader.getSystemClassLoader();
+            if (debug && classLoader != null) { 
+                debugPrintln("Using the system class loader");
+            }
+        }        
                     
         return classLoader;
     }
@@ -188,7 +194,12 @@ final class FactoryFinder {
 
         try {
             // If we are deployed into an OSGi environment, leverage it
-            Class factoryClass = FactoryFinder.class.getClassLoader().loadClass(factoryId);
+            Class factoryClass;
+            if (FactoryFinder.class.getClassLoader() != null) {
+                factoryClass = FactoryFinder.class.getClassLoader().loadClass(factoryId);
+            } else {
+                factoryClass = Class.forName(factoryId);
+            }
             Class spiClass = org.apache.servicemix.specs.locator.OsgiLocator.locate(factoryClass,
factoryId);
             if (spiClass != null) {
                 return spiClass.newInstance();
@@ -271,12 +282,18 @@ final class FactoryFinder {
             // If no provider found then try the current ClassLoader
             if (is == null) {
                 cl = FactoryFinder.class.getClassLoader();
+                if (cl == null) {
+                    cl = ClassLoader.getSystemClassLoader();
+                }
                 is = SecuritySupport.getResourceAsStream(cl, serviceId);
             }
         } else {
             // No Context ClassLoader, try the current
             // ClassLoader
             cl = FactoryFinder.class.getClassLoader();
+            if (cl == null) {
+                cl = ClassLoader.getSystemClassLoader();
+            }
             is = SecuritySupport.getResourceAsStream(cl, serviceId);
         }
 

Modified: servicemix/smx4/specs/trunk/jaxp-api-1.4/src/main/java/javax/xml/parsers/FactoryFinder.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/specs/trunk/jaxp-api-1.4/src/main/java/javax/xml/parsers/FactoryFinder.java?rev=1400142&r1=1400141&r2=1400142&view=diff
==============================================================================
--- servicemix/smx4/specs/trunk/jaxp-api-1.4/src/main/java/javax/xml/parsers/FactoryFinder.java
(original)
+++ servicemix/smx4/specs/trunk/jaxp-api-1.4/src/main/java/javax/xml/parsers/FactoryFinder.java
Fri Oct 19 15:57:02 2012
@@ -155,15 +155,24 @@ final class FactoryFinder {
             // if we have no Context ClassLoader
             // so use the current ClassLoader
             classLoader = FactoryFinder.class.getClassLoader();
+            if (classLoader == null) {
+                classLoader = ClassLoader.getSystemClassLoader();
+            }
         }
 
         if (debug) dPrint("find factoryId =" + factoryId);
         
         try {
             // If we are deployed into an OSGi environment, leverage it
-            Class factoryClass = FactoryFinder.class.getClassLoader().loadClass(factoryId);
+            Class factoryClass;
+            if (FactoryFinder.class.getClassLoader() != null) {
+                factoryClass = FactoryFinder.class.getClassLoader().loadClass(factoryId);
+            } else {
+                factoryClass = Class.forName(factoryId);
+            }
             Class spiClass = org.apache.servicemix.specs.locator.OsgiLocator.locate(factoryClass,
factoryId);
             if (spiClass != null) {
+                if (debug) dPrint("found osgi factory = " + spiClass.getName());
                 return spiClass.newInstance();
             }
         } catch (Throwable e) {
@@ -244,12 +253,18 @@ final class FactoryFinder {
             // If no provider found then try the current ClassLoader
             if (is == null) {
                 cl = FactoryFinder.class.getClassLoader();
+                if (cl == null) {
+                    cl = ClassLoader.getSystemClassLoader();
+                }
                 is = SecuritySupport.getResourceAsStream(cl, serviceId);
             }
         } else {
             // No Context ClassLoader, try the current
             // ClassLoader
             cl = FactoryFinder.class.getClassLoader();
+            if (cl == null) {
+                cl = ClassLoader.getSystemClassLoader();
+            }
             is = SecuritySupport.getResourceAsStream(cl, serviceId);
         }
 

Modified: servicemix/smx4/specs/trunk/jaxp-api-1.4/src/main/java/javax/xml/transform/FactoryFinder.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/specs/trunk/jaxp-api-1.4/src/main/java/javax/xml/transform/FactoryFinder.java?rev=1400142&r1=1400141&r2=1400142&view=diff
==============================================================================
--- servicemix/smx4/specs/trunk/jaxp-api-1.4/src/main/java/javax/xml/transform/FactoryFinder.java
(original)
+++ servicemix/smx4/specs/trunk/jaxp-api-1.4/src/main/java/javax/xml/transform/FactoryFinder.java
Fri Oct 19 15:57:02 2012
@@ -155,13 +155,22 @@ final class FactoryFinder {
             // if we have no Context ClassLoader
             // so use the current ClassLoader
             classLoader = FactoryFinder.class.getClassLoader();
+            if (classLoader == null) {
+                classLoader = ClassLoader.getSystemClassLoader();
+            }
+            
         }
 
         if (debug) dPrint("find factoryId =" + factoryId);
         
         try {
             // If we are deployed into an OSGi environment, leverage it
-            Class factoryClass = FactoryFinder.class.getClassLoader().loadClass(factoryId);
+            Class factoryClass;
+            if (FactoryFinder.class.getClassLoader() != null) {
+                factoryClass = FactoryFinder.class.getClassLoader().loadClass(factoryId);
+            } else {
+                factoryClass = Class.forName(factoryId);
+            }
             Class spiClass = org.apache.servicemix.specs.locator.OsgiLocator.locate(factoryClass,
factoryId);
             if (spiClass != null) {
                 return spiClass.newInstance();
@@ -244,12 +253,18 @@ final class FactoryFinder {
             // If no provider found then try the current ClassLoader
             if (is == null) {
                 cl = FactoryFinder.class.getClassLoader();
+                if (cl == null) {
+                    cl = ClassLoader.getSystemClassLoader();
+                }
                 is = SecuritySupport.getResourceAsStream(cl, serviceId);
             }
         } else {
             // No Context ClassLoader, try the current
             // ClassLoader
             cl = FactoryFinder.class.getClassLoader();
+            if (cl == null) {
+                cl = ClassLoader.getSystemClassLoader();
+            }
             is = SecuritySupport.getResourceAsStream(cl, serviceId);
         }
 

Modified: servicemix/smx4/specs/trunk/jaxp-api-1.4/src/main/java/org/xml/sax/helpers/XMLReaderFactory.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/specs/trunk/jaxp-api-1.4/src/main/java/org/xml/sax/helpers/XMLReaderFactory.java?rev=1400142&r1=1400141&r2=1400142&view=diff
==============================================================================
--- servicemix/smx4/specs/trunk/jaxp-api-1.4/src/main/java/org/xml/sax/helpers/XMLReaderFactory.java
(original)
+++ servicemix/smx4/specs/trunk/jaxp-api-1.4/src/main/java/org/xml/sax/helpers/XMLReaderFactory.java
Fri Oct 19 15:57:02 2012
@@ -141,12 +141,18 @@ final public class XMLReaderFactory
                 // If no provider found then try the current ClassLoader
                 if (is == null) {
                     cl = XMLReaderFactory.class.getClassLoader();
+                    if (cl == null) {
+                        cl = ClassLoader.getSystemClassLoader();
+                    }
                     is = SecuritySupport.getResourceAsStream(cl, service);
                 }
             } else {
                 // No Context ClassLoader or JDK 1.1 so try the current
                 // ClassLoader
                 cl = XMLReaderFactory.class.getClassLoader();
+                if (cl == null) {
+                    cl = ClassLoader.getSystemClassLoader();
+                }
                 is = SecuritySupport.getResourceAsStream(cl, service);
             }
             

Modified: servicemix/smx4/specs/trunk/jaxws-api-2.0/src/main/java/javax/xml/ws/spi/FactoryFinder.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/specs/trunk/jaxws-api-2.0/src/main/java/javax/xml/ws/spi/FactoryFinder.java?rev=1400142&r1=1400141&r2=1400142&view=diff
==============================================================================
--- servicemix/smx4/specs/trunk/jaxws-api-2.0/src/main/java/javax/xml/ws/spi/FactoryFinder.java
(original)
+++ servicemix/smx4/specs/trunk/jaxws-api-2.0/src/main/java/javax/xml/ws/spi/FactoryFinder.java
Fri Oct 19 15:57:02 2012
@@ -76,6 +76,9 @@ class FactoryFinder {
                     } catch (NoSuchMethodException e) {
                         // Assume that we are running JDK 1.1, use the current ClassLoader
                         debugPrintln("assuming JDK 1.1");
+                        if (FactoryFinder.class.getClassLoader() == null) {
+                            return ClassLoader.getSystemClassLoader();
+                        }
                         return FactoryFinder.class.getClassLoader();
                     }
 
@@ -171,7 +174,12 @@ class FactoryFinder {
                     
 			        try {
 			            // If we are deployed into an OSGi environment, leverage it
-                        Class factoryClass = FactoryFinder.class.getClassLoader().loadClass(iFactoryId);
+                        Class factoryClass;
+                        if (FactoryFinder.class.getClassLoader() == null) {
+                            factoryClass = Class.forName(iFactoryId);
+                        } else {
+                            factoryClass = FactoryFinder.class.getClassLoader().loadClass(iFactoryId);
+                        }
                         Class spiClass = org.apache.servicemix.specs.locator.OsgiLocator.locate(factoryClass,
iFactoryId);
 			            if (spiClass != null) {
 			                return spiClass.newInstance();

Modified: servicemix/smx4/specs/trunk/jaxws-api-2.1/src/main/java/javax/xml/ws/spi/FactoryFinder.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/specs/trunk/jaxws-api-2.1/src/main/java/javax/xml/ws/spi/FactoryFinder.java?rev=1400142&r1=1400141&r2=1400142&view=diff
==============================================================================
--- servicemix/smx4/specs/trunk/jaxws-api-2.1/src/main/java/javax/xml/ws/spi/FactoryFinder.java
(original)
+++ servicemix/smx4/specs/trunk/jaxws-api-2.1/src/main/java/javax/xml/ws/spi/FactoryFinder.java
Fri Oct 19 15:57:02 2012
@@ -76,6 +76,9 @@ class FactoryFinder {
                     } catch (NoSuchMethodException e) {
                         // Assume that we are running JDK 1.1, use the current ClassLoader
                         debugPrintln("assuming JDK 1.1");
+                        if (FactoryFinder.class.getClassLoader() == null) {
+                            return ClassLoader.getSystemClassLoader();
+                        }
                         return FactoryFinder.class.getClassLoader();
                     }
 
@@ -171,7 +174,12 @@ class FactoryFinder {
                     
 			        try {
 			            // If we are deployed into an OSGi environment, leverage it
-                        Class factoryClass = FactoryFinder.class.getClassLoader().loadClass(iFactoryId);
+                        Class factoryClass;
+                        if (FactoryFinder.class.getClassLoader() == null) {
+                            factoryClass = Class.forName(iFactoryId);
+                        } else {
+                            factoryClass = FactoryFinder.class.getClassLoader().loadClass(iFactoryId);
+                        }
                         Class spiClass = org.apache.servicemix.specs.locator.OsgiLocator.locate(factoryClass,
iFactoryId);
 			            if (spiClass != null) {
 			                return spiClass.newInstance();

Modified: servicemix/smx4/specs/trunk/jaxws-api-2.2/src/main/java/javax/xml/ws/spi/FactoryFinder.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/specs/trunk/jaxws-api-2.2/src/main/java/javax/xml/ws/spi/FactoryFinder.java?rev=1400142&r1=1400141&r2=1400142&view=diff
==============================================================================
--- servicemix/smx4/specs/trunk/jaxws-api-2.2/src/main/java/javax/xml/ws/spi/FactoryFinder.java
(original)
+++ servicemix/smx4/specs/trunk/jaxws-api-2.2/src/main/java/javax/xml/ws/spi/FactoryFinder.java
Fri Oct 19 15:57:02 2012
@@ -78,6 +78,9 @@ class FactoryFinder {
                     } catch (NoSuchMethodException e) {
                         // Assume that we are running JDK 1.1, use the current ClassLoader
                         debugPrintln("assuming JDK 1.1");
+                        if (FactoryFinder.class.getClassLoader() == null) {
+                            return ClassLoader.getSystemClassLoader();
+                        }
                         return FactoryFinder.class.getClassLoader();
                     }
 

Modified: servicemix/smx4/specs/trunk/saaj-api-1.3/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/specs/trunk/saaj-api-1.3/pom.xml?rev=1400142&r1=1400141&r2=1400142&view=diff
==============================================================================
--- servicemix/smx4/specs/trunk/saaj-api-1.3/pom.xml (original)
+++ servicemix/smx4/specs/trunk/saaj-api-1.3/pom.xml Fri Oct 19 15:57:02 2012
@@ -24,13 +24,13 @@
     <parent>
         <groupId>org.apache.servicemix.specs</groupId>
         <artifactId>specs</artifactId>
-        <version>2.2-SNAPSHOT</version>
+        <version>2.1-SNAPSHOT</version>
     </parent>
 
     <groupId>org.apache.servicemix.specs</groupId>
     <artifactId>org.apache.servicemix.specs.saaj-api-1.3</artifactId>
     <packaging>bundle</packaging>
-    <version>2.2-SNAPSHOT</version>
+    <version>2.1-SNAPSHOT</version>
     <name>Apache ServiceMix :: Specs :: SAAJ API 1.3</name>
 
     <dependencies>

Modified: servicemix/smx4/specs/trunk/saaj-api-1.3/src/main/java/javax/xml/soap/FactoryFinder.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/specs/trunk/saaj-api-1.3/src/main/java/javax/xml/soap/FactoryFinder.java?rev=1400142&r1=1400141&r2=1400142&view=diff
==============================================================================
--- servicemix/smx4/specs/trunk/saaj-api-1.3/src/main/java/javax/xml/soap/FactoryFinder.java
(original)
+++ servicemix/smx4/specs/trunk/saaj-api-1.3/src/main/java/javax/xml/soap/FactoryFinder.java
Fri Oct 19 15:57:02 2012
@@ -55,6 +55,9 @@ class FactoryFinder {
             }
             if (factory == null) {
                 classloader = FactoryFinder.class.getClassLoader();
+                if (classloader == null) {
+                    classloader = ClassLoader.getSystemClassLoader();
+                }
                 factory = classloader.loadClass(factoryClassName);
             }
             return factory.newInstance();
@@ -216,7 +219,7 @@ class FactoryFinder {
             inputstream = classloader.getResourceAsStream(factoryResource);
         }
 
-        if (inputstream == null) {
+        if (inputstream == null && FactoryFinder.class.getClassLoader() != null)
{
             inputstream =
                     FactoryFinder.class.getClassLoader().getResourceAsStream(
                             factoryResource);



Mime
View raw message