Bug 46894 - [PATCH] CSS scanner keeps multiple file handles to UserAgentStyleSheet.css open
Summary: [PATCH] CSS scanner keeps multiple file handles to UserAgentStyleSheet.css open
Status: NEW
Alias: None
Product: Batik - Now in Jira
Classification: Unclassified
Component: CSS (show other bugs)
Version: 1.7
Hardware: All All
: P2 normal
Target Milestone: ---
Assignee: Batik Developer's Mailing list
Keywords: PatchAvailable
Depends on:
Reported: 2009-03-23 09:48 UTC by Martin Kaeser
Modified: 2011-03-02 15:28 UTC (History)
1 user (show)

Diffs for Parser.java and Scanner.java (955 bytes, patch)
2009-03-23 09:48 UTC, Martin Kaeser
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Kaeser 2009-03-23 09:48:56 UTC
Created attachment 23399 [details]
Diffs for Parser.java and Scanner.java

Our software uses the CSS component of Batik. It's executed on a dedicated server system. Several times a big number of file handles (> 100) to the Batik resource file UserAgentStyleSheet.css remained open, that forced us to restart the server. 

We managed to track down the problem in the Batik source code:
In SVGDOMImplementation and SVG12DOMImplementation the above mentioned resource file is parsed, which leads to org.apache.batik.css.parser.Parser.parseStyleSheet(InputSource source). At the beginning of this method a Scanner instance is created but at the end it isn't destroyed (only set to null). The org.apache.batik.css.parser.Scanner holds an instance of org.apache.batik.util.io.NormalizingReader that needs to be closed to free the file handle.
As the scanner and the reader are not destroyed after the end of their usage, the freeing of the file handle relies on the Java garbage collector. Especially on server systems with lots of resources this can take a long time.

To improve the performance in this respect we applied a patch to our version of Batik (based on batik-src-1.7.zip). With this post we send you unifed diff files for Parser.java and Scanner.java. We would really appreciate it if you could include a fix for this matter in the next version of Batik.