https://issues.apache.org/bugzilla/show_bug.cgi?id=46791

           Summary: [PATCH] NullPointerException calling cloneNode for SVG
                    1.2 documents
           Product: Batik
           Version: 1.8
          Platform: Macintosh
        OS/Version: Mac OS X 10.4
            Status: NEW
          Severity: normal
          Priority: P2
         Component: SVG DOM
        AssignedTo: [email protected]
        ReportedBy: [email protected]


Created an attachment (id=23321)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=23321)
A patch that fixes the described bug.

If you call the Node#cloneNode(boolean) method to perform a deep clone of an
element in an SVG 1.2 document, and that element has got a child element in a
custom namespace, a NullPointerException is thrown:

Exception in thread "main" java.lang.NullPointerException
    at
org.apache.batik.dom.svg.SVGOMElement.createLiveAnimatedString(SVGOMElement.java:390)
    at
org.apache.batik.dom.svg.SVGStylableElement.initializeLiveAttributes(SVGStylableElement.java:118)
    at
org.apache.batik.dom.svg.SVGStylableElement.<init>(SVGStylableElement.java:103)
    at
org.apache.batik.dom.svg.SVGGraphicsElement.<init>(SVGGraphicsElement.java:96)
    at
org.apache.batik.dom.svg12.BindableElement.<init>(BindableElement.java:68)
    at
org.apache.batik.dom.svg12.BindableElement.newNode(BindableElement.java:99)
    at org.apache.batik.dom.AbstractNode.cloneNode(AbstractNode.java:309)
    at
org.apache.batik.dom.AbstractParentNode.deepCopyInto(AbstractParentNode.java:377)
    at
org.apache.batik.dom.AbstractElement.deepCopyInto(AbstractElement.java:563)
    at
org.apache.batik.dom.svg.SVGOMElement.deepCopyInto(SVGOMElement.java:891)
    at org.apache.batik.dom.AbstractNode.cloneNode(AbstractNode.java:309)
    at
org.apache.batik.dom.AbstractParentNode.deepCopyInto(AbstractParentNode.java:377)
    at
org.apache.batik.dom.AbstractElement.deepCopyInto(AbstractElement.java:563)
    at
org.apache.batik.dom.svg.SVGOMElement.deepCopyInto(SVGOMElement.java:891)
    at org.apache.batik.dom.AbstractNode.cloneNode(AbstractNode.java:309)
    at
org.apache.batik.dom.AbstractParentNode.deepCopyInto(AbstractParentNode.java:377)
    at
org.apache.batik.dom.AbstractElement.deepCopyInto(AbstractElement.java:563)
    at
org.apache.batik.dom.svg.SVGOMElement.deepCopyInto(SVGOMElement.java:891)
    at org.apache.batik.dom.AbstractNode.cloneNode(AbstractNode.java:309)
    at CloneNodeTest.main(CloneNodeTest.java:25)

In SVG 1.1 documents, this does not happen.

The problem is that the cloning behaviour of BindableElement is implemented
incorrectly. The newNode() method calls the wrong constructor, so that some
super constructor executes code relying on the owner document of the node
aready being set.

Attached is a patch for this bug. The cloning behaviour is now implemented just
as the one of GenericElementNS, the class used for custom namespace elements in
SVG 1.1. This means that in the newNode() method, we just call the
parameterless constructor. To ensure that the fields of BindableElement are
set, I added implementations for the copyInto, deepCopyInto, export, and
deepExport methods.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to