cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1081662 - /cxf/trunk/api/src/main/java/org/apache/cxf/wsdl/EndpointReferenceUtils.java
Date Tue, 15 Mar 2011 04:06:54 GMT
Author: dkulp
Date: Tue Mar 15 04:06:54 2011
New Revision: 1081662

URL: http://svn.apache.org/viewvc?rev=1081662&view=rev
Log:
[CXF-3331] Hack around a bug in the xerces schema parser built into the
JDK

Modified:
    cxf/trunk/api/src/main/java/org/apache/cxf/wsdl/EndpointReferenceUtils.java

Modified: cxf/trunk/api/src/main/java/org/apache/cxf/wsdl/EndpointReferenceUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/wsdl/EndpointReferenceUtils.java?rev=1081662&r1=1081661&r2=1081662&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/wsdl/EndpointReferenceUtils.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/wsdl/EndpointReferenceUtils.java Tue Mar 15
04:06:54 2011
@@ -612,7 +612,7 @@ public final class EndpointReferenceUtil
     }
     
     
-    private static Schema createSchema(ServiceInfo serviceInfo, Bus b) {
+    private static synchronized Schema createSchema(ServiceInfo serviceInfo, Bus b) {
         if (b == null) {
             b = BusFactory.getThreadDefaultBus(false);
         }
@@ -625,6 +625,7 @@ public final class EndpointReferenceUtil
             try {
                 for (SchemaInfo si : serviceInfo.getSchemas()) {
                     Element el = si.getElement();
+                    unsetReadonly(el);
                     String baseURI = null;
                     try {
                         baseURI = el.getBaseURI();
@@ -687,12 +688,29 @@ public final class EndpointReferenceUtil
                     String s = XMLUtils.toString(schemaInfo.getElement(), 4);
                     LOG.log(Level.INFO, "Schema for: " + schemaInfo.getNamespaceURI() + "\n"
+ s);
                 }
+            } finally { 
+                for (Source src : schemaSourcesMap2.values()) {
+                    if (src instanceof DOMSource) {
+                        Node nd = ((DOMSource)src).getNode();
+                        unsetReadonly(nd);
+                    }
+                }
             }
             serviceInfo.setProperty(Schema.class.getName(), schema);
         }
         return schema;
     }
     
+    private static void unsetReadonly(Node nd) {
+        try {
+            //work around a bug in the version of Xerces that is in the JDK
+            //that only allows the Element to be used to create a schema once.
+            nd.getClass().getMethod("setReadOnly", Boolean.TYPE, Boolean.TYPE).invoke(nd,
false, true);
+        } catch (Throwable ex) {
+            //ignore
+        }
+    }
+
     public static Schema getSchema(ServiceInfo serviceInfo) {
         return getSchema(serviceInfo, null);
     }



Mime
View raw message