gaogaotiantian opened a new pull request, #56600:
URL: https://github.com/apache/spark/pull/56600

   ### What changes were proposed in this pull request?
   
   In `StaxXmlGenerator`, the StAX `XMLOutputFactory` was obtained via 
`XMLOutputFactory.newInstance()` and then configured with Woodstox-specific 
properties from the shaded Hadoop Woodstox 
(`org.apache.hadoop.shaded.com.ctc.wstx.api.WstxOutputProperties`).
   
   This PR constructs the shaded Woodstox factory directly:
   
   ```scala
   val factory = new 
org.apache.hadoop.shaded.com.ctc.wstx.stax.WstxOutputFactory()
   ```
   
   instead of relying on `XMLOutputFactory.newInstance()`.
   
   ### Why are the changes needed?
   
   `XMLOutputFactory.newInstance()` resolves a concrete StAX implementation 
through the JAXP/service-loader lookup. If any other (unshaded) StAX provider 
happens to be on the classpath, it can win that lookup and return a factory 
that is **not** the shaded Woodstox. That factory does not understand the 
shaded `WstxOutputProperties.P_OUTPUT_VALIDATE_STRUCTURE` / 
`P_OUTPUT_VALIDATE_NAMES` keys set immediately afterwards, and Woodstox/StAX 
throws `IllegalArgumentException` for unknown property keys.
   
   By instantiating the shaded `WstxOutputFactory` directly, the factory 
implementation and the property keys are guaranteed to come from the same 
shaded Woodstox, eliminating the potential conflict regardless of what else is 
on the classpath.
   
   ### Does this PR introduce _any_ user-facing change?
   
   No.
   
   ### How was this patch tested?
   
   Existing `to_xml` / XML write tests in `XmlSuite` cover this code path. No 
behavior change is expected; the factory used is the same shaded Woodstox that 
the configured properties already targeted.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: Claude Code (Opus 4.8)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to