Skip to content

Commit 1070093

Browse files
authored
Enabled NullAway for the root package (#1878)
* Enabled NullAway for the root package
1 parent b36e82f commit 1070093

15 files changed

+339
-235
lines changed

client/src/main/java/org/asynchttpclient/AsyncCompletionHandler.java

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

1919
import io.netty.handler.codec.http.HttpHeaders;
2020
import org.asynchttpclient.handler.ProgressAsyncHandler;
21+
import org.jetbrains.annotations.Nullable;
2122
import org.slf4j.Logger;
2223
import org.slf4j.LoggerFactory;
2324

@@ -66,7 +67,7 @@ public State onTrailingHeadersReceived(HttpHeaders headers) throws Exception {
6667
}
6768

6869
@Override
69-
public final T onCompleted() throws Exception {
70+
public final @Nullable T onCompleted() throws Exception {
7071
return onCompleted(builder.build());
7172
}
7273

@@ -83,7 +84,7 @@ public void onThrowable(Throwable t) {
8384
* {@link Future}
8485
* @throws Exception if something wrong happens
8586
*/
86-
public abstract T onCompleted(Response response) throws Exception;
87+
public abstract @Nullable T onCompleted(@Nullable Response response) throws Exception;
8788

8889
/**
8990
* Invoked when the HTTP headers have been fully written on the I/O socket.

client/src/main/java/org/asynchttpclient/AsyncCompletionHandlerBase.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@
1717
package org.asynchttpclient;
1818

1919

20+
import org.jetbrains.annotations.Nullable;
21+
2022
/**
2123
* Simple {@link AsyncHandler} of type {@link Response}
2224
*/
2325
public class AsyncCompletionHandlerBase extends AsyncCompletionHandler<Response> {
2426
@Override
25-
public Response onCompleted(Response response) throws Exception {
27+
public @Nullable Response onCompleted(@Nullable Response response) throws Exception {
2628
return response;
2729
}
2830
}

client/src/main/java/org/asynchttpclient/AsyncHandler.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import io.netty.channel.Channel;
1919
import io.netty.handler.codec.http.HttpHeaders;
2020
import org.asynchttpclient.netty.request.NettyRequest;
21+
import org.jetbrains.annotations.Nullable;
2122

2223
import javax.net.ssl.SSLSession;
2324
import java.net.InetSocketAddress;
@@ -115,7 +116,7 @@ default State onTrailingHeadersReceived(HttpHeaders headers) throws Exception {
115116
* @return T Value that will be returned by the associated {@link Future}
116117
* @throws Exception if something wrong happens
117118
*/
118-
T onCompleted() throws Exception;
119+
@Nullable T onCompleted() throws Exception;
119120

120121
/**
121122
* Notify the callback before hostname resolution

client/src/main/java/org/asynchttpclient/AsyncHttpClientConfig.java

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import org.asynchttpclient.netty.channel.ConnectionSemaphoreFactory;
3535
import org.asynchttpclient.proxy.ProxyServer;
3636
import org.asynchttpclient.proxy.ProxyServerSelector;
37+
import org.jetbrains.annotations.Nullable;
3738

3839
import java.io.IOException;
3940
import java.time.Duration;
@@ -159,7 +160,7 @@ public interface AsyncHttpClientConfig {
159160
* @return the {@link ThreadFactory} an {@link AsyncHttpClient} use for handling asynchronous response. If no {@link ThreadFactory} has been explicitly
160161
* provided, this method will return {@code null}
161162
*/
162-
ThreadFactory getThreadFactory();
163+
@Nullable ThreadFactory getThreadFactory();
163164

164165
/**
165166
* An instance of {@link ProxyServer} used by an {@link AsyncHttpClient}
@@ -173,14 +174,14 @@ public interface AsyncHttpClientConfig {
173174
*
174175
* @return an instance of {@link SslContext} used for SSL connection.
175176
*/
176-
SslContext getSslContext();
177+
@Nullable SslContext getSslContext();
177178

178179
/**
179180
* Return the current {@link Realm}
180181
*
181182
* @return the current {@link Realm}
182183
*/
183-
Realm getRealm();
184+
@Nullable Realm getRealm();
184185

185186
/**
186187
* Return the list of {@link RequestFilter}
@@ -259,12 +260,12 @@ public interface AsyncHttpClientConfig {
259260
/**
260261
* @return the array of enabled protocols
261262
*/
262-
String[] getEnabledProtocols();
263+
@Nullable String[] getEnabledProtocols();
263264

264265
/**
265266
* @return the array of enabled cipher suites
266267
*/
267-
String[] getEnabledCipherSuites();
268+
@Nullable String[] getEnabledCipherSuites();
268269

269270
/**
270271
* @return if insecure cipher suites must be filtered out (only used when not explicitly passing enabled cipher suites)
@@ -293,7 +294,7 @@ public interface AsyncHttpClientConfig {
293294

294295
int getHandshakeTimeout();
295296

296-
SslEngineFactory getSslEngineFactory();
297+
@Nullable SslEngineFactory getSslEngineFactory();
297298

298299
int getChunkedFileChunkSize();
299300

@@ -309,23 +310,23 @@ public interface AsyncHttpClientConfig {
309310

310311
Map<ChannelOption<Object>, Object> getChannelOptions();
311312

312-
EventLoopGroup getEventLoopGroup();
313+
@Nullable EventLoopGroup getEventLoopGroup();
313314

314315
boolean isUseNativeTransport();
315316

316317
boolean isUseOnlyEpollNativeTransport();
317318

318-
Consumer<Channel> getHttpAdditionalChannelInitializer();
319+
@Nullable Consumer<Channel> getHttpAdditionalChannelInitializer();
319320

320-
Consumer<Channel> getWsAdditionalChannelInitializer();
321+
@Nullable Consumer<Channel> getWsAdditionalChannelInitializer();
321322

322323
ResponseBodyPartFactory getResponseBodyPartFactory();
323324

324-
ChannelPool getChannelPool();
325+
@Nullable ChannelPool getChannelPool();
325326

326-
ConnectionSemaphoreFactory getConnectionSemaphoreFactory();
327+
@Nullable ConnectionSemaphoreFactory getConnectionSemaphoreFactory();
327328

328-
Timer getNettyTimer();
329+
@Nullable Timer getNettyTimer();
329330

330331
/**
331332
* @return the duration between tick of {@link HashedWheelTimer}
@@ -357,7 +358,7 @@ public interface AsyncHttpClientConfig {
357358

358359
int getSoRcvBuf();
359360

360-
ByteBufAllocator getAllocator();
361+
@Nullable ByteBufAllocator getAllocator();
361362

362363
int getIoThreadsCount();
363364

client/src/main/java/org/asynchttpclient/DefaultAsyncHttpClient.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.asynchttpclient.handler.resumable.ResumableAsyncHandler;
3131
import org.asynchttpclient.netty.channel.ChannelManager;
3232
import org.asynchttpclient.netty.request.NettyRequestSender;
33+
import org.jetbrains.annotations.Nullable;
3334
import org.slf4j.Logger;
3435
import org.slf4j.LoggerFactory;
3536

@@ -68,7 +69,7 @@ public class DefaultAsyncHttpClient implements AsyncHttpClient {
6869
* Default signature calculator to use for all requests constructed by this
6970
* client instance.
7071
*/
71-
private SignatureCalculator signatureCalculator;
72+
private @Nullable SignatureCalculator signatureCalculator;
7273

7374
/**
7475
* Create a new HTTP Asynchronous Client using the default
@@ -95,8 +96,14 @@ public DefaultAsyncHttpClient(AsyncHttpClientConfig config) {
9596

9697
this.config = config;
9798
noRequestFilters = config.getRequestFilters().isEmpty();
98-
allowStopNettyTimer = config.getNettyTimer() == null;
99-
nettyTimer = allowStopNettyTimer ? newNettyTimer(config) : config.getNettyTimer();
99+
final Timer configTimer = config.getNettyTimer();
100+
if (configTimer == null) {
101+
allowStopNettyTimer = true;
102+
nettyTimer = newNettyTimer(config);
103+
} else {
104+
allowStopNettyTimer = false;
105+
nettyTimer = configTimer;
106+
}
100107

101108
channelManager = new ChannelManager(config, nettyTimer);
102109
requestSender = new NettyRequestSender(config, channelManager, nettyTimer, new AsyncHttpClientState(closed));

0 commit comments

Comments
 (0)