-
Notifications
You must be signed in to change notification settings - Fork 1.1k
GH-10083: Migrate spring-integration-ws
module to Jspecify
#10098
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,8 @@ | |
|
||
import java.io.IOException; | ||
|
||
import org.springframework.lang.Nullable; | ||
import org.jspecify.annotations.Nullable; | ||
|
||
import org.springframework.messaging.Message; | ||
import org.springframework.oxm.Marshaller; | ||
import org.springframework.oxm.Unmarshaller; | ||
|
@@ -45,11 +46,12 @@ public class MarshallingWebServiceOutboundGateway extends AbstractWebServiceOutb | |
|
||
@SuppressWarnings("this-escape") | ||
public MarshallingWebServiceOutboundGateway(DestinationProvider destinationProvider, Marshaller marshaller, | ||
Unmarshaller unmarshaller, WebServiceMessageFactory messageFactory) { | ||
@Nullable Unmarshaller unmarshaller, @Nullable WebServiceMessageFactory messageFactory) { | ||
super(destinationProvider, messageFactory); | ||
configureMarshallers(marshaller, unmarshaller); | ||
} | ||
|
||
@SuppressWarnings("NullAway") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not very OK with these |
||
public MarshallingWebServiceOutboundGateway(DestinationProvider destinationProvider, Marshaller marshaller, | ||
Unmarshaller unmarshaller) { | ||
this(destinationProvider, marshaller, unmarshaller, null); | ||
|
@@ -60,17 +62,19 @@ public MarshallingWebServiceOutboundGateway(DestinationProvider destinationProvi | |
this(destinationProvider, marshaller, null, messageFactory); | ||
} | ||
|
||
@SuppressWarnings("NullAway") | ||
public MarshallingWebServiceOutboundGateway(DestinationProvider destinationProvider, Marshaller marshaller) { | ||
this(destinationProvider, marshaller, (WebServiceMessageFactory) null); | ||
} | ||
|
||
@SuppressWarnings("this-escape") | ||
public MarshallingWebServiceOutboundGateway(String uri, Marshaller marshaller, Unmarshaller unmarshaller, | ||
WebServiceMessageFactory messageFactory) { | ||
public MarshallingWebServiceOutboundGateway(String uri, Marshaller marshaller, @Nullable Unmarshaller unmarshaller, | ||
@Nullable WebServiceMessageFactory messageFactory) { | ||
super(uri, messageFactory); | ||
configureMarshallers(marshaller, unmarshaller); | ||
} | ||
|
||
@SuppressWarnings("NullAway") | ||
public MarshallingWebServiceOutboundGateway(String uri, Marshaller marshaller, Unmarshaller unmarshaller) { | ||
this(uri, marshaller, unmarshaller, null); | ||
} | ||
|
@@ -80,6 +84,7 @@ public MarshallingWebServiceOutboundGateway(String uri, Marshaller marshaller, | |
this(uri, marshaller, null, messageFactory); | ||
} | ||
|
||
@SuppressWarnings("NullAway") | ||
public MarshallingWebServiceOutboundGateway(String uri, Marshaller marshaller) { | ||
this(uri, marshaller, (WebServiceMessageFactory) null); | ||
} | ||
|
@@ -90,7 +95,7 @@ public MarshallingWebServiceOutboundGateway(String uri, Marshaller marshaller) { | |
* @param webServiceTemplate the WebServiceTemplate | ||
* @since 5.0 | ||
*/ | ||
@SuppressWarnings("this-escape") | ||
@SuppressWarnings({"this-escape", "NullAway"}) | ||
public MarshallingWebServiceOutboundGateway(String uri, WebServiceTemplate webServiceTemplate) { | ||
super(uri, null); | ||
doSetWebServiceTemplate(webServiceTemplate); | ||
|
@@ -102,7 +107,7 @@ public MarshallingWebServiceOutboundGateway(String uri, WebServiceTemplate webSe | |
* @param webServiceTemplate the WebServiceTemplate | ||
* @since 5.0 | ||
*/ | ||
@SuppressWarnings("this-escape") | ||
@SuppressWarnings({"this-escape", "NullAway"}) | ||
public MarshallingWebServiceOutboundGateway(DestinationProvider destinationProvider, | ||
WebServiceTemplate webServiceTemplate) { | ||
super(destinationProvider, null); | ||
|
@@ -139,15 +144,15 @@ public String getComponentType() { | |
} | ||
|
||
@Override | ||
protected Object doHandle(String uri, Message<?> requestMessage, WebServiceMessageCallback requestCallback) { | ||
protected @Nullable Object doHandle(String uri, Message<?> requestMessage, @Nullable WebServiceMessageCallback requestCallback) { | ||
return getWebServiceTemplate() | ||
.marshalSendAndReceive(uri, requestMessage.getPayload(), | ||
new PassThroughRequestMessageCallback(requestCallback, requestMessage)); | ||
} | ||
|
||
private final class PassThroughRequestMessageCallback extends RequestMessageCallback { | ||
|
||
PassThroughRequestMessageCallback(WebServiceMessageCallback requestCallback, Message<?> requestMessage) { | ||
PassThroughRequestMessageCallback(@Nullable WebServiceMessageCallback requestCallback, Message<?> requestMessage) { | ||
super(requestCallback, requestMessage); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright 2002-2024 the original author or authors. | ||
* Copyright 2002-2025 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
|
@@ -25,9 +25,9 @@ | |
import javax.xml.transform.dom.DOMResult; | ||
import javax.xml.transform.dom.DOMSource; | ||
|
||
import org.jspecify.annotations.Nullable; | ||
import org.w3c.dom.Document; | ||
|
||
import org.springframework.lang.Nullable; | ||
import org.springframework.messaging.Message; | ||
import org.springframework.messaging.MessagingException; | ||
import org.springframework.util.Assert; | ||
|
@@ -49,6 +49,7 @@ | |
* @author Oleg Zhurakousky | ||
* @author Artem Bilan | ||
* @author Gary Russell | ||
* @author Jooyoung Pyoung | ||
*/ | ||
public class SimpleWebServiceOutboundGateway extends AbstractWebServiceOutboundGateway { | ||
|
||
|
@@ -68,7 +69,7 @@ public SimpleWebServiceOutboundGateway(DestinationProvider destinationProvider, | |
|
||
public SimpleWebServiceOutboundGateway(DestinationProvider destinationProvider, | ||
@Nullable SourceExtractor<?> sourceExtractor, | ||
WebServiceMessageFactory messageFactory) { | ||
@Nullable WebServiceMessageFactory messageFactory) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have to fix those places to not provide a null for the |
||
|
||
super(destinationProvider, messageFactory); | ||
this.sourceExtractor = (sourceExtractor != null) ? sourceExtractor : new DefaultSourceExtractor(); | ||
|
@@ -83,7 +84,7 @@ public SimpleWebServiceOutboundGateway(String uri, SourceExtractor<?> sourceExtr | |
} | ||
|
||
public SimpleWebServiceOutboundGateway(String uri, @Nullable SourceExtractor<?> sourceExtractor, | ||
WebServiceMessageFactory messageFactory) { | ||
@Nullable WebServiceMessageFactory messageFactory) { | ||
|
||
super(uri, messageFactory); | ||
this.sourceExtractor = (sourceExtractor != null) ? sourceExtractor : new DefaultSourceExtractor(); | ||
|
@@ -107,8 +108,8 @@ public String getComponentType() { | |
} | ||
|
||
@Override | ||
protected Object doHandle(String uri, final Message<?> requestMessage, | ||
final WebServiceMessageCallback requestCallback) { | ||
protected @Nullable Object doHandle(String uri, final Message<?> requestMessage, | ||
final @Nullable WebServiceMessageCallback requestCallback) { | ||
|
||
Object requestPayload = requestMessage.getPayload(); | ||
Result responseResultInstance = null; | ||
|
@@ -126,21 +127,24 @@ else if (requestPayload instanceof Document) { | |
|
||
private final class SimpleRequestMessageCallback extends RequestMessageCallback { | ||
|
||
SimpleRequestMessageCallback(WebServiceMessageCallback requestCallback, Message<?> requestMessage) { | ||
SimpleRequestMessageCallback(@Nullable WebServiceMessageCallback requestCallback, Message<?> requestMessage) { | ||
super(requestCallback, requestMessage); | ||
} | ||
|
||
@Override | ||
public void doWithMessageInternal(WebServiceMessage message, Object payload) | ||
throws IOException, TransformerException { | ||
Source source = this.extractSource(payload); | ||
if (source == null) { | ||
source = new DOMSource(); | ||
} | ||
transform(source, message.getPayloadResult()); | ||
if (message instanceof MimeMessage && payload instanceof MimeMessage) { | ||
copyAttachments((MimeMessage) payload, (MimeMessage) message); | ||
} | ||
} | ||
|
||
private Source extractSource(Object requestPayload) throws IOException, TransformerException { | ||
private @Nullable Source extractSource(Object requestPayload) throws IOException, TransformerException { | ||
Source source = null; | ||
|
||
if (requestPayload instanceof Source) { | ||
|
@@ -181,14 +185,14 @@ private void copyAttachments(MimeMessage source, MimeMessage target) { | |
|
||
private final class SimpleResponseMessageExtractor extends ResponseMessageExtractor { | ||
|
||
private final Result result; | ||
private final @Nullable Result result; | ||
|
||
SimpleResponseMessageExtractor(Result result) { | ||
SimpleResponseMessageExtractor(@Nullable Result result) { | ||
this.result = result; | ||
} | ||
|
||
@Override | ||
public Object doExtractData(WebServiceMessage message) throws TransformerException { | ||
public @Nullable Object doExtractData(WebServiceMessage message) throws TransformerException { | ||
if (!SimpleWebServiceOutboundGateway.this.extractPayload) { | ||
return message; | ||
} | ||
|
@@ -220,10 +224,13 @@ private static class DefaultSourceExtractor extends TransformerObjectSupport imp | |
} | ||
|
||
@Override | ||
public DOMSource extractData(Source source) throws TransformerException { | ||
public @Nullable DOMSource extractData(@Nullable Source source) throws TransformerException { | ||
if (source instanceof DOMSource) { | ||
return (DOMSource) source; | ||
} | ||
else if (source == null) { | ||
return new DOMSource(); | ||
} | ||
DOMResult result = new DOMResult(); | ||
this.transform(source, result); | ||
return new DOMSource(result.getNode()); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
/** | ||
* Contains parser classes for the Web Services namespace support. | ||
*/ | ||
@org.jspecify.annotations.NullMarked | ||
package org.springframework.integration.ws.config; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not correct.
The
WebServiceTemplate
expects from us aWebServiceMessageFactory
as a not null.If you see somewhere it is, let's mitigate it over there!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
then.. when ctors pass null for
WebServiceMessageFactory
, I'll replace null withSaajSoapMessageFactory
as the default. Does this sound good?Based on the WebServiceTemplate.properties,
SaajSoapMessageFactory
is indeed the default strategy.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would we allow to pass null at all?
The
WebServiceTemplate
does not expect that from us, so let's comeback to not-null for this ctors!Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I meant that I'll remove
@Nullable
from the constructor parameters and fix the calling sites to passSaajSoapMessageFactory
instance instead of null.For example:
Am I still misunderstanding something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see:
I think it is better to introduce a
protected
ctor in theAbstractWebServiceOutboundGateway
based on theWebServiceTemplate
then.