-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Always use the system default TransformerFactory in FormatXmlHelper
#2918
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Always use the system default TransformerFactory in FormatXmlHelper
#2918
Conversation
|
Looks like the build failed due to a port conflict - it will probably run ok if triggered again. |
|
Ugh, do you mind re-running Spotless and pushing? The rollover to the new year is causing it to fail now. |
Closes wiremock#2911 Closes wiremock#2913 The implementation of `FormatXmlHelper` relies on a non-standard `TransformerFactory` attribute, `indent-number`, which is not supported by all implementations. By using `TransformerFactory.newDefaultInstance` instead of `TransformerFactory.newInstance`, the system default implementation (`com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl` on OpenJDK-derived JDKs) will be used regardless of any other implementations which might be present on the classpath.
f72e498 to
29f4432
Compare
|
Sure, no problem, I just rebased and ran Spotless on top to update the copyright year. |
|
Hmm, it looks like just one of the Spotless jobs in CI is failing for copyright years on files which aren't being changed in this PR. Running Spotless on my end didn't touch these files, but I also use Linux while the failing CI job is using Windows. Should I update those files manually? |
|
We were just discussing this. Look like a bug in the latest Spotless and we were considering disabling it for Windows for now, but if you don't mind making those changes it would definitely help move things forward. |
|
Sounds good, I just added an extra commit on top which should address all the files that were failing in that CI run. |
|
With temurin-21 i am facing this exception when I try to upgrade from |
Always use the system default `TransformerFactory` in `FormatXmlHelper`
Closes #2911
Closes #2913
The implementation of
FormatXmlHelperrelies on a non-standardTransformerFactoryattribute,indent-number, which is not supported by all implementations. By usingTransformerFactory.newDefaultInstanceinstead ofTransformerFactory.newInstance, the system default implementation (com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImplon OpenJDK-derived JDKs) will be used regardless of any other implementations which might be present on the classpath.Unfortunately, I don't see any way to add or update any tests for this change without introducing a dependency on another XML library. To ensure this change has the expected behavior, I used the same reproduction steps as in #2911 (include Saxon-HE in a small test project): the exception thrown when invoking the
WireMockServerconstructor no longer appears when using a version with this change installed to my local Maven repository.Another possible approach would be to try to unify this logic with
wiremock/src/main/java/com/github/tomakehurst/wiremock/common/xml/XmlNode.java
Lines 44 to 57 in 00d0329
TransformerFactory.newDefaultInstancewas introduced in Java 9). Let me know if you'd like me to try to consider that in this PR as well.References
Submitter checklist
#help-contributingor a project-specific channel like#wiremock-java