cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1091105 - in /cxf/branches/2.3.x-fixes: ./ common/common/src/main/java/org/apache/cxf/helpers/XPathUtils.java tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java
Date Mon, 11 Apr 2011 15:51:04 GMT
Author: dkulp
Date: Mon Apr 11 15:51:04 2011
New Revision: 1091105

URL: http://svn.apache.org/viewvc?rev=1091105&view=rev
Log:
Merged revisions 1090633 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1090633 | dkulp | 2011-04-09 13:19:56 -0400 (Sat, 09 Apr 2011) | 5 lines
  
  When calling xpath.evaluate, the classloader MUST be the exact
  classloader used to load the xpath expression.   Otherwise,
  strange ClassCastExceptions occur
  Don't hold onto the Factory as it can lock the classloader.  If this
  causes a performance issue, we may need to relook at it.
........

Modified:
    cxf/branches/2.3.x-fixes/   (props changed)
    cxf/branches/2.3.x-fixes/common/common/src/main/java/org/apache/cxf/helpers/XPathUtils.java
    cxf/branches/2.3.x-fixes/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java

Propchange: cxf/branches/2.3.x-fixes/
            ('svn:mergeinfo' removed)

Propchange: cxf/branches/2.3.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.3.x-fixes/common/common/src/main/java/org/apache/cxf/helpers/XPathUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/common/common/src/main/java/org/apache/cxf/helpers/XPathUtils.java?rev=1091105&r1=1091104&r2=1091105&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/common/common/src/main/java/org/apache/cxf/helpers/XPathUtils.java
(original)
+++ cxf/branches/2.3.x-fixes/common/common/src/main/java/org/apache/cxf/helpers/XPathUtils.java
Mon Apr 11 15:51:04 2011
@@ -31,11 +31,10 @@ import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
 public class XPathUtils {
-    private static final XPathFactory FACTORY = XPathFactory.newInstance();
     private XPath xpath;
 
     public XPathUtils() {
-        xpath = FACTORY.newXPath();
+        xpath = XPathFactory.newInstance().newXPath();
     }
 
     public XPathUtils(final Map<String, String> ns) {
@@ -52,10 +51,14 @@ public class XPathUtils {
     }
 
     public Object getValue(String xpathExpression, Node node, QName type) {
+        ClassLoader loader = Thread.currentThread().getContextClassLoader();
         try {
+            Thread.currentThread().setContextClassLoader(xpath.getClass().getClassLoader());
             return xpath.evaluate(xpathExpression, node, type);
         } catch (Exception e) {
             return null;
+        } finally {
+            Thread.currentThread().setContextClassLoader(loader);
         }
     }
     public NodeList getValueList(String xpathExpression, Node node) {
@@ -72,7 +75,4 @@ public class XPathUtils {
         return getValue(xpathExpression, node, type) != null;
     }
 
-    public static XPathFactory getFactory() {
-        return FACTORY;
-    }
 }

Modified: cxf/branches/2.3.x-fixes/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java?rev=1091105&r1=1091104&r2=1091105&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java
(original)
+++ cxf/branches/2.3.x-fixes/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java
Mon Apr 11 15:51:04 2011
@@ -50,6 +50,7 @@ import javax.xml.validation.SchemaFactor
 import javax.xml.xpath.XPath;
 import javax.xml.xpath.XPathConstants;
 import javax.xml.xpath.XPathExpression;
+import javax.xml.xpath.XPathFactory;
 
 
 import org.w3c.dom.Attr;
@@ -100,7 +101,6 @@ import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.helpers.DOMUtils;
 import org.apache.cxf.helpers.FileUtils;
 import org.apache.cxf.helpers.XMLUtils;
-import org.apache.cxf.helpers.XPathUtils;
 import org.apache.cxf.resource.URIResolver;
 import org.apache.cxf.service.model.SchemaInfo;
 import org.apache.cxf.service.model.ServiceInfo;
@@ -474,7 +474,7 @@ public class JAXBDataBinding implements 
                 String s = r.getAttributeValue(null, "schemaLocation");
                 if (StringUtils.isEmpty(s)) {
                     Document d = StaxUtils.read(r);
-                    XPath p = XPathUtils.getFactory().newXPath();
+                    XPath p = XPathFactory.newInstance().newXPath();
                     p.setNamespaceContext(new W3CNamespaceContext(d.getDocumentElement()));
                     XPathExpression xpe = p.compile(d.getDocumentElement().getAttribute("node"));
                     for (XmlSchema schema : schemas.getXmlSchemas()) {



Mime
View raw message