Skip to content

Commit 08782a5

Browse files
author
Stephane Landelle
committed
Format with 140 chars lines
1 parent 272144e commit 08782a5

File tree

87 files changed

+699
-655
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+699
-655
lines changed

api/src/main/java/org/asynchttpclient/AsyncHandlerExtensions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public interface AsyncHandlerExtensions {
3434
* Currently only supported by the Netty provider.
3535
*/
3636
void onRequestSent();
37-
37+
3838
/**
3939
* Notify the callback every time a request is being retried.
4040
*/

api/src/main/java/org/asynchttpclient/AsyncHttpClient.java

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,9 @@ public class AsyncHttpClient implements Closeable {
149149
* Providers that will be searched for, on the classpath, in order when no
150150
* provider is explicitly specified by the developer.
151151
*/
152-
private static final String[] DEFAULT_PROVIDERS = {
153-
"org.asynchttpclient.providers.netty.NettyAsyncHttpProvider",
154-
"org.asynchttpclient.providers.grizzly.GrizzlyAsyncHttpProvider"
152+
private static final String[] DEFAULT_PROVIDERS = {//
153+
"org.asynchttpclient.providers.netty.NettyAsyncHttpProvider",/**/
154+
"org.asynchttpclient.providers.grizzly.GrizzlyAsyncHttpProvider"//
155155
};
156156

157157
private final AsyncHttpProvider httpProvider;
@@ -174,7 +174,6 @@ public class AsyncHttpClient implements Closeable {
174174
* <ul>
175175
* <li>netty</li>
176176
* <li>grizzly</li>
177-
* <li>JDK</li>
178177
* </ul>
179178
*
180179
* If none of those providers are found, then the engine will throw an IllegalStateException.
@@ -367,7 +366,6 @@ public BoundRequestBuilder setSignatureCalculator(SignatureCalculator signatureC
367366
}
368367
}
369368

370-
371369
/**
372370
* Return the asynchronous {@link AsyncHttpProvider}
373371
*
@@ -565,7 +563,8 @@ public <T> ListenableFuture<T> executeRequest(Request request, AsyncHandler<T> h
565563
* @throws IOException
566564
*/
567565
public ListenableFuture<Response> executeRequest(Request request) throws IOException {
568-
FilterContext<Response> fc = new FilterContext.FilterContextBuilder<Response>().asyncHandler(new AsyncCompletionHandlerBase()).request(request).build();
566+
FilterContext<Response> fc = new FilterContext.FilterContextBuilder<Response>().asyncHandler(new AsyncCompletionHandlerBase())
567+
.request(request).build();
569568
fc = preProcessRequest(fc);
570569
return httpProvider.execute(fc.getRequest(), fc.getAsyncHandler());
571570
}
@@ -577,7 +576,7 @@ public ListenableFuture<Response> executeRequest(Request request) throws IOExcep
577576
* @return {@link FilterContext}
578577
*/
579578
private <T> FilterContext<T> preProcessRequest(FilterContext<T> fc) throws IOException {
580-
for (RequestFilter asyncFilter: config.getRequestFilters()) {
579+
for (RequestFilter asyncFilter : config.getRequestFilters()) {
581580
try {
582581
fc = asyncFilter.filter(fc);
583582
if (fc == null) {
@@ -605,36 +604,31 @@ private <T> FilterContext<T> preProcessRequest(FilterContext<T> fc) throws IOExc
605604
}
606605

607606
@SuppressWarnings("unchecked")
608-
private static AsyncHttpProvider loadProvider(final String className,
609-
final AsyncHttpClientConfig config) {
607+
private static AsyncHttpProvider loadProvider(final String className, final AsyncHttpClientConfig config) {
610608
try {
611-
Class<AsyncHttpProvider> providerClass = (Class<AsyncHttpProvider>) Thread.currentThread()
612-
.getContextClassLoader().loadClass(className);
613-
return providerClass.getDeclaredConstructor(
614-
new Class[]{AsyncHttpClientConfig.class}).newInstance(config);
615-
} catch (Throwable t) {
609+
Class<AsyncHttpProvider> providerClass = (Class<AsyncHttpProvider>) Thread.currentThread().getContextClassLoader()
610+
.loadClass(className);
611+
return providerClass.getDeclaredConstructor(new Class[] { AsyncHttpClientConfig.class }).newInstance(config);
612+
} catch (Throwable t) {
616613
if (t instanceof InvocationTargetException) {
617614
final InvocationTargetException ite = (InvocationTargetException) t;
618615
if (logger.isErrorEnabled()) {
619-
logger.error("Unable to instantiate provider {}. Trying other providers.",
620-
className);
616+
logger.error("Unable to instantiate provider {}. Trying other providers.", className);
621617
logger.error(ite.getCause().toString(), ite.getCause());
622618
}
623619
}
624620
// Let's try with another classloader
625621
try {
626-
Class<AsyncHttpProvider> providerClass = (Class<AsyncHttpProvider>)
627-
AsyncHttpClient.class.getClassLoader().loadClass(className);
628-
return providerClass.getDeclaredConstructor(
629-
new Class[]{AsyncHttpClientConfig.class}).newInstance(config);
622+
Class<AsyncHttpProvider> providerClass = (Class<AsyncHttpProvider>) AsyncHttpClient.class.getClassLoader().loadClass(
623+
className);
624+
return providerClass.getDeclaredConstructor(new Class[] { AsyncHttpClientConfig.class }).newInstance(config);
630625
} catch (Throwable ignored) {
631626
}
632627
}
633628
return null;
634629
}
635630

636-
private static AsyncHttpProvider loadDefaultProvider(String[] providerClassNames,
637-
AsyncHttpClientConfig config) {
631+
private static AsyncHttpProvider loadDefaultProvider(String[] providerClassNames, AsyncHttpClientConfig config) {
638632
AsyncHttpProvider provider;
639633
for (final String className : providerClassNames) {
640634
provider = loadProvider(className, config);

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,8 @@ public static class Builder {
566566
private int defaultMaxConnectionPerHost = Integer.getInteger(ASYNC_CLIENT + "defaultMaxConnectionsPerHost", -1);
567567
private int defaultConnectionTimeOutInMs = Integer.getInteger(ASYNC_CLIENT + "defaultConnectionTimeoutInMS", 60 * 1000);
568568
private int defaultWebsocketIdleTimeoutInMs = Integer.getInteger(ASYNC_CLIENT + "defaultWebsocketTimoutInMS", 15 * 60 * 1000);
569-
private int defaultIdleConnectionInPoolTimeoutInMs = Integer.getInteger(ASYNC_CLIENT + "defaultIdleConnectionInPoolTimeoutInMS", 60 * 1000);
569+
private int defaultIdleConnectionInPoolTimeoutInMs = Integer.getInteger(ASYNC_CLIENT + "defaultIdleConnectionInPoolTimeoutInMS",
570+
60 * 1000);
570571
private int defaultIdleConnectionTimeoutInMs = Integer.getInteger(ASYNC_CLIENT + "defaultIdleConnectionTimeoutInMS", 60 * 1000);
571572
private int defaultRequestTimeoutInMs = Integer.getInteger(ASYNC_CLIENT + "defaultRequestTimeoutInMS", 60 * 1000);
572573
private int defaultMaxConnectionLifeTimeInMs = Integer.getInteger(ASYNC_CLIENT + "defaultMaxConnectionLifeTimeInMs", -1);

api/src/main/java/org/asynchttpclient/AsyncHttpClientConfigBean.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import java.util.concurrent.ThreadFactory;
2828

2929
/**
30-
* Simple JavaBean version of {@link AsyncHttpClientConfig}
30+
* Simple JavaBean version of {@link AsyncHttpClientConfig}
3131
*/
3232
public class AsyncHttpClientConfigBean extends AsyncHttpClientConfig {
3333

@@ -55,7 +55,7 @@ void configureDefaults() {
5555
compressionEnabled = Boolean.getBoolean(ASYNC_CLIENT + "compressionEnabled");
5656
userAgent = System.getProperty(ASYNC_CLIENT + "userAgent", "AsyncHttpClient/" + AHC_VERSION);
5757
ioThreadMultiplier = Integer.getInteger(ASYNC_CLIENT + "ioThreadMultiplier", 2);
58-
58+
5959
boolean useProxySelector = Boolean.getBoolean(ASYNC_CLIENT + "useProxySelector");
6060
boolean useProxyProperties = Boolean.getBoolean(ASYNC_CLIENT + "useProxyProperties");
6161
if (useProxySelector) {

api/src/main/java/org/asynchttpclient/AsyncHttpProviderConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public interface AsyncHttpProviderConfig<U, V> {
2929
* @param value the value of the property
3030
* @return this instance of AsyncHttpProviderConfig
3131
*/
32-
public AsyncHttpProviderConfig<U,V> addProperty(U name, V value);
32+
public AsyncHttpProviderConfig<U, V> addProperty(U name, V value);
3333

3434
/**
3535
* Return the value associated with the property's name

api/src/main/java/org/asynchttpclient/BodyDeferringAsyncHandler.java

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@
7272
* </pre>
7373
*/
7474
public class BodyDeferringAsyncHandler implements AsyncHandler<Response> {
75-
private final Response.ResponseBuilder
76-
responseBuilder = new Response.ResponseBuilder();
75+
private final Response.ResponseBuilder responseBuilder = new Response.ResponseBuilder();
7776

7877
private final CountDownLatch headersArrived = new CountDownLatch(1);
7978

@@ -115,21 +114,18 @@ public void onThrowable(Throwable t) {
115114
}
116115
}
117116

118-
public STATE onStatusReceived(HttpResponseStatus responseStatus)
119-
throws Exception {
117+
public STATE onStatusReceived(HttpResponseStatus responseStatus) throws Exception {
120118
responseBuilder.reset();
121119
responseBuilder.accumulate(responseStatus);
122120
return STATE.CONTINUE;
123121
}
124122

125-
public STATE onHeadersReceived(HttpResponseHeaders headers)
126-
throws Exception {
123+
public STATE onHeadersReceived(HttpResponseHeaders headers) throws Exception {
127124
responseBuilder.accumulate(headers);
128125
return STATE.CONTINUE;
129126
}
130127

131-
public STATE onBodyPartReceived(HttpResponseBodyPart bodyPart)
132-
throws Exception {
128+
public STATE onBodyPartReceived(HttpResponseBodyPart bodyPart) throws Exception {
133129
// body arrived, flush headers
134130
if (!responseSet) {
135131
response = responseBuilder.build();
@@ -230,8 +226,7 @@ public static class BodyDeferringInputStream extends FilterInputStream {
230226

231227
private final BodyDeferringAsyncHandler bdah;
232228

233-
public BodyDeferringInputStream(final Future<Response> future,
234-
final BodyDeferringAsyncHandler bdah, final InputStream in) {
229+
public BodyDeferringInputStream(final Future<Response> future, final BodyDeferringAsyncHandler bdah, final InputStream in) {
235230
super(in);
236231
this.future = future;
237232
this.bdah = bdah;
@@ -263,8 +258,7 @@ public void close() throws IOException {
263258
* @return a {@link Response}
264259
* @throws InterruptedException
265260
*/
266-
public Response getAsapResponse() throws InterruptedException,
267-
IOException {
261+
public Response getAsapResponse() throws InterruptedException, IOException {
268262
return bdah.getResponse();
269263
}
270264

@@ -276,8 +270,7 @@ public Response getAsapResponse() throws InterruptedException,
276270
* @throws InterruptedException
277271
* @throws ExecutionException
278272
*/
279-
public Response getLastResponse() throws InterruptedException,
280-
ExecutionException {
273+
public Response getLastResponse() throws InterruptedException, ExecutionException {
281274
return future.get();
282275
}
283276
}

api/src/main/java/org/asynchttpclient/ConnectionPoolKeyStrategy.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@
1919

2020
public interface ConnectionPoolKeyStrategy {
2121

22-
String getKey(URI uri, ProxyServer proxy);
22+
String getKey(URI uri, ProxyServer proxy);
2323
}

api/src/main/java/org/asynchttpclient/HttpResponseBodyPart.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public abstract class HttpResponseBodyPart {
3131
* @since 2.0.0
3232
*/
3333
public abstract int length();
34-
34+
3535
/**
3636
* Return the response body's part bytes received.
3737
*
@@ -45,7 +45,7 @@ public abstract class HttpResponseBodyPart {
4545
* @since 2.0.0
4646
*/
4747
public abstract InputStream readBodyPartBytes();
48-
48+
4949
/**
5050
* Write the available bytes to the {@link java.io.OutputStream}
5151
*

api/src/main/java/org/asynchttpclient/HttpResponseHeaders.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
*/
1616
package org.asynchttpclient;
1717

18-
1918
/**
2019
* A class that represent the HTTP headers.
2120
*/

api/src/main/java/org/asynchttpclient/HttpResponseStatus.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public HttpResponseStatus(URI uri, AsyncHttpClientConfig config) {
4040
public final URI getUri() {
4141
return uri;
4242
}
43-
43+
4444
/**
4545
* Prepare a {@link Response}
4646
*

api/src/main/java/org/asynchttpclient/ProxyServer.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public String toString() {
6060
private Charset charset = StandardCharsets.UTF_8;
6161
private String ntlmDomain = System.getProperty("http.auth.ntlm.domain", "");
6262

63-
public ProxyServer(final Protocol protocol, final String host, final int port, String principal, String password) {
63+
public ProxyServer(final Protocol protocol, final String host, final int port, String principal, String password) {
6464
this.protocol = protocol;
6565
this.host = host;
6666
this.port = port;
@@ -151,4 +151,3 @@ public String toString() {
151151
return protocol + "://" + host + ":" + port;
152152
}
153153
}
154-

api/src/main/java/org/asynchttpclient/Realm.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@ public enum AuthScheme {
5555
DIGEST, BASIC, NTLM, SPNEGO, KERBEROS, NONE
5656
}
5757

58-
private Realm(AuthScheme scheme, String principal, String password, String realmName, String nonce, String algorithm, String response, String qop, String nc, String cnonce,
59-
String uri, String method, boolean usePreemptiveAuth, String domain, String enc, String host, boolean messageType2Received, String opaque) {
58+
private Realm(AuthScheme scheme, String principal, String password, String realmName, String nonce, String algorithm, String response,
59+
String qop, String nc, String cnonce, String uri, String method, boolean usePreemptiveAuth, String domain, String enc,
60+
String host, boolean messageType2Received, String opaque) {
6061

6162
this.principal = principal;
6263
this.password = password;
@@ -212,9 +213,9 @@ public boolean equals(Object o) {
212213

213214
@Override
214215
public String toString() {
215-
return "Realm{" + "principal='" + principal + '\'' + ", scheme=" + scheme + ", realmName='" + realmName + '\'' + ", nonce='" + nonce + '\'' + ", algorithm='" + algorithm
216-
+ '\'' + ", response='" + response + '\'' + ", qop='" + qop + '\'' + ", nc='" + nc + '\'' + ", cnonce='" + cnonce + '\'' + ", uri='" + uri + '\''
217-
+ ", methodName='" + methodName + '\'' + '}';
216+
return "Realm{" + "principal='" + principal + '\'' + ", scheme=" + scheme + ", realmName='" + realmName + '\'' + ", nonce='"
217+
+ nonce + '\'' + ", algorithm='" + algorithm + '\'' + ", response='" + response + '\'' + ", qop='" + qop + '\'' + ", nc='"
218+
+ nc + '\'' + ", cnonce='" + cnonce + '\'' + ", uri='" + uri + '\'' + ", methodName='" + methodName + '\'' + '}';
218219
}
219220

220221
@Override
@@ -569,8 +570,8 @@ public Realm build() {
569570
newResponse();
570571
}
571572

572-
return new Realm(scheme, principal, password, realmName, nonce, algorithm, response, qop, nc, cnonce, uri, methodName, usePreemptive, domain, enc, host,
573-
messageType2Received, opaque);
573+
return new Realm(scheme, principal, password, realmName, nonce, algorithm, response, qop, nc, cnonce, uri, methodName,
574+
usePreemptive, domain, enc, host, messageType2Received, opaque);
574575
}
575576
}
576577
}

api/src/main/java/org/asynchttpclient/Request.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ public interface Request {
5454
public String getUrl();
5555

5656
public URI getOriginalURI();
57+
5758
public URI getURI();
59+
5860
public URI getRawURI();
5961

6062
/**

api/src/main/java/org/asynchttpclient/RequestBuilderBase.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,8 @@ private void addQueryParameters(URI uri) {
408408
if (useRawUrl) {
409409
addQueryParameter(query.substring(0, pos), query.substring(pos + 1));
410410
} else {
411-
addQueryParameter(URLDecoder.decode(query.substring(0, pos), StandardCharsets.UTF_8.name()), URLDecoder.decode(query.substring(pos + 1), StandardCharsets.UTF_8.name()));
411+
addQueryParameter(URLDecoder.decode(query.substring(0, pos), StandardCharsets.UTF_8.name()),
412+
URLDecoder.decode(query.substring(pos + 1), StandardCharsets.UTF_8.name()));
412413
}
413414
} catch (UnsupportedEncodingException e) {
414415
throw new RuntimeException(e);

api/src/main/java/org/asynchttpclient/ResumableBodyConsumer.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,4 @@ public interface ResumableBodyConsumer extends BodyConsumer {
3434
*/
3535
long getTransferredBytes() throws IOException;
3636

37-
3837
}

api/src/main/java/org/asynchttpclient/SignatureCalculator.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,5 @@ public interface SignatureCalculator {
3535
* @param request Request that is being built; needed to access content to
3636
* be signed
3737
*/
38-
public void calculateAndAddSignature(String url, Request request,
39-
RequestBuilderBase<?> requestBuilder);
38+
public void calculateAndAddSignature(String url, Request request, RequestBuilderBase<?> requestBuilder);
4039
}

0 commit comments

Comments
 (0)