Skip to content

Explicitly pass ClassLoader of XmlFactory when creating Stax input/output factory, instead of context ClassLoaderΒ #483

@cowtowncoder

Description

@cowtowncoder

(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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions