Skip to content

Commit b36f142

Browse files
committed
Fix WebServiceMessageFactory null handling
* Add constructor overloads without messageFactory parameter * Clean up unnecessary @SuppressWarnings("NullAway") annotations Signed-off-by: Jooyoung Pyoung <[email protected]>
1 parent 99bea96 commit b36f142

File tree

5 files changed

+57
-26
lines changed

5 files changed

+57
-26
lines changed

spring-integration-ws/src/main/java/org/springframework/integration/ws/AbstractWebServiceOutboundGateway.java

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
* @author Artem Bilan
6262
* @author Christian Tzolov
6363
* @author Ngoc Nhan
64+
* @author Jooyoung Pyoung
6465
*/
6566
public abstract class AbstractWebServiceOutboundGateway extends AbstractReplyProducingMessageHandler {
6667

@@ -87,25 +88,56 @@ public abstract class AbstractWebServiceOutboundGateway extends AbstractReplyPro
8788

8889
private boolean webServiceTemplateExplicitlySet;
8990

90-
@SuppressWarnings("NullAway")
91-
public AbstractWebServiceOutboundGateway(final String uri, @Nullable WebServiceMessageFactory messageFactory) {
91+
public AbstractWebServiceOutboundGateway(final String uri) {
92+
Assert.hasText(uri, "URI must not be empty");
93+
this.webServiceTemplate = new WebServiceTemplate();
94+
this.destinationProvider = null;
95+
this.uri = uri;
96+
}
97+
98+
public AbstractWebServiceOutboundGateway(final String uri, WebServiceMessageFactory messageFactory) {
9299
Assert.hasText(uri, "URI must not be empty");
93100
this.webServiceTemplate = new WebServiceTemplate(messageFactory);
94101
this.destinationProvider = null;
95102
this.uri = uri;
96103
}
97104

98-
@SuppressWarnings("NullAway")
105+
public AbstractWebServiceOutboundGateway(final String uri, WebServiceTemplate webServiceTemplate) {
106+
Assert.hasText(uri, "URI must not be empty");
107+
doSetWebServiceTemplate(webServiceTemplate);
108+
this.destinationProvider = null;
109+
this.uri = uri;
110+
}
111+
112+
protected AbstractWebServiceOutboundGateway(DestinationProvider destinationProvider,
113+
WebServiceTemplate webServiceTemplate) {
114+
115+
Assert.notNull(destinationProvider, "DestinationProvider must not be null");
116+
doSetWebServiceTemplate(webServiceTemplate);
117+
this.destinationProvider = destinationProvider;
118+
this.uri = "";
119+
}
120+
121+
public AbstractWebServiceOutboundGateway(DestinationProvider destinationProvider) {
122+
Assert.notNull(destinationProvider, "DestinationProvider must not be null");
123+
this.webServiceTemplate = new WebServiceTemplate();
124+
this.destinationProvider = destinationProvider;
125+
// we always call WebServiceTemplate methods with an explicit URI argument,
126+
// but in case the WebServiceTemplate is accessed directly we'll set this:
127+
this.webServiceTemplate.setDestinationProvider(destinationProvider);
128+
this.uri = "";
129+
}
130+
99131
public AbstractWebServiceOutboundGateway(DestinationProvider destinationProvider,
100-
@Nullable WebServiceMessageFactory messageFactory) {
132+
WebServiceMessageFactory messageFactory) {
101133

102134
Assert.notNull(destinationProvider, "DestinationProvider must not be null");
103135
this.webServiceTemplate = new WebServiceTemplate(messageFactory);
104136
this.destinationProvider = destinationProvider;
105137
// we always call WebServiceTemplate methods with an explicit URI argument,
106138
// but in case the WebServiceTemplate is accessed directly we'll set this:
107139
this.webServiceTemplate.setDestinationProvider(destinationProvider);
108-
this.uri = null;
140+
this.uri = "";
109141
}
110142

111143
public void setHeaderMapper(SoapHeaderMapper headerMapper) {

spring-integration-ws/src/main/java/org/springframework/integration/ws/MarshallingWebServiceOutboundGateway.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public class MarshallingWebServiceOutboundGateway extends AbstractWebServiceOutb
4646

4747
@SuppressWarnings("this-escape")
4848
public MarshallingWebServiceOutboundGateway(DestinationProvider destinationProvider, Marshaller marshaller,
49-
@Nullable Unmarshaller unmarshaller, @Nullable WebServiceMessageFactory messageFactory) {
49+
@Nullable Unmarshaller unmarshaller, WebServiceMessageFactory messageFactory) {
5050
super(destinationProvider, messageFactory);
5151
configureMarshallers(marshaller, unmarshaller);
5252
}
@@ -69,7 +69,7 @@ public MarshallingWebServiceOutboundGateway(DestinationProvider destinationProvi
6969

7070
@SuppressWarnings("this-escape")
7171
public MarshallingWebServiceOutboundGateway(String uri, Marshaller marshaller, @Nullable Unmarshaller unmarshaller,
72-
@Nullable WebServiceMessageFactory messageFactory) {
72+
WebServiceMessageFactory messageFactory) {
7373
super(uri, messageFactory);
7474
configureMarshallers(marshaller, unmarshaller);
7575
}
@@ -95,10 +95,9 @@ public MarshallingWebServiceOutboundGateway(String uri, Marshaller marshaller) {
9595
* @param webServiceTemplate the WebServiceTemplate
9696
* @since 5.0
9797
*/
98-
@SuppressWarnings({"this-escape", "NullAway"})
98+
@SuppressWarnings("this-escape")
9999
public MarshallingWebServiceOutboundGateway(String uri, WebServiceTemplate webServiceTemplate) {
100-
super(uri, null);
101-
doSetWebServiceTemplate(webServiceTemplate);
100+
super(uri, webServiceTemplate);
102101
}
103102

104103
/**
@@ -107,11 +106,10 @@ public MarshallingWebServiceOutboundGateway(String uri, WebServiceTemplate webSe
107106
* @param webServiceTemplate the WebServiceTemplate
108107
* @since 5.0
109108
*/
110-
@SuppressWarnings({"this-escape", "NullAway"})
109+
@SuppressWarnings("this-escape")
111110
public MarshallingWebServiceOutboundGateway(DestinationProvider destinationProvider,
112111
WebServiceTemplate webServiceTemplate) {
113-
super(destinationProvider, null);
114-
doSetWebServiceTemplate(webServiceTemplate);
112+
super(destinationProvider, webServiceTemplate);
115113
}
116114

117115
/**

spring-integration-ws/src/main/java/org/springframework/integration/ws/SimpleWebServiceOutboundGateway.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,33 +58,33 @@ public class SimpleWebServiceOutboundGateway extends AbstractWebServiceOutboundG
5858
private boolean extractPayload = true;
5959

6060
public SimpleWebServiceOutboundGateway(DestinationProvider destinationProvider) {
61-
this(destinationProvider, null, null);
61+
this(destinationProvider, null);
6262
}
6363

6464
public SimpleWebServiceOutboundGateway(DestinationProvider destinationProvider,
65-
SourceExtractor<?> sourceExtractor) {
66-
67-
this(destinationProvider, sourceExtractor, null);
65+
@Nullable SourceExtractor<?> sourceExtractor) {
66+
super(destinationProvider);
67+
this.sourceExtractor = (sourceExtractor != null) ? sourceExtractor : new DefaultSourceExtractor();
6868
}
6969

7070
public SimpleWebServiceOutboundGateway(DestinationProvider destinationProvider,
7171
@Nullable SourceExtractor<?> sourceExtractor,
72-
@Nullable WebServiceMessageFactory messageFactory) {
73-
72+
WebServiceMessageFactory messageFactory) {
7473
super(destinationProvider, messageFactory);
7574
this.sourceExtractor = (sourceExtractor != null) ? sourceExtractor : new DefaultSourceExtractor();
7675
}
7776

7877
public SimpleWebServiceOutboundGateway(String uri) {
79-
this(uri, null, null);
78+
this(uri, null);
8079
}
8180

82-
public SimpleWebServiceOutboundGateway(String uri, SourceExtractor<?> sourceExtractor) {
83-
this(uri, sourceExtractor, null);
81+
public SimpleWebServiceOutboundGateway(String uri, @Nullable SourceExtractor<?> sourceExtractor) {
82+
super(uri);
83+
this.sourceExtractor = (sourceExtractor != null) ? sourceExtractor : new DefaultSourceExtractor();
8484
}
8585

8686
public SimpleWebServiceOutboundGateway(String uri, @Nullable SourceExtractor<?> sourceExtractor,
87-
@Nullable WebServiceMessageFactory messageFactory) {
87+
WebServiceMessageFactory messageFactory) {
8888

8989
super(uri, messageFactory);
9090
this.sourceExtractor = (sourceExtractor != null) ? sourceExtractor : new DefaultSourceExtractor();

spring-integration-ws/src/main/java/org/springframework/integration/ws/dsl/BaseWsOutboundGatewaySpec.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ public abstract class BaseWsOutboundGatewaySpec<
6161
@SuppressWarnings("NullAway.Init")
6262
protected String uri; // NOSONAR
6363

64-
protected @Nullable WebServiceMessageFactory webServiceMessageFactory; // NOSONAR
64+
@SuppressWarnings("NullAway.Init")
65+
protected WebServiceMessageFactory webServiceMessageFactory; // NOSONAR
6566

6667
private @Nullable SoapHeaderMapper headerMapper;
6768

spring-integration-ws/src/test/java/org/springframework/integration/ws/config/WebServiceOutboundGatewayParserTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -382,7 +382,7 @@ public void simpleGatewayWithDestinationProvider() {
382382
DirectFieldAccessor accessor = new DirectFieldAccessor(gateway);
383383
assertThat(accessor.getPropertyValue("destinationProvider")).as("Wrong DestinationProvider")
384384
.isEqualTo(stubProvider);
385-
assertThat(accessor.getPropertyValue("uri")).isNull();
385+
assertThat(accessor.getPropertyValue("uri")).isEqualTo("");
386386
Object destinationProviderObject = new DirectFieldAccessor(
387387
accessor.getPropertyValue("webServiceTemplate")).getPropertyValue("destinationProvider");
388388
assertThat(destinationProviderObject).as("Wrong DestinationProvider").isEqualTo(stubProvider);

0 commit comments

Comments
 (0)