Skip to content
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

Minor cleanups #1899

Merged
merged 1 commit into from
Sep 3, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public State onHeadersWritten() {
}

/**
* Invoked when the content (a {@link File}, {@link String} or
* Invoked when the content (a {@link File}, {@link String}) or
* {@link InputStream} has been fully written on the I/O socket.
*
* @return a {@link AsyncHandler.State} telling to CONTINUE
Expand Down
4 changes: 2 additions & 2 deletions client/src/main/java/org/asynchttpclient/AsyncHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
* <p>
* Do NOT perform any blocking operations in any of these methods. A typical example would be trying to send another
* request and calling get() on its future.
* There's a chance you might end up in a dead lock.
* There's a chance you might end up in a deadlock.
* If you really need to perform a blocking operation, execute it in a different dedicated thread pool.
*
* @param <T> Type of object returned by the {@link Future#get}
Expand Down Expand Up @@ -151,7 +151,7 @@ default void onHostnameResolutionFailure(String name, Throwable cause) {
/**
* Notify the callback when trying to open a new connection.
* <p>
* Might be called several times if the name was resolved to multiple addresses and we failed to connect to the first(s) one(s).
* Might be called several times if the name was resolved to multiple addresses, and we failed to connect to the first(s) one(s).
*
* @param remoteAddress the address we try to connect to
*/
Expand Down
22 changes: 11 additions & 11 deletions client/src/main/java/org/asynchttpclient/AsyncHttpClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
* The {@link AsyncCompletionHandler#onCompleted(Response)} method will be invoked once the http response has been fully read.
* The {@link Response} object includes the http headers and the response body. Note that the entire response will be buffered in memory.
* <br>
* You can also have more control about the how the response is asynchronously processed by using an {@link AsyncHandler}
* You can also have more control about how the response is asynchronously processed by using an {@link AsyncHandler}
* <blockquote><pre>
* AsyncHttpClient c = new AsyncHttpClient();
* Future&lt;String&gt; f = c.prepareGet(TARGET_URL).execute(new AsyncHandler&lt;String&gt;() &#123;
Expand Down Expand Up @@ -149,7 +149,7 @@ public interface AsyncHttpClient extends Closeable {
* Prepare an HTTP client request.
*
* @param method HTTP request method type. MUST BE in upper case
* @param url A well formed URL.
* @param url A well-formed URL.
* @return {@link RequestBuilder}
*/
BoundRequestBuilder prepare(String method, String url);
Expand All @@ -158,71 +158,71 @@ public interface AsyncHttpClient extends Closeable {
/**
* Prepare an HTTP client GET request.
*
* @param url A well formed URL.
* @param url A well-formed URL.
* @return {@link RequestBuilder}
*/
BoundRequestBuilder prepareGet(String url);

/**
* Prepare an HTTP client CONNECT request.
*
* @param url A well formed URL.
* @param url A well-formed URL.
* @return {@link RequestBuilder}
*/
BoundRequestBuilder prepareConnect(String url);

/**
* Prepare an HTTP client OPTIONS request.
*
* @param url A well formed URL.
* @param url A well-formed URL.
* @return {@link RequestBuilder}
*/
BoundRequestBuilder prepareOptions(String url);

/**
* Prepare an HTTP client HEAD request.
*
* @param url A well formed URL.
* @param url A well-formed URL.
* @return {@link RequestBuilder}
*/
BoundRequestBuilder prepareHead(String url);

/**
* Prepare an HTTP client POST request.
*
* @param url A well formed URL.
* @param url A well-formed URL.
* @return {@link RequestBuilder}
*/
BoundRequestBuilder preparePost(String url);

/**
* Prepare an HTTP client PUT request.
*
* @param url A well formed URL.
* @param url A well-formed URL.
* @return {@link RequestBuilder}
*/
BoundRequestBuilder preparePut(String url);

/**
* Prepare an HTTP client DELETE request.
*
* @param url A well formed URL.
* @param url A well-formed URL.
* @return {@link RequestBuilder}
*/
BoundRequestBuilder prepareDelete(String url);

/**
* Prepare an HTTP client PATCH request.
*
* @param url A well formed URL.
* @param url A well-formed URL.
* @return {@link RequestBuilder}
*/
BoundRequestBuilder preparePatch(String url);

/**
* Prepare an HTTP client TRACE request.
*
* @param url A well formed URL.
* @param url A well-formed URL.
* @return {@link RequestBuilder}
*/
BoundRequestBuilder prepareTrace(String url);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ public interface AsyncHttpClientConfig {
boolean isDisableUrlEncodingForBoundRequests();

/**
* @return true if AHC is to use a LAX cookie encoder, eg accept illegal chars in cookie value
* @return true if AHC is to use a LAX cookie encoder, e.g. accept illegal chars in cookie value
*/
boolean isUseLaxCookieEncoder();

Expand Down
2 changes: 1 addition & 1 deletion client/src/main/java/org/asynchttpclient/ClientStats.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import java.util.Objects;

/**
* A record class representing the state of an (@link org.asynchttpclient.AsyncHttpClient).
* A record class representing the state of a (@link org.asynchttpclient.AsyncHttpClient).
*/
public class ClientStats {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import org.asynchttpclient.cookie.CookieEvictionTask;
import org.asynchttpclient.cookie.CookieStore;
import org.asynchttpclient.filter.FilterContext;
import org.asynchttpclient.filter.FilterException;
import org.asynchttpclient.exception.FilterException;
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 @@ -978,7 +978,7 @@ public Builder setStrict302Handling(final boolean strict302Handling) {

/**
* If true, AHC will add Accept-Encoding HTTP header to each request
*
* <p>
* If false (default), AHC will either leave AcceptEncoding header as is
* (if enableAutomaticDecompression is false) or will remove unsupported
* algorithms (if enableAutomaticDecompression is true)
Expand All @@ -988,7 +988,6 @@ public Builder setCompressionEnforced(boolean compressionEnforced) {
return this;
}


/*
* If true (default), AHC will add a Netty HttpContentDecompressor, so compressed
* content will automatically get decompressed.
Expand All @@ -997,7 +996,7 @@ public Builder setCompressionEnforced(boolean compressionEnforced) {
* be done by calling code.
*/
public Builder setEnableAutomaticDecompression(boolean enable) {
this.enableAutomaticDecompression = enable;
enableAutomaticDecompression = enable;
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import java.net.SocketAddress;

/**
* A class that represent the HTTP response' status line (code + text)
* A class that represent the HTTP response status line (code + text)
*/
public abstract class HttpResponseStatus {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public interface ListenableFuture<V> extends Future<V> {
* in the thread where completion happens.
* <br>
* There is no guaranteed ordering of execution of listeners, they may get
* called in the order they were added and they may get called out of order,
* called in the order they were added, and they may get called out of order,
* but any listener added through this method is guaranteed to be called once
* the computation is complete.
*
Expand Down
14 changes: 7 additions & 7 deletions client/src/main/java/org/asynchttpclient/Request.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,32 +84,32 @@ public interface Request {
List<Cookie> getCookies();

/**
* @return the request's body byte array (only non null if it was set this way)
* @return the request's body byte array (only non-null if it was set this way)
*/
byte @Nullable [] getByteData();

/**
* @return the request's body array of byte arrays (only non null if it was set this way)
* @return the request's body array of byte arrays (only non-null if it was set this way)
*/
@Nullable List<byte[]> getCompositeByteData();

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

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

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

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

Expand Down Expand Up @@ -159,7 +159,7 @@ public interface Request {
Duration getRequestTimeout();

/**
* @return the read timeout. Non zero values means "override config value".
* @return the read timeout. Non-zero values means "override config value".
*/
Duration getReadTimeout();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ public T addHeader(CharSequence name, String value) {
}

/**
* Add a header value for the request. If a header with {@code name} was setup for this request already -
* Add a header value for the request. If a header with {@code name} was set up for this request already -
* call will add one more header value and convert it to multi-value header
*
* @param name header name
Expand All @@ -244,7 +244,7 @@ public T addHeader(CharSequence name, Object value) {
}

/**
* Add header values for the request. If a header with {@code name} was setup for this request already -
* Add header values for the request. If a header with {@code name} was set up for this request already -
* call will add more header values and convert it to multi-value header
*
* @param name header name
Expand All @@ -267,7 +267,7 @@ public T setHeaders(HttpHeaders headers) {

/**
* Set request headers using a map {@code headers} of pair (Header name, Header values)
* This method could be used to setup multi-valued headers
* This method could be used to set up multivalued headers
*
* @param headers map of header names as the map keys and header values {@link Iterable} as the map values
* @return {@code this}
Expand Down Expand Up @@ -559,7 +559,7 @@ private RequestBuilderBase<?> executeSignatureCalculator() {

// build a first version of the request, without signatureCalculator in play
RequestBuilder rb = new RequestBuilder(method);
// make copy of mutable collections so we don't risk affecting
// make copy of mutable collections, so we don't risk affecting
// original RequestBuilder
// call setFormParams first as it resets other fields
if (formParams != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
*/
@FunctionalInterface
public interface SignatureCalculator {

/**
* Method called when {@link RequestBuilder#build} method is called.
* Should first calculate signature information and then modify request
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public interface ChannelPool {
boolean removeAll(Channel channel);

/**
* Return true if a channel can be cached. A implementation can decide based
* Return true if a channel can be cached. An implementation can decide based
* on some rules to allow caching Calling this method is equivalent of
* checking the returned value of {@link ChannelPool#offer(Channel, Object)}
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ class CompositePartitionKey {
private final int proxyPort;
private final @Nullable ProxyType proxyType;

CompositePartitionKey(String targetHostBaseUrl, @Nullable String virtualHost,
@Nullable String proxyHost, int proxyPort, @Nullable ProxyType proxyType) {
CompositePartitionKey(String targetHostBaseUrl, @Nullable String virtualHost, @Nullable String proxyHost, int proxyPort, @Nullable ProxyType proxyType) {
this.targetHostBaseUrl = targetHostBaseUrl;
this.virtualHost = virtualHost;
this.proxyHost = proxyHost;
Expand Down Expand Up @@ -102,12 +101,7 @@ public boolean equals(Object o) {

@Override
public int hashCode() {
int result = targetHostBaseUrl != null ? targetHostBaseUrl.hashCode() : 0;
result = 31 * result + (virtualHost != null ? virtualHost.hashCode() : 0);
result = 31 * result + (proxyHost != null ? proxyHost.hashCode() : 0);
result = 31 * result + proxyPort;
result = 31 * result + (proxyType != null ? proxyType.hashCode() : 0);
return result;
return Objects.hash(targetHostBaseUrl, virtualHost, proxyHost, proxyPort, proxyType);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@

public final class AsyncHttpClientConfigHelper {

private static volatile @Nullable Config config;
@Nullable
private static volatile Config config;

private AsyncHttpClientConfigHelper() {
}
Expand Down Expand Up @@ -93,7 +94,8 @@ public String getString(String key) {
});
}

public @Nullable String[] getStringArray(String key) {
@Nullable
public String[] getStringArray(String key) {
String s = getString(key);
s = s.trim();
if (s.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,21 @@
* @since 2.1
*/
public interface CookieStore extends Counted {

/**
* Adds one {@link Cookie} to the store. This is called for every incoming HTTP response.
* If the given cookie has already expired it will not be added.
*
* <p>A cookie to store may or may not be associated with an URI. If it
* is not associated with an URI, the cookie's domain and path attribute
* will indicate where it comes from. If it is associated with an URI and
* <p>A cookie to store may or may not be associated with a URI. If it
* is not associated with a URI, the cookie's domain and path attribute
* will indicate where it comes from. If it is associated with a URI and
* its domain and path attribute are not specified, given URI will indicate
* where this cookie comes from.
*
* <p>If a cookie corresponding to the given URI already exists,
* then it is replaced with the new one.
*
* @param uri the {@link Uri uri} this cookie associated with. if {@code null}, this cookie will not be associated with an URI
* @param uri the {@link Uri uri} this cookie associated with. if {@code null}, this cookie will not be associated with a URI
* @param cookie the {@link Cookie cookie} to be added
*/
void add(Uri uri, Cookie cookie);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ public List<Cookie> get(Uri uri) {

@Override
public List<Cookie> getAll() {
return cookieJar
.values()
return cookieJar.values()
.stream()
.flatMap(map -> map.values().stream())
.filter(pair -> !hasCookieExpired(pair.cookie, pair.createdAt))
Expand Down Expand Up @@ -260,10 +259,7 @@ public boolean equals(Object obj) {

@Override
public int hashCode() {
int result = 17;
result = 31 * result + name.hashCode();
result = 31 * result + path.hashCode();
return result;
return Objects.hash(name, path);
}

@Override
Expand Down