Details
-
Bug
-
Status: Open
-
Resolution: Unresolved
-
1.8
-
None
-
Operating System: All
Platform: All
URL: http://www.nabble.com/NPE-calling-cloneNode-for-SVG-1.2-documents-td22080561.html
Description
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.
Attachments
Attachments
Issue Links
- depends upon
-
BATIK-962 [META] Batik 1.8 release tracking bug
- Resolved