You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by ve...@apache.org on 2013/01/05 16:17:25 UTC

svn commit: r1429315 - /webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/dialect/StAXDialectDetector.java

Author: veithen
Date: Sat Jan  5 15:17:25 2013
New Revision: 1429315

URL: http://svn.apache.org/viewvc?rev=1429315&view=rev
Log:
AXIOM-443: Correctly detect dialect of the StAX implementation in IBM Java 1.7.

Modified:
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/dialect/StAXDialectDetector.java

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/dialect/StAXDialectDetector.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/dialect/StAXDialectDetector.java?rev=1429315&r1=1429314&r2=1429315&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/dialect/StAXDialectDetector.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/dialect/StAXDialectDetector.java Sat Jan  5 15:17:25 2013
@@ -274,16 +274,22 @@ public class StAXDialectDetector {
         // Try Sun's implementation found in JREs
         cls = loadClass(classLoader, rootUrl, "com.sun.xml.internal.stream.XMLOutputFactoryImpl");
         if (cls != null) {
-            // Check if the implementation has the bug fixed here:
-            // https://sjsxp.dev.java.net/source/browse/sjsxp/zephyr/src/com/sun/xml/stream/ZephyrWriterFactory.java?rev=1.8&r1=1.4&r2=1.5
-            boolean isUnsafeStreamResult;
-            try {
-                cls.getDeclaredField("fStreamResult");
-                isUnsafeStreamResult = true;
-            } catch (NoSuchFieldException ex) {
-                isUnsafeStreamResult = false;
+            // Some JREs (such as IBM Java 1.7) include com.sun.xml.internal.stream.XMLOutputFactoryImpl
+            // for compatibility (in which case it extends the XMLOutputFactory implementation from
+            // another StAX implementation, e.g. XLXP). Detect this situation by checking the superclass.
+            Class superClass = cls.getSuperclass();
+            if (superClass == XMLOutputFactory.class || superClass.getName().startsWith("com.sun.")) {
+                // Check if the implementation has the bug fixed here:
+                // https://sjsxp.dev.java.net/source/browse/sjsxp/zephyr/src/com/sun/xml/stream/ZephyrWriterFactory.java?rev=1.8&r1=1.4&r2=1.5
+                boolean isUnsafeStreamResult;
+                try {
+                    cls.getDeclaredField("fStreamResult");
+                    isUnsafeStreamResult = true;
+                } catch (NoSuchFieldException ex) {
+                    isUnsafeStreamResult = false;
+                }
+                return new SJSXPDialect(isUnsafeStreamResult);
             }
-            return new SJSXPDialect(isUnsafeStreamResult);
         }
         
         // Try IBM's XL XP-J