You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by br...@apache.org on 2015/11/22 15:17:44 UTC

svn commit: r1715629 - in /commons/proper/jxpath/trunk/src: changes/changes.xml main/java/org/apache/commons/jxpath/JXPathContextFactory.java

Author: britter
Date: Sun Nov 22 14:17:44 2015
New Revision: 1715629

URL: http://svn.apache.org/viewvc?rev=1715629&view=rev
Log:
JXPATH-162: Concurrency problem for JXPathContextFactory.factoryImplName static field. Thanks to Michele Vivoda and Uwe Barthel.

Modified:
    commons/proper/jxpath/trunk/src/changes/changes.xml
    commons/proper/jxpath/trunk/src/main/java/org/apache/commons/jxpath/JXPathContextFactory.java

Modified: commons/proper/jxpath/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/jxpath/trunk/src/changes/changes.xml?rev=1715629&r1=1715628&r2=1715629&view=diff
==============================================================================
--- commons/proper/jxpath/trunk/src/changes/changes.xml (original)
+++ commons/proper/jxpath/trunk/src/changes/changes.xml Sun Nov 22 14:17:44 2015
@@ -47,6 +47,9 @@ The <action> type attribute can be add,u
   <body>
     <!-- The release date is the date RC is cut -->
     <release version="1.4" date="2014-??-??" description="New features and bug fixes.">
+      <action issue="JXPATH-162" dev="britter" type="fix" due-to="Uwe Barthel">
+        Concurrency problem for JXPathContextFactory.factoryImplName static field
+      </action>
       <action issue="JXPATH-141" dev="mbenson" type="fix">
         FunctionLibrary Multithreading issue
       </action>

Modified: commons/proper/jxpath/trunk/src/main/java/org/apache/commons/jxpath/JXPathContextFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/jxpath/trunk/src/main/java/org/apache/commons/jxpath/JXPathContextFactory.java?rev=1715629&r1=1715628&r2=1715629&view=diff
==============================================================================
--- commons/proper/jxpath/trunk/src/main/java/org/apache/commons/jxpath/JXPathContextFactory.java (original)
+++ commons/proper/jxpath/trunk/src/main/java/org/apache/commons/jxpath/JXPathContextFactory.java Sun Nov 22 14:17:44 2015
@@ -23,7 +23,6 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.util.Properties;
-
 import org.apache.commons.jxpath.util.ClassLoaderUtil;
 
 /**
@@ -56,7 +55,7 @@ public abstract class JXPathContextFacto
         method is called the second time ( cache the result of
         finding the default impl )
     */
-    private static String factoryImplName = null;
+    private static final String FACTORY_IMPL_NAME = findFactory( FACTORY_NAME_PROPERTY, DEFAULT_FACTORY_CLASS );
 
     /**
      * Create a new JXPathContextFactory.
@@ -102,14 +101,9 @@ public abstract class JXPathContextFacto
      *            is not available or cannot be instantiated.
      */
     public static JXPathContextFactory newInstance() {
-        if (factoryImplName == null) {
-            factoryImplName =
-                findFactory(FACTORY_NAME_PROPERTY, DEFAULT_FACTORY_CLASS);
-        }
-
         JXPathContextFactory factoryImpl;
         try {
-            Class clazz = ClassLoaderUtil.getClass(factoryImplName, true);
+            Class clazz = ClassLoaderUtil.getClass( FACTORY_IMPL_NAME, true );
             factoryImpl = (JXPathContextFactory) clazz.newInstance();
         }
         catch (ClassNotFoundException cnfe) {