[jira] [Commented] (BATIK-1228) NPE in SVGGen not working due to non-registered image writers
"Erich Schubert (JIRA)" <[email protected]> Tue, 14 Aug 2018 12:35:00 +0000 (UTC)
| Newsgroups | gmane.text.xml.batik.devel |
|---|---|
| Message-ID | <[email protected]> |
[ https://issues.apache.org/jira/browse/BATIK-1228?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16579740#comment-16579740 ]
Erich Schubert commented on BATIK-1228:
---------------------------------------
If batik-codecs is missing, then a dependency should be added to the application that uses this functionality!
Not everybody needs codecs (for example, you may want to only output SVG files, not PNGs) - so it is appropriate to have them optional; if you use the codecs you should have a dependency on the codecs.
But this could also be caused by the registry cache refresh bug BATIK-1203 that has a fix, but is not being merged...
If writers are added in non-increasing order, they may not be found; because the code only resets the cache to null if it appended the new entry to the end of the list. So if jar A is loaded first, and has a high priority entry, the cache is initialized inbetween, and then jar B adds another entry with lower priority, that entry will not be returned.
> NPE in SVGGen not working due to non-registered image writers
> -------------------------------------------------------------
>
> Key: BATIK-1228
> URL: https://issues.apache.org/jira/browse/BATIK-1228
> Project: Batik
> Issue Type: Bug
> Components: SVGGraphics2D, Utilities
> Affects Versions: 1.9
> Environment: Eclipse
> Reporter: Ansgar Radermacher
> Priority: Critical
>
> There is an NPE in class ImageHandlerBase64Encoder (in batik-svggen) in the 1.9.1 build for Eclipse photon in the following code (which gets triggered by a "File->Save as Image" in Papyrus).
> ImageWriter writer = ImageWriterRegistry.getInstance().getWriterFor("image/png");
> writer.writeImage(buf, os);
> ...
> No ImageWriter is registered for "image/png", i.e writer is null after the assignment. The ImageIOPNGImageWriter (and others) from the batik codec package are not "visible" for the class Service in utils which it used by the ImageWriterRegistry to detect available writers.
> This is due to a missing dependency from batik-util to batik-codec, as proposed in [https://bz.apache.org/bugzilla/show_bug.cgi?id=44682] and [https://stackoverflow.com/questions/16138850/batik-svggraphics2d-nullpointerexception-when-drawing-image]. However, this solution is not possible (at least not on Eclipse level), since batik.codec also depends on batik.util, i.e. would introduce a dependency cycle.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)