Repository navigation
Description
In DOMDifferenceEngine, we have:
private DocumentBuilderFactory documentBuilderFactory =
DocumentBuilderFactoryConfigurer.Default.configure(DocumentBuilderFactory.newInstance());
While if I provide my own DBF to DiffBuilder, above creation will be useless anyway due to override.
Since DOMDifferenceEngine is only used by DiffBuilder, I think it could be package private, and a constructor with DBF could be provided. (let DiffBuilder inject a DBF to it, either new or provided by caller).
Pretty much like the way to handle WhitespaceNormalizedSource.
I raise this issue because I observed some of my threads during LnP are running at below stack:
lang.Thread.State: RUNNABLE
at java.net.URLStreamHandler.parseURL(URLStreamHandler.java:255)
at java.net.URL.(URL.java:640)
at java.net.URL.(URL.java:508)
at sun.misc.URLClassPath$Loader.findResource(URLClassPath.java:701)
at sun.misc.URLClassPath.findResource(URLClassPath.java:225)
at java.net.URLClassLoader$2.run(URLClassLoader.java:572)
at java.net.URLClassLoader$2.run(URLClassLoader.java:570)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findResource(URLClassLoader.java:569)
at org.springframework.boot.loader.LaunchedURLClassLoader.findResource(LaunchedURLClassLoader.java:53)
at java.lang.ClassLoader.getResource(ClassLoader.java:1090)
at java.net.URLClassLoader.getResourceAsStream(URLClassLoader.java:233)
at org.apache.xerces.parsers.SecuritySupport$6.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.xerces.parsers.SecuritySupport.getResourceAsStream(Unknown Source)
at org.apache.xerces.parsers.ObjectFactory.findJarServiceProvider(Unknown Source)
at org.apache.xerces.parsers.ObjectFactory.createObject(Unknown Source)
at org.apache.xerces.parsers.ObjectFactory.createObject(Unknown Source)
at org.apache.xerces.parsers.DOMParser.(Unknown Source)
at org.apache.xerces.parsers.DOMParser.(Unknown Source)
at org.apache.xerces.jaxp.DocumentBuilderImpl.(Unknown Source)
at org.apache.xerces.jaxp.DocumentBuilderImpl.(Unknown Source)
at org.apache.xerces.jaxp.DocumentBuilderFactoryImpl.setFeature(Unknown Source)
Which indicate DBF's creation is a heavy operation.
(I already have my own thread-local bases DBF passed into DiffBuilder)
Thanks in advance for looking into it.
Leon
Activity
bodewig commentedon May 11, 2020
DOMDifferenceEngineandDiffBuilderlive in separate packages, so package private is not an option. To me the builder API has always been an alternative API to creatingDOMDifferenceEnginedirectly so it has to stay public anyway.Back when I added
setDocumentFactoryI should have chosen a new constructor instead, I don't recall why I opted for the setter.bodewig commentedon May 11, 2020
I've changed the code to use a separate constructor now.
tutufool commentedon May 12, 2020
Cool, thanks for the super fast fix
bodewig commentedon May 12, 2020
2.7.0 has just been released