You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by mr...@apache.org on 2010/03/17 12:58:49 UTC

svn commit: r924246 - in /xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/dom: AttrImpl.java AttrNSImpl.java ElementNSImpl.java

Author: mrglavas
Date: Wed Mar 17 11:58:49 2010
New Revision: 924246

URL: http://svn.apache.org/viewvc?rev=924246&view=rev
Log:
Fixing JIRA Issue #1248: https://issues.apache.org/jira/browse/XERCESJ-1248. Eliminating a static field which was holding on to a text node for mutation notifications. This was not thread-safe and could lead to a memory leak. Fixed thanks to the patch by Ludger Bünger (which I modified slightly; setting the value field on TextImpl directly instead of calling setNodeValueInternal()).

Modified:
    xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/dom/AttrImpl.java
    xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/dom/AttrNSImpl.java
    xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/dom/ElementNSImpl.java

Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/dom/AttrImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/dom/AttrImpl.java?rev=924246&r1=924245&r2=924246&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/dom/AttrImpl.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/dom/AttrImpl.java Wed Mar 17 11:58:49 2010
@@ -138,8 +138,6 @@ public class AttrImpl
     // REVISIT: we are losing the type information in DOM during serialization
     transient Object type;
 
-    protected static TextImpl textNode = null;
-
     //
     // Constructors
     //
@@ -347,6 +345,8 @@ public class AttrImpl
         
         Element ownerElement = getOwnerElement();
         String oldvalue = "";
+        TextImpl textNode = null;
+        
         if (needsSyncData()) {
             synchronizeData();
         }
@@ -361,13 +361,7 @@ public class AttrImpl
                     oldvalue = (String) value;
                     // create an actual text node as our child so
                     // that we can use it in the event
-                    if (textNode == null) {
-                        textNode = (TextImpl)
-                            ownerDocument.createTextNode((String) value);
-                    }
-                    else {
-                        textNode.data = (String) value;
-                    }
+                    textNode = (TextImpl) ownerDocument.createTextNode((String) value);
                     value = textNode;
                     textNode.isFirstChild(true);
                     textNode.previousSibling = textNode;
@@ -412,9 +406,16 @@ public class AttrImpl
         // since we need to combine the remove and insert.
     	isSpecified(true);
         if (ownerDocument.getMutationEvents()) {
-            // if there are any event handlers create a real node
-            internalInsertBefore(ownerDocument.createTextNode(newvalue),
-                                 null, true);
+            // if there are any event handlers create a real node or
+            // reuse the one we synthesized for the remove notifications
+            // if it exists.
+            if (textNode == null) {
+                textNode = (TextImpl) ownerDocument.createTextNode(newvalue);
+            } 
+            else {
+                textNode.data = newvalue;
+            }
+            internalInsertBefore(textNode, null, true);
             hasStringValue(false);
             // notify document
             ownerDocument.modifiedAttrValue(this, oldvalue);

Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/dom/AttrNSImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/dom/AttrNSImpl.java?rev=924246&r1=924245&r2=924246&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/dom/AttrNSImpl.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/dom/AttrNSImpl.java Wed Mar 17 11:58:49 2010
@@ -143,30 +143,6 @@ public class AttrNSImpl
         setName(namespaceURI, qualifiedName);
     }
 
-    /**
-     * NON-DOM: resets this node and sets specified values for the node
-     * 
-     * @param ownerDocument
-     * @param namespaceURI
-     * @param qualifiedName
-     * @param localName
-     */
-    public void setValues (CoreDocumentImpl ownerDocument, 
-                         String namespaceURI, 
-                         String qualifiedName,
-                         String localName){
-
-        AttrImpl.textNode = null;
-        super.flags = 0;
-        isSpecified(true);
-        hasStringValue(true);
-        super.setOwnerDocument(ownerDocument);
-        this.localName = localName;
-        this.namespaceURI = namespaceURI;
-        super.name = qualifiedName;
-        super.value = null;
-    }
-
     //
     // DOM2: Namespace methods
     //

Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/dom/ElementNSImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/dom/ElementNSImpl.java?rev=924246&r1=924245&r2=924246&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/dom/ElementNSImpl.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/dom/ElementNSImpl.java Wed Mar 17 11:58:49 2010
@@ -185,37 +185,6 @@ public class ElementNSImpl
         reconcileDefaultAttributes();
     }
 
-    /**
-     * NON-DOM: resets this node and sets specified values for the node
-     *
-     * @param ownerDocument
-     * @param namespaceURI
-     * @param qualifiedName
-     * @param localName
-     */
-    protected void setValues (CoreDocumentImpl ownerDocument,
-                            String namespaceURI, String qualifiedName,
-                            String localName){
-
-        // remove children first
-        firstChild = null;
-        previousSibling = null;
-        nextSibling = null;
-        fNodeListCache = null;
-
-        // set owner document
-        attributes = null;
-        super.flags = 0;
-        setOwnerDocument(ownerDocument);
-
-        // synchronizeData will initialize attributes
-        needsSyncData(true);
-        super.name = qualifiedName;
-        this.localName = localName;
-        this.namespaceURI = namespaceURI;
-
-    }
-
     //
     // Node methods
     //



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org