Skip to content
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

Custom FaultMessageResolver throw UndeclaredThrowableException on checked Exception #1448

Open
dan-lang-droid opened this issue Jan 9, 2025 · 0 comments
Labels
status: waiting-for-triage An issue we've not yet triaged

Comments

@dan-lang-droid
Copy link

dan-lang-droid commented Jan 9, 2025

When updating to spring-boot v3.4.0 (ws: v4.0.11) (also observed in v3.4.1) from 3.3.7 (ws: v4.0.8), a regression is observed when having a custom FaultMessageResolver that throw a checked exception.

To replicate:

Have a WebServiceTemplate with a custom FaultMessageResolver:

private WebServiceTemplate buildTemplate(...) {
    WebServiceTemplate webServiceTemplate = new WebServiceTemplate();
    (...)
    webServiceTemplate.setFaultMessageResolver(new CustomFaultMessageResolver());
    return webServiceTemplate;
}

Have the custom FaultMessageResolver

public class CustomFaultMessageResolver extends SoapFaultMessageResolver {
    @Override
    public void resolveFault(WebServiceMessage message) throws IOException {
        throwException(new Exception("Custom exception"));
    }

    private void throwException(Throwable exception) {
        this.<RuntimeException>throwException(exception, null);
    }

    private <T extends Throwable> void throwException(T exception, Object dummy) throws T {
        throw (T) exception;
    }
}

And the WebServiceTemplate operation invokation, server side should return a fault

public void doOperation() throws Exception {
    ExampleOperationRequest request = new ExampleOperationRequest();
    ExampleOperationResponse response = (ExampleOperationResponse)webServiceTemplate.marshalSendAndReceive(request);
}

Let me know if any further information is required.

Thank you for the help

@snicoll snicoll added the status: waiting-for-triage An issue we've not yet triaged label Feb 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-triage An issue we've not yet triaged
Projects
None yet
Development

No branches or pull requests

2 participants