Question about JDK-6925410

Frederick Zhang frederick888 at tsundere.moe
Wed Aug 4 02:38:25 UTC 2021


Hello everyone,

I've got a question about JDK-6925410 [1] and I hope this is the right
place to ask.

I'm experiencing some slowness when handling XML request bodies in
Spring. After digging into the code, it led me to [2] where it
instantiates XMLReader upon every request. And the reason of the
slowness here seems to be related to JDK-6925410, since after
pre-assigning a parser via
'-Dorg.xml.sax.driver=com.sun.org.apache.xerces.internal.parsers.SAXParser'
the slowness was gone.

Although I understand creating new XMLReader instances every time is an
anti-pattern, JDK-6925410 mentioned that there was a fix put in place on
jaxp's side so I'm wondering what the fix was?

I tried downloading relevant sources from [3][4][5] for comparison but
some links were broken. Then I checked out the latest JDK code [6] and
it's still doing the class scanning but the method has been marked as
deprecated. May I know if people are simply suggested to migrate to
SAXParserFactory or there's another way of using XMLReaderFactory to
avoid the scanning without pre-assigning any parser?

[1] https://bugs.openjdk.java.net/browse/JDK-6925410
[2] 
https://github.com/spring-projects/spring-framework/blob/8242d02f9d47679610e4c6259dc7b87f195f2eaa/spring-web/src/main/java/org/springframework/http/converter/xml/Jaxb2RootElementHttpMessageConverter.java#L162
[3] https://download.java.net/openjdk/jdk6/promoted/b13/
[4] https://download.java.net/openjdk/jdk7/promoted/b112/
[5] https://download.java.net/openjdk/jdk7/
[6] 
https://github.com/openjdk/jdk/blob/c8add223a10030e40ccef42e081fd0d8f00e0593/src/java.xml/share/classes/org/xml/sax/helpers/XMLReaderFactory.java#L144-L148

-- 
Best regards,
Frederick Zhang

Email: frederick888 at tsundere.moe
PGP:   8BFB EA5B 4C44 BFAC C8EC 5F93 1F92 8BE6 0D8B C11D


More information about the jdk-dev mailing list