xmlgraphics-batik icon indicating copy to clipboard operation
xmlgraphics-batik copied to clipboard

BATIK-1318: NullPointerException in SAXSVGDocumentFactory.resolveEntity()

Open stanio opened this issue 2 years ago • 1 comments

Suggested fix for BATIK-1318.

In 2014 the SAXSVGDocumentFactory class along with the dtdids.properties resource have been moved from org.apache.batik.dom.svg to org.apache.batik.anim.dom package:

  • 412c7bb1ede09d81e9a2125542439a762ba1c501 removed cyclic dependencies reported in BATIK-1098

However, the resources referenced in dtdids.properties are still in org.apache.batik.dom.svg package:

This makes the following Class.getResource() return null and ultimately cause NPE:

https://github.com/apache/xmlgraphics-batik/blob/42f696530256dd1bfeec4870922c208d67c0c128/batik-anim/src/main/java/org/apache/batik/anim/dom/SAXSVGDocumentFactory.java#L386-L392

I can see the overall issue has been partially addressed in f2dac46c5e23f830321829eda248fecafce443f9. I suggest further the dtdids.properties should be updated with absolute resource names.

stanio avatar Oct 12 '23 14:10 stanio

Now that 04b46fd1386bfab2e57bee6a86d229a336a2225a is checked into the main line, one may need to add (haven't tested it explicitly):

--add-opens org.apache.xmlgraphics.batik.svgdom/org.apache.batik.dom.svg.resources=org.apache.xmlgraphics.batik.anim

when using the --module-path vs. --class-path runtime configuration. This could be further addressed by more appropriate packaging. For example, SAXSVGDocumentFactory (and dtdids.properties) should likely reside in the batik-dom module, where the rest of the referenced resources are.

stanio avatar Apr 11 '24 13:04 stanio