Explicitly pass `ClassLoader` of `XmlFactory` when creating Stax input/output factory, instead of context `ClassLoader`
See original GitHub issue(for background see PR #480)
When creating XMLInputFactory
/ XMLOutputFactory
instances – in cases where user does not provide explicit instances – current code uses no-argument static factory methods, which ultimately end up using context ClassLoader to locate implementation via SPI. This can lead to sub-optimal selection process, and it seems better to instead explicit pass the ClassLoader to use, and specifically pass (by default) ClassLoader
that was used to load XML module class XmlFactory
.
Before making the change it would be great to have some supporting documentation/articles explaining common reason for doing this, and/or something explaining potential trade-offs.
Another thing to consider would be whether to allow configuring this aspect (maybe simple on/off to toggle between) or not: since user may simply opt to instantiate and pass factories on its own, configurability may not make much sense (if caller has to do something they might as well just pass instances to avoid all fragility of SPI approach).
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:6 (4 by maintainers)
Top GitHub Comments
Implemented – hope I didn’t botch anything; bit tricky to test (as unit tests explicitly define xml input/output factory).
Ok I’ll add in my todo list & try to get it done for 2.13.0-rc1!