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

MarshallingWsOutboundGatewayNoTemplateSpec overwrites useful WebserviceTemplate defaults with null #3688

Closed
gviczai opened this issue Dec 10, 2021 · 0 comments · Fixed by #3689
Assignees
Milestone

Comments

@gviczai
Copy link

gviczai commented Dec 10, 2021

In what version(s) of Spring Integration are you seeing this issue?

5.5.6, 5.4.x, but other versions are affected as well

Describe the bug

In MarshallingWsOutboundGatewaySpec.MarshallingWsOutboundGatewayNoTemplateSpec class the assemble() method overwrites messageSenders and faultMessageResolver's otherwise useful and valid default not null values
with null values in the WebServiceTemplate created by the builder itself if no values provided in the builder explicitly:
https://github.com/spring-projects/spring-integration/blob/5.4.x/spring-integration-ws/src/main/java/org/springframework/integration/ws/dsl/MarshallingWsOutboundGatewaySpec.java#L144
https://github.com/spring-projects/spring-integration/blob/5.4.x/spring-integration-ws/src/main/java/org/springframework/integration/ws/AbstractWebServiceOutboundGateway.java#L181

Also, one MUST provide an encodingMode in the builder, because BaseWsOutboundGatewaySpec does exactly the same (overwrites the correct default value without null checking) with the UriFactory's encodingMode:
https://github.com/spring-projects/spring-integration/blob/5.4.x/spring-integration-ws/src/main/java/org/springframework/integration/ws/dsl/BaseWsOutboundGatewaySpec.java#L162
https://github.com/spring-projects/spring-integration/blob/5.4.x/spring-integration-ws/src/main/java/org/springframework/integration/ws/AbstractWebServiceOutboundGateway.java#L140

To Reproduce

create a Ws.marshallingOutboundGateway()

Expected behavior

faultMessageResolver, messageSenders and enCodingmode:

  • may be left unspecified in builder, in which case the defaults in WebServiceTemplate and UriFactory should be left intact
    (Note: A simple null check before the setter calls would be sufficient.)
  • if one needs null values, they should provide WebServiceTemplate and UriFactory explicitly (with mentioned fields set to null)

Sample

IntegrationFlow myFlow = IntegrationFlows
        .from(MessageChannels.direct("myChannel"))
        .handle(
            Ws.marshallingOutboundGateway()
                .marshaller(jaxb2Marshaller())
                .destinationProvider(createDestinationProvider(myBackendUri))
                // IntegrationFlows's Ws.marshallingOutBoundGateway a little bit buggy, it
                // overwrites nice defaults already set, so we have to provide encodingMode,
                // faultMessageResolver and MessageSenders here, otherwise they will be nulled,
                // which results in an error...
                .encodingMode(DefaultUriBuilderFactory.EncodingMode.TEMPLATE_AND_VALUES)
                .messageSenders(getWebserviceTemplateDefaultMessageSenders())
                .faultMessageResolver(getWebserviceTemplateDefaultFaultMessageResolver()))
        .get();
@gviczai gviczai added status: waiting-for-triage The issue need to be evaluated and its future decided type: bug labels Dec 10, 2021
@artembilan artembilan self-assigned this Dec 10, 2021
@artembilan artembilan added this to the 5.5.7 milestone Dec 10, 2021
@artembilan artembilan added backport 5.3.x in: ws and removed status: waiting-for-triage The issue need to be evaluated and its future decided labels Dec 10, 2021
artembilan added a commit to artembilan/spring-integration that referenced this issue Dec 10, 2021
Fixes spring-projects#3688

The `WebServiceTemplate` is populated with some defaults from its ctor.
We should rely on the target default template values as much as possible
and don't override them to `null` if end-user doesn't ask about that explicitly

* Fix `BaseWsOutboundGatewaySpec` extensions to populate values to the target gateway
only if they are not null - therefore provided by end-user
* If end-user wants them explicitly `null`, it is better to do that via
externally configured template.
See overloaded variants for DSL: `Ws.marshallingOutboundGateway(WebServiceTemplate)`
and `Ws.simpleOutboundGateway(WebServiceTemplate)`

**Cherry-pick to `5.4.x` & `5.3.x`**
garyrussell pushed a commit that referenced this issue Dec 13, 2021
Fixes #3688

The `WebServiceTemplate` is populated with some defaults from its ctor.
We should rely on the target default template values as much as possible
and don't override them to `null` if end-user doesn't ask about that explicitly

* Fix `BaseWsOutboundGatewaySpec` extensions to populate values to the target gateway
only if they are not null - therefore provided by end-user
* If end-user wants them explicitly `null`, it is better to do that via
externally configured template.
See overloaded variants for DSL: `Ws.marshallingOutboundGateway(WebServiceTemplate)`
and `Ws.simpleOutboundGateway(WebServiceTemplate)`

**Cherry-pick to `5.4.x` & `5.3.x`**
garyrussell pushed a commit that referenced this issue Dec 13, 2021
Fixes #3688

The `WebServiceTemplate` is populated with some defaults from its ctor.
We should rely on the target default template values as much as possible
and don't override them to `null` if end-user doesn't ask about that explicitly

* Fix `BaseWsOutboundGatewaySpec` extensions to populate values to the target gateway
only if they are not null - therefore provided by end-user
* If end-user wants them explicitly `null`, it is better to do that via
externally configured template.
See overloaded variants for DSL: `Ws.marshallingOutboundGateway(WebServiceTemplate)`
and `Ws.simpleOutboundGateway(WebServiceTemplate)`

**Cherry-pick to `5.4.x` & `5.3.x`**
garyrussell pushed a commit that referenced this issue Dec 13, 2021
Fixes #3688

The `WebServiceTemplate` is populated with some defaults from its ctor.
We should rely on the target default template values as much as possible
and don't override them to `null` if end-user doesn't ask about that explicitly

* Fix `BaseWsOutboundGatewaySpec` extensions to populate values to the target gateway
only if they are not null - therefore provided by end-user
* If end-user wants them explicitly `null`, it is better to do that via
externally configured template.
See overloaded variants for DSL: `Ws.marshallingOutboundGateway(WebServiceTemplate)`
and `Ws.simpleOutboundGateway(WebServiceTemplate)`

**Cherry-pick to `5.4.x` & `5.3.x`**
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants