JDK-8173390 : Investigate SymbolTable in SAXParser
  • Type: Bug
  • Component: xml
  • Affected Version: 9
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2017-01-26
  • Updated: 2017-04-19
  • Resolved: 2017-02-16
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 10 JDK 9
10Fixed 9 b158Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Description
During removal of SAAJ dependencies to JDK xml internal apis, there were removed a piece of code, resetting SymbolTable in cached SaxParsers. This may cause heap OOM error. Here is original issue, which induced resetting SymbolTables:

https://java.net/jira/browse/SAAJ-46

Resetting SymbolTables was pushed as temporary fix, until this is resolved:

https://java.net/jira/browse/JAXP-59

I have checked a SAAJ code and didn't found any better solution, than to not cache sax parsers at all. But I am not sure what performance impact it may have on saaj/jaxws.

Aleksej can you check if resetting SymbolTable can be done in SaxParser#reset ?
Comments
JDK9 review: http://mail.openjdk.java.net/pipermail/core-libs-dev/2017-February/046445.html
15-02-2017

Needs to be fixed in 9 too
15-02-2017

Raised priority to 2 because this bug is required by JDK-8174735 to avoid uncontrollable grow of symbol table entries associated with SAX parsers in SAAJ SAX parsers pool.
15-02-2017

I can test/backport the whole SAAJ change. Can you, please, provide me diff with the standalone changes?
31-01-2017

I don't expect any test failures with this change in SAAJ units. It would be more interesting to test whole SAAJ change in JDK. I hope to make a presync this or next week.
31-01-2017

[~rgrigoriadi], Do you want me to generate JDK9 build with this patch for you, so you can run standalone tests?
31-01-2017

I tested the following simple patch that reallocates the symbol table during SAXParser reset() call: diff -r 2d7bf6955c05 src/java.xml/share/classes/com/sun/org/apache/xerces/internal/parsers/SAXParser.java --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/parsers/SAXParser.java Tue Jan 24 16:34:23 2017 +0000 +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/parsers/SAXParser.java Tue Jan 31 14:43:52 2017 +0300 @@ -24,6 +24,7 @@ import com.sun.org.apache.xerces.internal.util.SymbolTable; import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager; import com.sun.org.apache.xerces.internal.utils.XMLSecurityPropertyManager; +import com.sun.org.apache.xerces.internal.xni.XNIException; import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarPool; import com.sun.org.apache.xerces.internal.xni.parser.XMLParserConfiguration; import org.xml.sax.SAXNotRecognizedException; @@ -124,6 +125,15 @@ } // <init>(SymbolTable,XMLGrammarPool) + public void reset() throws XNIException { + super.reset(); + SymbolTable symbolTable = (SymbolTable)fConfiguration.getProperty(SYMBOL_TABLE); + if (symbolTable != null) { + symbolTable = new SymbolTable(); + fConfiguration.setProperty(SYMBOL_TABLE, symbolTable); + } + } + /** * Sets the particular property in the underlying implementation of * org.xml.sax.XMLReader. JDK9 build with this patch shows no related JCK failures. Will discuss this approach with [~joehw]
31-01-2017

The SAAJ bug mentions some performance numbers with removed parser pool: https://java.net/jira/browse/SAAJ-46?focusedCommentId=38687&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-38687
26-01-2017