Skip to content

SimpleXsdSchema is not thread safe [SWS-973] #1043

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
gregturn opened this issue Oct 20, 2016 · 2 comments
Open

SimpleXsdSchema is not thread safe [SWS-973] #1043

gregturn opened this issue Oct 20, 2016 · 2 comments
Labels
type: bug A general bug
Milestone

Comments

@gregturn
Copy link
Contributor

gregturn commented Oct 20, 2016

Robert Lönnqvist opened SWS-973 and commented

Hi everyone,

We are using spring-ws and discovered an issue in SimpleXsdSchema.

SimpleXsdSchema has a reference to an instance of org.w3c.dom.Element which is not thread safe. This cause issues when multiple clients are requesting the schema file simultaneously. The end result is empty attributes which causes ws clients to fail validating the schema.

I've pushed an example of the issue here.

For now, my workaround is to override SimpleXsdSchema with a version using a ThreadLocal for the element.


Affects: 2.4.0

@gregturn gregturn added status: waiting-for-triage An issue we've not yet triaged in: core labels Sep 22, 2020
@martinnemec3
Copy link

martinnemec3 commented Oct 14, 2022

I can confirm that this issue affect also the latest version (3.1.3). Due to this we are getting NPEs in production.

Another working workaround seems to be to override the getSource() method (e.g. return a new ResourceSource instance built out of the original Resource used to create the SimpleXSDSchema object). The following snippet shows the idea:

SimpleXsdSchema schema = new SimpleXsdSchema(resource) {
    @Override
    public Source getSource() {
        try {
            return new ResourceSource(resource);
        } catch (IOException e) {
            throw new UncheckedIOException(e);
        }
    }
};

@cesure
Copy link

cesure commented Jan 20, 2025

Any updates on this? We face the same issue. We have a SimpleXsdSchema @Bean and when multiple clients try to download the XSD at the same time from our SOAP service then the DOM is changed and gets corrupted.

All Spring docs advice to use SimpleXsdSchema for exposing the XSDs but no one seems aware of the problem here.

@snicoll snicoll removed the in: core label Feb 19, 2025
@snicoll snicoll added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Mar 28, 2025
@snicoll snicoll added this to the 4.0.x milestone Mar 28, 2025
@snicoll snicoll changed the title SimpleXsdSchema not thread safe. [SWS-973] SimpleXsdSchema is not thread safe [SWS-973] Mar 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

4 participants