You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-cvs@xml.apache.org by mr...@apache.org on 2006/02/23 23:30:32 UTC

svn commit: r380250 - /xml/commons/trunk/java/external/src/javax/xml/namespace/QName.java

Author: mrglavas
Date: Thu Feb 23 14:30:29 2006
New Revision: 380250

URL: http://svn.apache.org/viewcvs?rev=380250&view=rev
Log:
Fixing Bugzilla #37267:
http://issues.apache.org/bugzilla/show_bug.cgi?id=37267

Serialization compatibility of QName was broken in JAXP 1.3 when the serialVersionUID
changed from -9120448754896609940 (which was the original one introduced in JAX-RPC 1.0)
to 4418622981026545151. Restoring the original serialVersionUID and providing a system
property called org.apache.xml.namespace.QName.useCompatibleSerialVersionUID which can
be used to select 4418622981026545151 as the serialVersionUID. This is fixed thanks to
the patch by Nathan Beyer.

Modified:
    xml/commons/trunk/java/external/src/javax/xml/namespace/QName.java

Modified: xml/commons/trunk/java/external/src/javax/xml/namespace/QName.java
URL: http://svn.apache.org/viewcvs/xml/commons/trunk/java/external/src/javax/xml/namespace/QName.java?rev=380250&r1=380249&r2=380250&view=diff
==============================================================================
--- xml/commons/trunk/java/external/src/javax/xml/namespace/QName.java (original)
+++ xml/commons/trunk/java/external/src/javax/xml/namespace/QName.java Thu Feb 23 14:30:29 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 2003-2005 The Apache Software Foundation.
+ * Copyright 2003-2006 The Apache Software Foundation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,6 +21,8 @@
 import java.io.IOException;
 import java.io.ObjectInputStream;
 import java.io.Serializable;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 
 import javax.xml.XMLConstants;
 
@@ -66,8 +68,39 @@
 
     /**
      * <p>Stream Unique Identifier.</p>
+     * 
+     * <p>To enable the compatibility <code>serialVersionUID</code>
+     * set the System Property
+     * <code>org.apache.xml.namespace.QName.useCompatibleSerialVersionUID</code>
+     * to a value of "1.0".</p>
      */
-    private static final long serialVersionUID = 4418622981026545151L;
+    private static final long serialVersionUID;
+    
+    /**
+     * <p>The original default Stream Unique Identifier.</p>
+     */
+    private static final long defaultSerialVersionUID = -9120448754896609940L;
+    
+    /**
+     * <p>The compatibility Stream Unique Identifier that was introduced
+     * with Java 5 SE SDK.</p>
+     */
+    private static final long compatabilitySerialVersionUID = 4418622981026545151L;
+    
+    static {
+        String compatPropValue = null;
+        try {
+            compatPropValue = (String)AccessController.doPrivileged(
+                    new PrivilegedAction() {
+                        public Object run() {
+                            return System.getProperty("org.apache.xml.namespace.QName.useCompatibleSerialVersionUID");
+                        }
+                    });
+        } 
+        catch (Exception e) {}
+        // If 1.0 use compatability serialVersionUID
+        serialVersionUID = !"1.0".equals(compatPropValue) ? defaultSerialVersionUID : compatabilitySerialVersionUID;
+    }
 
     /**
      * <p>Namespace URI of this <code>QName</code>.</p>