[SWS-867] MethodReturnValueHandler implementations should support null return values from endpoints Created: 19/Mar/14  Updated: 20/Mar/14  Resolved: 20/Mar/14

Status: Resolved
Project: Spring Web Services
Component/s: OXM
Affects Version/s: 2.1.4
Fix Version/s: 2.2.RC1

Type: Improvement Priority: Minor
Reporter: Phil McCarley Assignee: Arjen Poutsma
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


Here is an example Endpoint...

public class WsDiscovery {
    private static final String ENDPOINT_REFERENCE = "uuid:f7a32a18-5205-46f1-b296-e0f6ac9de7ed";

    @Action(value = "http://schemas.xmlsoap.org/ws/2005/04/discovery/Resolve", output = "http://schemas.xmlsoap.org/ws/2005/04/discovery/ResolveMatches")
    public @ResponsePayload JAXBElement<ResolveMatchesType> handleResolve(@RequestPayload JAXBElement<ResolveType> element) {
        if (ENDPOINT_REFERENCE.equals(element.getValue().getEndpointReference().getAddress())) {
            return new ObjectFactory().createResolveMatches(new ResolveMatchesType());
        return null;

In the case where we the ENDPOINT_REFERENCE doesn't match, we don't want to send a response at all, and so the method returns 'null'. However, in all but the AbstractPayloadSourceMethodProcessor implementations, either a NullPointerException or IllegalArgumentException (from the Assert.notNull) will be thrown.

I believe handling null return values by suppressing the sending of a response is the most consistent approach, given that this is what Spring MVC does.

Comment by Arjen Poutsma [ 20/Mar/14 ]


Generated at Sun Oct 21 20:55:40 UTC 2018 using JIRA 7.9.2#79002-sha1:3bb15b68ecd99a30eb364c4c1a393359bcad6278.