Skip to content

Commit f26bfe5

Browse files
committed
Polish nullability declarations
1 parent 6b2797f commit f26bfe5

File tree

8 files changed

+32
-15
lines changed

8 files changed

+32
-15
lines changed

spring-ws-core/src/main/java/org/springframework/ws/client/core/WebServiceTemplate.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ public void setDestinationProvider(DestinationProvider destinationProvider) {
270270
}
271271

272272
/** Sets the marshaller for this template. */
273-
public void setMarshaller(Marshaller marshaller) {
273+
public void setMarshaller(@Nullable Marshaller marshaller) {
274274
this.marshaller = marshaller;
275275
}
276276

@@ -280,7 +280,7 @@ public void setMarshaller(Marshaller marshaller) {
280280
}
281281

282282
/** Sets the unmarshaller for this template. */
283-
public void setUnmarshaller(Unmarshaller unmarshaller) {
283+
public void setUnmarshaller(@Nullable Unmarshaller unmarshaller) {
284284
this.unmarshaller = unmarshaller;
285285
}
286286

@@ -566,15 +566,15 @@ public boolean sendAndReceive(String uri, WebServiceMessageCallback requestCallb
566566
}
567567

568568
@Override
569-
public <T> @Nullable T sendAndReceive(WebServiceMessageCallback requestCallback,
569+
public <T> @Nullable T sendAndReceive(@Nullable WebServiceMessageCallback requestCallback,
570570
WebServiceMessageExtractor<T> responseExtractor) {
571571
String defaultUri = getDefaultUri();
572572
Assert.notNull(defaultUri, "'defaultUri' must not be null");
573573
return sendAndReceive(defaultUri, requestCallback, responseExtractor);
574574
}
575575

576576
@Override
577-
public <T> @Nullable T sendAndReceive(String uriString, WebServiceMessageCallback requestCallback,
577+
public <T> @Nullable T sendAndReceive(String uriString, @Nullable WebServiceMessageCallback requestCallback,
578578
WebServiceMessageExtractor<T> responseExtractor) {
579579
Assert.notNull(responseExtractor, "'responseExtractor' must not be null");
580580
Assert.hasLength(uriString, "'uri' must not be empty");

spring-ws-core/src/main/java/org/springframework/ws/soap/support/SoapUtils.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import java.util.regex.Matcher;
2020
import java.util.regex.Pattern;
2121

22+
import org.jspecify.annotations.Nullable;
23+
2224
import org.springframework.util.Assert;
2325
import org.springframework.util.StringUtils;
2426
import org.springframework.ws.transport.TransportConstants;
@@ -38,7 +40,7 @@ private SoapUtils() {
3840
}
3941

4042
/** Escapes the given SOAP action to be surrounded by quotes. */
41-
public static String escapeAction(String soapAction) {
43+
public static String escapeAction(@Nullable String soapAction) {
4244

4345
if (!StringUtils.hasLength(soapAction)) {
4446
soapAction = "\"\"";

spring-ws-core/src/main/java/org/springframework/ws/transport/context/TransportContextHolder.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package org.springframework.ws.transport.context;
1818

19+
import org.jspecify.annotations.Nullable;
20+
1921
/**
2022
* Simple holder class that associates a {@code TransportContext} instance with the
2123
* current thread. The {@code TransportContext} will be inherited by any child threads
@@ -34,8 +36,13 @@ public abstract class TransportContextHolder {
3436
* @param transportContext the current transport context, or {@code null} to reset the
3537
* thread-bound context
3638
*/
37-
public static void setTransportContext(TransportContext transportContext) {
38-
transportContextHolder.set(transportContext);
39+
public static void setTransportContext(@Nullable TransportContext transportContext) {
40+
if (transportContext != null) {
41+
transportContextHolder.set(transportContext);
42+
}
43+
else {
44+
transportContextHolder.remove();
45+
}
3946
}
4047

4148
/**

spring-ws-core/src/main/java/org/springframework/ws/wsdl/wsdl11/provider/AbstractPortTypesProvider.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package org.springframework.ws.wsdl.wsdl11.provider;
1818

1919
import java.util.List;
20+
import java.util.Objects;
2021

2122
import javax.wsdl.Definition;
2223
import javax.wsdl.Fault;
@@ -90,7 +91,7 @@ public void addPortTypes(Definition definition) throws WSDLException {
9091
*/
9192
protected void populatePortType(Definition definition, PortType portType) throws WSDLException {
9293

93-
QName portTypeName = new QName(definition.getTargetNamespace(), getPortTypeName());
94+
QName portTypeName = new QName(definition.getTargetNamespace(), Objects.requireNonNull(getPortTypeName()));
9495
if (this.logger.isDebugEnabled()) {
9596
this.logger.debug("Creating port type [" + portTypeName + "]");
9697
}

spring-ws-support/src/main/java/org/springframework/ws/transport/mail/MailMessageReceiver.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,12 +194,13 @@ protected void onShutdown() {
194194
}
195195

196196
private void openSession() throws MessagingException {
197-
this.store = this.session.getStore(this.storeUri);
197+
Store storeToConnectTo = this.session.getStore(this.storeUri);
198198
if (this.logger.isDebugEnabled()) {
199199
this.logger
200200
.debug("Connecting to store [" + MailTransportUtils.toPasswordProtectedString(this.storeUri) + "]");
201201
}
202-
this.store.connect();
202+
storeToConnectTo.connect();
203+
this.store = storeToConnectTo;
203204
}
204205

205206
private void openFolder() throws MessagingException {

spring-ws-support/src/test/java/org/springframework/ws/transport/jms/JmsMessageSenderIntegrationTests.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import jakarta.xml.soap.SOAPException;
3535
import org.apache.activemq.ActiveMQConnectionFactory;
3636
import org.awaitility.Awaitility;
37+
import org.jspecify.annotations.Nullable;
3738
import org.junit.jupiter.api.Test;
3839

3940
import org.springframework.beans.factory.annotation.Autowired;
@@ -227,15 +228,15 @@ public Boolean doInJms(Session session, QueueBrowser browser) throws JMSExceptio
227228

228229
static class TestJmsListener {
229230

230-
private ThrowingFunction<jakarta.jms.Message, Object> messageHandler;
231+
private ThrowingFunction<jakarta.jms.Message, @Nullable Object> messageHandler;
231232

232-
public void handleMessage(ThrowingFunction<Message, Object> messageHandler) {
233+
public void handleMessage(ThrowingFunction<Message, @Nullable Object> messageHandler) {
233234
this.messageHandler = messageHandler;
234235
}
235236

236237
@JmsListener(destination = "SenderRequestQueue")
237238
@SendTo("SenderResponseQueue")
238-
Object handleRequest(jakarta.jms.Message message) {
239+
@Nullable Object handleRequest(jakarta.jms.Message message) {
239240
return this.messageHandler.apply(message);
240241
}
241242

spring-ws-test/src/main/java/org/springframework/ws/test/client/WebServiceMessageMatcherAdapter.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import java.io.IOException;
2020
import java.net.URI;
2121

22+
import org.jspecify.annotations.Nullable;
23+
2224
import org.springframework.util.Assert;
2325
import org.springframework.ws.WebServiceMessage;
2426
import org.springframework.ws.test.support.matcher.WebServiceMessageMatcher;
@@ -39,7 +41,7 @@ class WebServiceMessageMatcherAdapter implements RequestMatcher {
3941
}
4042

4143
@Override
42-
public void match(URI uri, WebServiceMessage request) throws IOException, AssertionError {
44+
public void match(@Nullable URI uri, WebServiceMessage request) throws IOException, AssertionError {
4345
this.adaptee.match(request);
4446
}
4547

spring-ws-test/src/main/java/org/springframework/ws/test/server/WebServiceMessageMatcherAdapter.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
import java.io.IOException;
2020

21+
import org.jspecify.annotations.Nullable;
22+
2123
import org.springframework.util.Assert;
2224
import org.springframework.ws.WebServiceMessage;
2325
import org.springframework.ws.test.support.matcher.WebServiceMessageMatcher;
@@ -38,7 +40,8 @@ class WebServiceMessageMatcherAdapter implements ResponseMatcher {
3840
}
3941

4042
@Override
41-
public void match(WebServiceMessage request, WebServiceMessage response) throws IOException, AssertionError {
43+
public void match(@Nullable WebServiceMessage request, WebServiceMessage response)
44+
throws IOException, AssertionError {
4245
this.adaptee.match(response);
4346
}
4447

0 commit comments

Comments
 (0)