-
-
Notifications
You must be signed in to change notification settings - Fork 229
Use of ClassLoader
-taking newFactory()
variant breaks applications using default JDK XML implementation
#550
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
Comments
Ok just to make sure I understand: what is the effect of missing fall-back for 2-argument case? Exception for missing implementation? Or something else? I am also curious as to why someone would want to use JDK Stax implementation (it being inferior to Woodstox and Aalto in about every way), but that's more for my curiosity: it should be possible from impl perspective. |
Exception for missing implementation. |
Ok, so. First of all, I don't like the idea of reverting the change since there was an issue it was meant to resolve and since the change has been in one full minor version (2.13). One thing that seems doable is catching of the exception and attempting secondary lookup with no-args method. One immediate challenge here is testing, however; due to the way Stax implementation lookup works, if any implementation is in the classpath it will be found so test would specifically require use of a very bare-bones project. @dfelliott Do you think you could come up with a PR here? I would be open to it being based off of 2.13 branch if it's just simple try-catch-reattempt change. |
ClassLoader
-taking newFactory()
variant breaks applications using default JDK XML implementation
@dfelliott I added try-catch for |
The fix for #483 introduced a regression for applications using only the built-in JDK XML support.
Before this change, the code did this:
After this change, the code does this:
A similar change applies to the
XMLOutputFactory
.Unfortunately if you look at the JDK's implementation of these methods, the one taking zero arguments (old code) will fall back to the built-in implementation whereas the one accepting arguments (new code) does not perform the fallback.
My preference would be to revert this change, not just because it would fix this problem for me but because I believe the original code was actually correct and the new code is not. Why should only XML libraries on whatever ClassLoader is hosting Jackson be considered? Shouldn't the caller be able to control what library is used in the default constructor by controlling the context ClassLoader?
Meanwhile, a caller wishing to use the XML support of a specific ClassLoader, be it Jackson's ClassLoader or another, is already free to make the call to XMLInputFactory and XMLOutputFactory itself, passing in the specific objects to use. Or that caller could instead simply set their ContextClassLoader appropriately and the default constructor would do what they want.
The text was updated successfully, but these errors were encountered: