Skip to content

Commit 9e3f00a

Browse files
committed
NullAway fixes
1 parent 89ca8e6 commit 9e3f00a

File tree

8 files changed

+23
-19
lines changed

8 files changed

+23
-19
lines changed

spring-core/src/main/java/org/springframework/core/codec/Decoder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ Mono<T> decodeToMono(Publisher<DataBuffer> inputStream, ResolvableType elementTy
9393
default @Nullable T decode(DataBuffer buffer, ResolvableType targetType,
9494
@Nullable MimeType mimeType, @Nullable Map<String, Object> hints) throws DecodingException {
9595

96-
CompletableFuture<T> future = decodeToMono(Mono.just(buffer), targetType, mimeType, hints).toFuture();
96+
CompletableFuture<@Nullable T> future = decodeToMono(Mono.just(buffer), targetType, mimeType, hints).toFuture();
9797
Assert.state(future.isDone(), "DataBuffer decoding should have completed");
9898

9999
try {

spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompBrokerRelayMessageHandler.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
9696

9797
private static final byte[] EMPTY_PAYLOAD = new byte[0];
9898

99-
private static final CompletableFuture<Void> EMPTY_TASK = CompletableFuture.completedFuture(null);
99+
private static final CompletableFuture<@Nullable Void> EMPTY_TASK = CompletableFuture.completedFuture(null);
100100

101101
private static final StompHeaderAccessor HEART_BEAT_ACCESSOR;
102102

@@ -851,7 +851,7 @@ public void afterConnectionClosed() {
851851
* @return a future to wait for the result
852852
*/
853853
@SuppressWarnings("unchecked")
854-
public CompletableFuture<Void> forward(final Message<?> message, final StompHeaderAccessor accessor) {
854+
public CompletableFuture<@Nullable Void> forward(final Message<?> message, final StompHeaderAccessor accessor) {
855855
TcpConnection<byte[]> conn = this.tcpConnection;
856856

857857
if (!this.isStompConnected || conn == null) {
@@ -887,7 +887,7 @@ else if (logger.isTraceEnabled()) {
887887
logger.trace("Forwarding " + accessor.getDetailedLogMessage(message.getPayload()));
888888
}
889889

890-
CompletableFuture<Void> future = conn.sendAsync((Message<byte[]>) messageToSend);
890+
CompletableFuture<@Nullable Void> future = conn.sendAsync((Message<byte[]>) messageToSend);
891891
future.whenComplete((unused, throwable) -> {
892892
if (throwable == null) {
893893
if (accessor.getCommand() == StompCommand.DISCONNECT) {
@@ -1067,9 +1067,9 @@ public void afterConnectionClosed() {
10671067
}
10681068

10691069
@Override
1070-
public CompletableFuture<Void> forward(Message<?> message, StompHeaderAccessor accessor) {
1070+
public CompletableFuture<@Nullable Void> forward(Message<?> message, StompHeaderAccessor accessor) {
10711071
try {
1072-
CompletableFuture<Void> future = super.forward(message, accessor);
1072+
CompletableFuture<@Nullable Void> future = super.forward(message, accessor);
10731073
if (message.getHeaders().get(SimpMessageHeaderAccessor.IGNORE_ERROR) == null) {
10741074
future.get();
10751075
}

spring-messaging/src/main/java/org/springframework/messaging/tcp/TcpConnection.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import java.io.Closeable;
2020
import java.util.concurrent.CompletableFuture;
2121

22+
import org.jspecify.annotations.Nullable;
2223
import org.springframework.messaging.Message;
2324

2425
/**
@@ -37,7 +38,7 @@ public interface TcpConnection<P> extends Closeable {
3738
* message was successfully sent
3839
* @since 6.0
3940
*/
40-
CompletableFuture<Void> sendAsync(Message<P> message);
41+
CompletableFuture<@Nullable Void> sendAsync(Message<P> message);
4142

4243
/**
4344
* Register a task to invoke after a period of read inactivity.

spring-messaging/src/main/java/org/springframework/messaging/tcp/TcpOperations.java

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

1717
package org.springframework.messaging.tcp;
1818

19+
import org.jspecify.annotations.Nullable;
20+
1921
import java.util.concurrent.CompletableFuture;
2022

2123
/**
@@ -34,7 +36,7 @@ public interface TcpOperations<P> {
3436
* connection is successfully established
3537
* @since 6.0
3638
*/
37-
CompletableFuture<Void> connectAsync(TcpConnectionHandler<P> connectionHandler);
39+
CompletableFuture<@Nullable Void> connectAsync(TcpConnectionHandler<P> connectionHandler);
3840

3941
/**
4042
* Open a new connection and a strategy for reconnecting if the connection fails.
@@ -44,14 +46,14 @@ public interface TcpOperations<P> {
4446
* initial connection is successfully established
4547
* @since 6.0
4648
*/
47-
CompletableFuture<Void> connectAsync(TcpConnectionHandler<P> connectionHandler, ReconnectStrategy reconnectStrategy);
49+
CompletableFuture<@Nullable Void> connectAsync(TcpConnectionHandler<P> connectionHandler, ReconnectStrategy reconnectStrategy);
4850

4951
/**
5052
* Shut down and close any open connections.
5153
* @return a CompletableFuture that can be used to determine when and if the
5254
* connection is successfully closed
5355
* @since 6.0
5456
*/
55-
CompletableFuture<Void> shutdownAsync();
57+
CompletableFuture<@Nullable Void> shutdownAsync();
5658

5759
}

spring-messaging/src/main/java/org/springframework/messaging/tcp/reactor/ReactorNettyTcpClient.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ public Log getLogger() {
172172

173173

174174
@Override
175-
public CompletableFuture<Void> connectAsync(TcpConnectionHandler<P> handler) {
175+
public CompletableFuture<@Nullable Void> connectAsync(TcpConnectionHandler<P> handler) {
176176
Assert.notNull(handler, "TcpConnectionHandler is required");
177177

178178
if (this.stopping) {
@@ -200,7 +200,7 @@ protected TcpClient extendTcpClient(TcpClient tcpClient, TcpConnectionHandler<P>
200200
}
201201

202202
@Override
203-
public CompletableFuture<Void> connectAsync(TcpConnectionHandler<P> handler, ReconnectStrategy strategy) {
203+
public CompletableFuture<@Nullable Void> connectAsync(TcpConnectionHandler<P> handler, ReconnectStrategy strategy) {
204204
Assert.notNull(handler, "TcpConnectionHandler is required");
205205
Assert.notNull(strategy, "ReconnectStrategy is required");
206206

@@ -209,7 +209,7 @@ public CompletableFuture<Void> connectAsync(TcpConnectionHandler<P> handler, Rec
209209
}
210210

211211
// Report first connect to the ListenableFuture
212-
CompletableFuture<Void> connectFuture = new CompletableFuture<>();
212+
CompletableFuture<@Nullable Void> connectFuture = new CompletableFuture<>();
213213

214214
extendTcpClient(this.tcpClient, handler)
215215
.handle(new ReactorNettyHandler(handler))
@@ -228,7 +228,7 @@ public CompletableFuture<Void> connectAsync(TcpConnectionHandler<P> handler, Rec
228228
return connectFuture;
229229
}
230230

231-
private CompletableFuture<Void> handleShuttingDownConnectFailure(TcpConnectionHandler<P> handler) {
231+
private CompletableFuture<@Nullable Void> handleShuttingDownConnectFailure(TcpConnectionHandler<P> handler) {
232232
IllegalStateException ex = new IllegalStateException("Shutting down.");
233233
handler.afterConnectFailure(ex);
234234
return Mono.<Void>error(ex).toFuture();
@@ -240,7 +240,7 @@ private Publisher<? extends Long> reconnect(Integer attempt, ReconnectStrategy r
240240
}
241241

242242
@Override
243-
public CompletableFuture<Void> shutdownAsync() {
243+
public CompletableFuture<@Nullable Void> shutdownAsync() {
244244
if (this.stopping) {
245245
return CompletableFuture.completedFuture(null);
246246
}

spring-messaging/src/main/java/org/springframework/messaging/tcp/reactor/ReactorNettyTcpConnection.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import java.util.concurrent.CompletableFuture;
2020

2121
import io.netty.buffer.ByteBuf;
22+
import org.jspecify.annotations.Nullable;
2223
import reactor.core.publisher.Mono;
2324
import reactor.core.publisher.Sinks;
2425
import reactor.netty.NettyInbound;
@@ -56,7 +57,7 @@ public ReactorNettyTcpConnection(NettyInbound inbound, NettyOutbound outbound,
5657

5758

5859
@Override
59-
public CompletableFuture<Void> sendAsync(Message<P> message) {
60+
public CompletableFuture<@Nullable Void> sendAsync(Message<P> message) {
6061
ByteBuf byteBuf = this.outbound.alloc().buffer();
6162
this.codec.encode(message, byteBuf);
6263
return this.outbound.send(Mono.just(byteBuf))

spring-webflux/src/main/java/org/springframework/web/reactive/result/method/SyncInvocableHandlerMethod.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public ParameterNameDiscoverer getParameterNameDiscoverer() {
100100
public @Nullable HandlerResult invokeForHandlerResult(ServerWebExchange exchange,
101101
BindingContext bindingContext, Object... providedArgs) {
102102

103-
CompletableFuture<HandlerResult> future =
103+
CompletableFuture<@Nullable HandlerResult> future =
104104
this.delegate.invoke(exchange, bindingContext, providedArgs).toFuture();
105105

106106
if (!future.isDone()) {

spring-websocket/src/main/java/org/springframework/web/socket/messaging/WebSocketStompClient.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,9 +387,9 @@ public boolean supportsPartialMessages() {
387387
// TcpConnection implementation
388388

389389
@Override
390-
public CompletableFuture<Void> sendAsync(Message<byte[]> message) {
390+
public CompletableFuture<@Nullable Void> sendAsync(Message<byte[]> message) {
391391
updateLastWriteTime();
392-
CompletableFuture<Void> future = new CompletableFuture<>();
392+
CompletableFuture<@Nullable Void> future = new CompletableFuture<>();
393393
try {
394394
WebSocketSession session = this.session;
395395
Assert.state(session != null, "No WebSocketSession available");

0 commit comments

Comments
 (0)