Skip to content

Commit

Permalink
Cleanup (#1963)
Browse files Browse the repository at this point in the history
  • Loading branch information
hyperxpro committed Jun 17, 2024
1 parent 954acb1 commit 661ec72
Show file tree
Hide file tree
Showing 23 changed files with 243 additions and 198 deletions.
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 @@ -116,7 +116,8 @@ 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
*/
@Nullable T onCompleted() throws Exception;
@Nullable
T onCompleted() throws Exception;

/**
* Notify the callback before hostname resolution
Expand Down
39 changes: 26 additions & 13 deletions client/src/main/java/org/asynchttpclient/AsyncHttpClientConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ 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}
*/
@Nullable ThreadFactory getThreadFactory();
@Nullable
ThreadFactory getThreadFactory();

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

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

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

/**
* @return the array of enabled cipher suites
*/
@Nullable 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 @@ -294,7 +299,8 @@ public interface AsyncHttpClientConfig {

int getHandshakeTimeout();

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

int getChunkedFileChunkSize();

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

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

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

boolean isUseNativeTransport();

boolean isUseOnlyEpollNativeTransport();

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

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

ResponseBodyPartFactory getResponseBodyPartFactory();

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

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

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

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

int getSoRcvBuf();

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

int getIoThreadsCount();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
import org.asynchttpclient.channel.ChannelPool;
import org.asynchttpclient.cookie.CookieEvictionTask;
import org.asynchttpclient.cookie.CookieStore;
import org.asynchttpclient.filter.FilterContext;
import org.asynchttpclient.exception.FilterException;
import org.asynchttpclient.filter.FilterContext;
import org.asynchttpclient.filter.RequestFilter;
import org.asynchttpclient.handler.resumable.ResumableAsyncHandler;
import org.asynchttpclient.netty.channel.ChannelManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package org.asynchttpclient;

import io.netty.buffer.ByteBuf;

import java.nio.ByteBuffer;

/**
Expand Down
42 changes: 28 additions & 14 deletions client/src/main/java/org/asynchttpclient/Request.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,14 @@ public interface Request {
/**
* @return the InetAddress to be used to bypass uri's hostname resolution
*/
@Nullable InetAddress getAddress();
@Nullable
InetAddress getAddress();

/**
* @return the local address to bind from
*/
@Nullable InetAddress getLocalAddress();
@Nullable
InetAddress getLocalAddress();

/**
* @return the HTTP headers
Expand All @@ -92,32 +94,38 @@ public interface Request {
/**
* @return the request's body array of byte arrays (only non-null if it was set this way)
*/
@Nullable List<byte[]> getCompositeByteData();
@Nullable
List<byte[]> getCompositeByteData();

/**
* @return the request's body string (only non-null if it was set this way)
*/
@Nullable String getStringData();
@Nullable
String getStringData();

/**
* @return the request's body ByteBuffer (only non-null if it was set this way)
*/
@Nullable ByteBuffer getByteBufferData();
@Nullable
ByteBuffer getByteBufferData();

/**
* @return the request's body ByteBuf (only non-null if it was set this way)
*/
@Nullable ByteBuf getByteBufData();
@Nullable
ByteBuf getByteBufData();

/**
* @return the request's body InputStream (only non-null if it was set this way)
*/
@Nullable InputStream getStreamData();
@Nullable
InputStream getStreamData();

/**
* @return the request's body BodyGenerator (only non-null if it was set this way)
*/
@Nullable BodyGenerator getBodyGenerator();
@Nullable
BodyGenerator getBodyGenerator();

/**
* @return the request's form parameters
Expand All @@ -132,7 +140,8 @@ public interface Request {
/**
* @return the virtual host to connect to
*/
@Nullable String getVirtualHost();
@Nullable
String getVirtualHost();

/**
* @return the query params resolved from the url/uri
Expand All @@ -142,22 +151,26 @@ public interface Request {
/**
* @return the proxy server to be used to perform this request (overrides the one defined in config)
*/
@Nullable ProxyServer getProxyServer();
@Nullable
ProxyServer getProxyServer();

/**
* @return the realm to be used to perform this request (overrides the one defined in config)
*/
@Nullable Realm getRealm();
@Nullable
Realm getRealm();

/**
* @return the file to be uploaded
*/
@Nullable File getFile();
@Nullable
File getFile();

/**
* @return if this request is to follow redirects. Non null values means "override config value".
*/
@Nullable Boolean getFollowRedirect();
@Nullable
Boolean getFollowRedirect();

/**
* @return the request timeout. Non zero values means "override config value".
Expand All @@ -177,7 +190,8 @@ public interface Request {
/**
* @return the charset value used when decoding the request's body.
*/
@Nullable Charset getCharset();
@Nullable
Charset getCharset();

/**
* @return the strategy to compute ChannelPool's keys
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ public interface ChannelPool {
* @param partitionKey the partition used when invoking offer
* @return the channel associated with the uri
*/
@Nullable Channel poll(Object partitionKey);
@Nullable
Channel poll(Object partitionKey);

/**
* Remove all channels from the cache. A channel might have been associated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public enum NoopChannelPool implements ChannelPool {
INSTANCE;

/**
*
* @return always false since this is a {@link NoopChannelPool}
*/
@Override
Expand All @@ -39,7 +38,6 @@ public boolean offer(Channel channel, Object partitionKey) {
}

/**
*
* @return always null since this is a {@link NoopChannelPool}
*/
@Override
Expand All @@ -48,7 +46,6 @@ public boolean offer(Channel channel, Object partitionKey) {
}

/**
*
* @return always false since this is a {@link NoopChannelPool}
*/
@Override
Expand All @@ -57,7 +54,6 @@ public boolean removeAll(Channel channel) {
}

/**
*
* @return always true since this is a {@link NoopChannelPool}
*/
@Override
Expand All @@ -66,23 +62,20 @@ public boolean isOpen() {
}

/**
*
* Does nothing since this is a {@link NoopChannelPool}
*/
@Override
public void destroy() {
}

/**
*
* Does nothing since this is a {@link NoopChannelPool}
*/
@Override
public void flushPartitions(Predicate<Object> predicate) {
}

/**
*
* @return always {@link Collections#emptyMap()} since this is a {@link NoopChannelPool}
*/
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ private void removeExpired() {

cookieJar.values()
.forEach(cookieMap -> removed[0] |= cookieMap.entrySet()
.removeIf(v -> hasCookieExpired(v.getValue().cookie, v.getValue().createdAt)));
.removeIf(v -> hasCookieExpired(v.getValue().cookie, v.getValue().createdAt)));

if (removed[0]) {
cookieJar.entrySet().removeIf(entry -> entry.getValue() == null || entry.getValue().isEmpty());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
import org.asynchttpclient.AsyncHandler;
import org.asynchttpclient.AsyncHttpClientConfig;
import org.asynchttpclient.HttpResponseStatus;
import org.asynchttpclient.filter.FilterContext;
import org.asynchttpclient.exception.FilterException;
import org.asynchttpclient.filter.FilterContext;
import org.asynchttpclient.filter.ResponseFilter;
import org.asynchttpclient.netty.NettyResponseFuture;
import org.asynchttpclient.netty.request.NettyRequestSender;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@
import org.asynchttpclient.Realm;
import org.asynchttpclient.Realm.AuthScheme;
import org.asynchttpclient.Request;
import org.asynchttpclient.exception.FilterException;
import org.asynchttpclient.exception.PoolAlreadyClosedException;
import org.asynchttpclient.exception.RemotelyClosedException;
import org.asynchttpclient.filter.FilterContext;
import org.asynchttpclient.exception.FilterException;
import org.asynchttpclient.filter.IOExceptionFilter;
import org.asynchttpclient.handler.TransferCompletionHandler;
import org.asynchttpclient.netty.NettyResponseFuture;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1083,7 +1083,8 @@ byte[] getChallenge() {
/**
* Retrieve the target
*/
@Nullable String getTarget() {
@Nullable
String getTarget() {
return target;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,6 @@ public interface ProxyServerSelector {
* @param uri The URI to select a proxy server for.
* @return The proxy server to use, if any. May return null.
*/
@Nullable ProxyServer select(Uri uri);
@Nullable
ProxyServer select(Uri uri);
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.server.handler.AbstractHandler;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.extension.ExtendWith;
import org.slf4j.Logger;
Expand Down
Loading

0 comments on commit 661ec72

Please sign in to comment.