[ 
https://issues.apache.org/jira/browse/BATIK-1400?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18123655#comment-18123655
 ] 

Markus Karg commented on BATIK-1400:
------------------------------------

Proposed bug fix is found in Github PR 
[BATIK-69|https://github.com/apache/xmlgraphics-batik/pull/69].

> XMLResourceDescriptor.getParserProps() never closes the InputStream loaded 
> from resources
> -----------------------------------------------------------------------------------------
>
>                 Key: BATIK-1400
>                 URL: https://issues.apache.org/jira/browse/BATIK-1400
>             Project: Batik
>          Issue Type: Bug
>            Reporter: Markus Karg
>            Priority: Minor
>
> {{org.apache.batik.util.XMLResourceDescriptor#getParserProps()}} opens an 
> {{InputStream}} via {{getResourceAsStream()}} and passes it to 
> {{Properties.load(is)}} without ever closing it - not even via 
> {_}try-with-resources{_}. Still present on {{{}main{}}}.
> {{{color:#24201d}protected static synchronized Properties getParserProps() {
>     if (parserProps != null)
>         return parserProps;
>     parserProps = new Properties();
>     try {
>         Class cls = XMLResourceDescriptor.class;
>         InputStream *is* = cls.getResourceAsStream(RESOURCES);
>         parserProps.load({*}is{*});{color}}}
> {{{color:#24201d}        // *is* is not closed here
>     } catch (IOException ioe) {
>         throw new MissingResourceException(ioe.getMessage(), RESOURCES, null);
>     }
>     return parserProps;
> }{color}}}
> Observed effect: application servers that monitor streams handed out by their 
> class loaders report the leak. E.g. Payara Server wraps every 
> {{ASURLClassLoader.getResourceAsStream()}} stream in a sentinel and warns 
> (NCLS-COMUTIL-00023) when the stream is GC'd without explicit close:{{{}{}}}
> _Input stream has been finalized or forced closed without being explicitly 
> closed; stream instantiation reported in following stack trace_
>     _at 
> org.apache.batik.util.XMLResourceDescriptor.getParserProps(XMLResourceDescriptor.java:75)_
>     _at 
> org.apache.batik.util.XMLResourceDescriptor.getXMLParserClassName(XMLResourceDescriptor.java:94)_
> {{Suggested fix:}}
> {{{}{}}}{{{}try (InputStream is = 
> XMLResourceDescriptor.class.getResourceAsStream(RESOURCES)) {{}}}
> {{    parserProps.load(is);}}
> {{}}}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

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

Reply via email to