question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
cowtowncodercommented, Jul 5, 2021

Implemented – hope I didn’t botch anything; bit tricky to test (as unit tests explicitly define xml input/output factory).

1reaction
cowtowncodercommented, Jul 5, 2021

Ok I’ll add in my todo list & try to get it done for 2.13.0-rc1!

Read more comments on GitHub >

github_iconTop Results From Across the Web

java - ClassNotFoundException with custom xml serializer for ...
If running the javadoc target in our sample project where we have set the xml factory to use the Woodstox serializer the class...
Read more >
Jackson Release 2.13 · FasterXML/jackson Wiki - GitHub
A class of impossible-to-fix problems related to Creator methods (constructors, factory methods) is due to "duality" of Creator discovery and ...
Read more >
XMLOutputFactory (Java SE 15 & JDK 15) - Oracle Help Center
Defines an abstract implementation of a factory for getting XMLEventWriters ... If the context class loader is null, the system class loader will...
Read more >
10.1. Defining classloaders - JBoss.org
During the deployment process, as the controller performs the Instantiate action, the thread context classloader is used to load the bean's class into...
Read more >
Can't use StAX from inside a plugins 2 plugin without ...
jar (Woodstox) in WEB-INF/lib. This JAR registers itself with the JVM to provide implementations of XMLInputFactory, XMLOutputFactory and XMLEventFactory from ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found