Skip to content

Enabled NullAway for the root package #1878

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

Merged
merged 2 commits into from
May 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import io.netty.handler.codec.http.HttpHeaders;
import org.asynchttpclient.handler.ProgressAsyncHandler;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -66,7 +67,7 @@ public State onTrailingHeadersReceived(HttpHeaders headers) throws Exception {
}

@Override
public final T onCompleted() throws Exception {
public final @Nullable T onCompleted() throws Exception {
return onCompleted(builder.build());
}

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

/**
* Invoked when the HTTP headers have been fully written on the I/O socket.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@
package org.asynchttpclient;


import org.jetbrains.annotations.Nullable;

/**
* Simple {@link AsyncHandler} of type {@link Response}
*/
public class AsyncCompletionHandlerBase extends AsyncCompletionHandler<Response> {
@Override
public Response onCompleted(Response response) throws Exception {
public @Nullable Response onCompleted(@Nullable Response response) throws Exception {
return response;
}
}
3 changes: 2 additions & 1 deletion client/src/main/java/org/asynchttpclient/AsyncHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import io.netty.channel.Channel;
import io.netty.handler.codec.http.HttpHeaders;
import org.asynchttpclient.netty.request.NettyRequest;
import org.jetbrains.annotations.Nullable;

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

/**
* Notify the callback before hostname resolution
Expand Down
27 changes: 14 additions & 13 deletions client/src/main/java/org/asynchttpclient/AsyncHttpClientConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.asynchttpclient.netty.channel.ConnectionSemaphoreFactory;
import org.asynchttpclient.proxy.ProxyServer;
import org.asynchttpclient.proxy.ProxyServerSelector;
import org.jetbrains.annotations.Nullable;

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

/**
* An instance of {@link ProxyServer} used by an {@link AsyncHttpClient}
Expand All @@ -173,14 +174,14 @@ public interface AsyncHttpClientConfig {
*
* @return an instance of {@link SslContext} used for SSL connection.
*/
SslContext getSslContext();
@Nullable SslContext getSslContext();

/**
* Return the current {@link Realm}
*
* @return the current {@link Realm}
*/
Realm getRealm();
@Nullable Realm getRealm();

/**
* Return the list of {@link RequestFilter}
Expand Down Expand Up @@ -259,12 +260,12 @@ public interface AsyncHttpClientConfig {
/**
* @return the array of enabled protocols
*/
String[] getEnabledProtocols();
@Nullable String[] getEnabledProtocols();

/**
* @return the array of enabled cipher suites
*/
String[] getEnabledCipherSuites();
@Nullable String[] getEnabledCipherSuites();

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

int getHandshakeTimeout();

SslEngineFactory getSslEngineFactory();
@Nullable SslEngineFactory getSslEngineFactory();

int getChunkedFileChunkSize();

Expand All @@ -309,23 +310,23 @@ public interface AsyncHttpClientConfig {

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

EventLoopGroup getEventLoopGroup();
@Nullable EventLoopGroup getEventLoopGroup();

boolean isUseNativeTransport();

boolean isUseOnlyEpollNativeTransport();

Consumer<Channel> getHttpAdditionalChannelInitializer();
@Nullable Consumer<Channel> getHttpAdditionalChannelInitializer();

Consumer<Channel> getWsAdditionalChannelInitializer();
@Nullable Consumer<Channel> getWsAdditionalChannelInitializer();

ResponseBodyPartFactory getResponseBodyPartFactory();

ChannelPool getChannelPool();
@Nullable ChannelPool getChannelPool();

ConnectionSemaphoreFactory getConnectionSemaphoreFactory();
@Nullable ConnectionSemaphoreFactory getConnectionSemaphoreFactory();

Timer getNettyTimer();
@Nullable Timer getNettyTimer();

/**
* @return the duration between tick of {@link HashedWheelTimer}
Expand Down Expand Up @@ -357,7 +358,7 @@ public interface AsyncHttpClientConfig {

int getSoRcvBuf();

ByteBufAllocator getAllocator();
@Nullable ByteBufAllocator getAllocator();

int getIoThreadsCount();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.asynchttpclient.handler.resumable.ResumableAsyncHandler;
import org.asynchttpclient.netty.channel.ChannelManager;
import org.asynchttpclient.netty.request.NettyRequestSender;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -68,7 +69,7 @@ public class DefaultAsyncHttpClient implements AsyncHttpClient {
* Default signature calculator to use for all requests constructed by this
* client instance.
*/
private SignatureCalculator signatureCalculator;
private @Nullable SignatureCalculator signatureCalculator;

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

this.config = config;
noRequestFilters = config.getRequestFilters().isEmpty();
allowStopNettyTimer = config.getNettyTimer() == null;
nettyTimer = allowStopNettyTimer ? newNettyTimer(config) : config.getNettyTimer();
final Timer configTimer = config.getNettyTimer();
if (configTimer == null) {
allowStopNettyTimer = true;
nettyTimer = newNettyTimer(config);
} else {
allowStopNettyTimer = false;
nettyTimer = configTimer;
}

channelManager = new ChannelManager(config, nettyTimer);
requestSender = new NettyRequestSender(config, channelManager, nettyTimer, new AsyncHttpClientState(closed));
Expand Down
Loading