Repository navigation
fix(sip-core): construct Woodstox StAX factories directly - #536
Merged
Merged
Conversation
WstxInputFactory.newInstance() is the inherited static XMLInputFactory.newInstance(), a lookup through the thread context class loader. Under Play's dev-mode loader some Narthex worker threads got the JDK parser, and MetadataRecordFactory's cast to XMLStreamReader2 failed every record. Construct the input, output and event factories directly.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Running Narthex locally (
sbt run, Play dev mode), processing brabantse-gebouwen gave 1,000 valid and 2,041 invalid records. Every invalid record failed with the same error:Production processes the same dataset without errors.
Cause
XMLToolFactory.xmlInputFactory()calledWstxInputFactory.newInstance(). That method is the staticXMLInputFactory.newInstance()inherited fromXMLInputFactory, which looks up an implementation through the thread context class loader; it does not construct a Woodstox factory. Under Play's dev-mode class loader, some worker threads can't see Woodstox and get the JDK parser instead.MetadataRecordFactorythen casts the reader toXMLStreamReader2and fails.Fix
XMLToolFactorynow constructsWstxInputFactory,WstxOutputFactoryandWstxEventFactorydirectly. The output and event factories used the samenewInstance()lookup. Nothing casts their results today, but Woodstox registers itself as the service for all three, so production already resolves them to Woodstox. Constructing them directly keeps that behaviour and removes the dependency on the class loader.TestXMLToolFactorycovers this:XMLStreamReader2;WstxInputFactory. This test fails on main withXMLInputFactoryImpl, which is the bug.mvn test -pl sip-coreon Java 21: 160 tests, 0 failures.Follow-up
Narthex pins sip-core
1.4.1-RC1, so it only picks this up after a release and a version bump in Narthex. That's your call.