Skip to content

Commit b39f321

Browse files
committed
Update to NullAway 0.12.15 and fix new warnings
Signed-off-by: Manu Sridharan <[email protected]>
1 parent 0b2bb7e commit b39f321

File tree

9 files changed

+29
-19
lines changed

9 files changed

+29
-19
lines changed

gradle/spring-module.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ tasks.register('javadocJar', Jar) {
105105
from javadoc
106106
}
107107

108+
nullability {
109+
nullAwayVersion = "0.12.15"
110+
}
111+
108112
publishing {
109113
publications {
110114
mavenJava(MavenPublication) {

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: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import java.io.Closeable;
2020
import java.util.concurrent.CompletableFuture;
2121

22+
import org.jspecify.annotations.Nullable;
23+
2224
import org.springframework.messaging.Message;
2325

2426
/**
@@ -37,7 +39,7 @@ public interface TcpConnection<P> extends Closeable {
3739
* message was successfully sent
3840
* @since 6.0
3941
*/
40-
CompletableFuture<Void> sendAsync(Message<P> message);
42+
CompletableFuture<@Nullable Void> sendAsync(Message<P> message);
4143

4244
/**
4345
* Register a task to invoke after a period of read inactivity.

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818

1919
import java.util.concurrent.CompletableFuture;
2020

21+
import org.jspecify.annotations.Nullable;
22+
23+
2124
/**
2225
* A contract for establishing TCP connections.
2326
*
@@ -34,7 +37,7 @@ public interface TcpOperations<P> {
3437
* connection is successfully established
3538
* @since 6.0
3639
*/
37-
CompletableFuture<Void> connectAsync(TcpConnectionHandler<P> connectionHandler);
40+
CompletableFuture<@Nullable Void> connectAsync(TcpConnectionHandler<P> connectionHandler);
3841

3942
/**
4043
* Open a new connection and a strategy for reconnecting if the connection fails.
@@ -44,14 +47,14 @@ public interface TcpOperations<P> {
4447
* initial connection is successfully established
4548
* @since 6.0
4649
*/
47-
CompletableFuture<Void> connectAsync(TcpConnectionHandler<P> connectionHandler, ReconnectStrategy reconnectStrategy);
50+
CompletableFuture<@Nullable Void> connectAsync(TcpConnectionHandler<P> connectionHandler, ReconnectStrategy reconnectStrategy);
4851

4952
/**
5053
* Shut down and close any open connections.
5154
* @return a CompletableFuture that can be used to determine when and if the
5255
* connection is successfully closed
5356
* @since 6.0
5457
*/
55-
CompletableFuture<Void> shutdownAsync();
58+
CompletableFuture<@Nullable Void> shutdownAsync();
5659

5760
}

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)