Skip to content

Commit 8daebe0

Browse files
committed
minor clean up
1 parent e3f152c commit 8daebe0

File tree

175 files changed

+989
-1386
lines changed

Some content is hidden

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

175 files changed

+989
-1386
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class AsyncHttpClientState {
1919

2020
private final AtomicBoolean closed;
2121

22-
public AsyncHttpClientState(AtomicBoolean closed) {
22+
AsyncHttpClientState(AtomicBoolean closed) {
2323
this.closed = closed;
2424
}
2525

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public class DefaultAsyncHttpClient implements AsyncHttpClient {
5454
* Default signature calculator to use for all requests constructed by this
5555
* client instance.
5656
*/
57-
protected SignatureCalculator signatureCalculator;
57+
private SignatureCalculator signatureCalculator;
5858

5959
/**
6060
* Create a new HTTP Asynchronous Client using the default
@@ -229,7 +229,7 @@ public ListenableFuture<Response> executeRequest(RequestBuilder requestBuilder)
229229

230230
private <T> ListenableFuture<T> execute(Request request, final AsyncHandler<T> asyncHandler) {
231231
try {
232-
return requestSender.sendRequest(request, asyncHandler, null, false);
232+
return requestSender.sendRequest(request, asyncHandler, null);
233233
} catch (Exception e) {
234234
asyncHandler.onThrowable(e);
235235
return new ListenableFuture.CompletedFailure<>(e);

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

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -64,30 +64,30 @@ public class DefaultRequest implements Request {
6464
// lazily loaded
6565
private List<Param> queryParams;
6666

67-
public DefaultRequest(String method,//
68-
Uri uri,//
69-
InetAddress address,//
70-
InetAddress localAddress,//
71-
HttpHeaders headers,//
72-
List<Cookie> cookies,//
73-
byte[] byteData,//
74-
List<byte[]> compositeByteData,//
75-
String stringData,//
76-
ByteBuffer byteBufferData,//
77-
InputStream streamData,//
78-
BodyGenerator bodyGenerator,//
79-
List<Param> formParams,//
80-
List<Part> bodyParts,//
81-
String virtualHost,//
82-
ProxyServer proxyServer,//
83-
Realm realm,//
84-
File file,//
85-
Boolean followRedirect,//
86-
int requestTimeout,//
87-
int readTimeout,//
88-
long rangeOffset,//
89-
Charset charset,//
90-
ChannelPoolPartitioning channelPoolPartitioning,//
67+
public DefaultRequest(String method,
68+
Uri uri,
69+
InetAddress address,
70+
InetAddress localAddress,
71+
HttpHeaders headers,
72+
List<Cookie> cookies,
73+
byte[] byteData,
74+
List<byte[]> compositeByteData,
75+
String stringData,
76+
ByteBuffer byteBufferData,
77+
InputStream streamData,
78+
BodyGenerator bodyGenerator,
79+
List<Param> formParams,
80+
List<Part> bodyParts,
81+
String virtualHost,
82+
ProxyServer proxyServer,
83+
Realm realm,
84+
File file,
85+
Boolean followRedirect,
86+
int requestTimeout,
87+
int readTimeout,
88+
long rangeOffset,
89+
Charset charset,
90+
ChannelPoolPartitioning channelPoolPartitioning,
9191
NameResolver<InetAddress> nameResolver) {
9292
this.method = method;
9393
this.uri = uri;

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -85,20 +85,20 @@ public static DefaultAsyncHttpClientConfig.Builder config() {
8585

8686
// /////////// Realm ////////////////
8787
public static Realm.Builder realm(Realm prototype) {
88-
return new Realm.Builder(prototype.getPrincipal(), prototype.getPassword())//
89-
.setRealmName(prototype.getRealmName())//
90-
.setAlgorithm(prototype.getAlgorithm())//
91-
.setNc(prototype.getNc())//
92-
.setNonce(prototype.getNonce())//
93-
.setCharset(prototype.getCharset())//
94-
.setOpaque(prototype.getOpaque())//
95-
.setQop(prototype.getQop())//
96-
.setScheme(prototype.getScheme())//
97-
.setUri(prototype.getUri())//
98-
.setUsePreemptiveAuth(prototype.isUsePreemptiveAuth())//
99-
.setNtlmDomain(prototype.getNtlmDomain())//
100-
.setNtlmHost(prototype.getNtlmHost())//
101-
.setUseAbsoluteURI(prototype.isUseAbsoluteURI())//
88+
return new Realm.Builder(prototype.getPrincipal(), prototype.getPassword())
89+
.setRealmName(prototype.getRealmName())
90+
.setAlgorithm(prototype.getAlgorithm())
91+
.setNc(prototype.getNc())
92+
.setNonce(prototype.getNonce())
93+
.setCharset(prototype.getCharset())
94+
.setOpaque(prototype.getOpaque())
95+
.setQop(prototype.getQop())
96+
.setScheme(prototype.getScheme())
97+
.setUri(prototype.getUri())
98+
.setUsePreemptiveAuth(prototype.isUsePreemptiveAuth())
99+
.setNtlmDomain(prototype.getNtlmDomain())
100+
.setNtlmHost(prototype.getNtlmHost())
101+
.setUseAbsoluteURI(prototype.isUseAbsoluteURI())
102102
.setOmitQuery(prototype.isOmitQuery());
103103
}
104104

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,12 @@ public boolean isDone() {
106106
}
107107

108108
@Override
109-
public T get() throws InterruptedException, ExecutionException {
109+
public T get() throws ExecutionException {
110110
throw e;
111111
}
112112

113113
@Override
114-
public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
114+
public T get(long timeout, TimeUnit unit) throws ExecutionException {
115115
throw e;
116116
}
117117

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -173,24 +173,20 @@ class ResponseBuilder {
173173
private HttpResponseStatus status;
174174
private HttpHeaders headers;
175175

176-
public ResponseBuilder accumulate(HttpResponseStatus status) {
176+
public void accumulate(HttpResponseStatus status) {
177177
this.status = status;
178-
return this;
179178
}
180179

181-
public ResponseBuilder accumulate(HttpHeaders headers) {
180+
public void accumulate(HttpHeaders headers) {
182181
this.headers = this.headers == null ? headers : this.headers.add(headers);
183-
return this;
184182
}
185183

186184
/**
187185
* @param bodyPart a body part (possibly empty, but will be filtered out)
188-
* @return this
189186
*/
190-
public ResponseBuilder accumulate(HttpResponseBodyPart bodyPart) {
187+
public void accumulate(HttpResponseBodyPart bodyPart) {
191188
if (bodyPart.length() > 0)
192189
bodyParts.add(bodyPart);
193-
return this;
194190
}
195191

196192
/**

client/src/main/java/org/asynchttpclient/channel/ChannelPoolPartitioning.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,20 +87,16 @@ public boolean equals(Object obj) {
8787
return false;
8888
} else if (!targetHostBaseUrl.equals(other.targetHostBaseUrl))
8989
return false;
90-
if (proxyType != other.proxyType)
91-
return false;
92-
return true;
90+
return proxyType == other.proxyType;
9391
}
9492

9593
@Override
9694
public String toString() {
97-
return new StringBuilder()//
98-
.append("ProxyPartitionKey(proxyHost=").append(proxyHost)//
99-
.append(", proxyPort=").append(proxyPort)//
100-
.append(", secured=").append(secured)//
101-
.append(", targetHostBaseUrl=").append(targetHostBaseUrl)//
102-
.append(", proxyType=").append(proxyType)//
103-
.toString();
95+
return "ProxyPartitionKey(proxyHost=" + proxyHost +
96+
", proxyPort=" + proxyPort +
97+
", secured=" + secured +
98+
", targetHostBaseUrl=" + targetHostBaseUrl +
99+
", proxyType=" + proxyType;
104100
}
105101
}
106102
}

client/src/main/java/org/asynchttpclient/config/AsyncHttpClientConfigHelper.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,6 @@ public int getInt(String key) {
109109
return Integer.parseInt(getString(key));
110110
}
111111

112-
public long getLong(String key) {
113-
return Long.parseLong(getString(key));
114-
}
115-
116-
public Integer getInteger(String key) {
117-
String s = getString(key);
118-
return s != null ? Integer.valueOf(s) : null;
119-
}
120-
121112
public boolean getBoolean(String key) {
122113
return Boolean.parseBoolean(getString(key));
123114
}

client/src/main/java/org/asynchttpclient/filter/ReleasePermitOnComplete.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
import org.asynchttpclient.AsyncHandler;
44

5-
import java.lang.reflect.InvocationHandler;
6-
import java.lang.reflect.Method;
75
import java.lang.reflect.Proxy;
86
import java.util.Collections;
97
import java.util.HashSet;
@@ -29,9 +27,7 @@ public static <T> AsyncHandler<T> wrap(final AsyncHandler<T> handler, final Sema
2927
ClassLoader classLoader = handlerClass.getClassLoader();
3028
Class<?>[] interfaces = allInterfaces(handlerClass);
3129

32-
return (AsyncHandler<T>) Proxy.newProxyInstance(classLoader, interfaces, new InvocationHandler() {
33-
@Override
34-
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
30+
return (AsyncHandler<T>) Proxy.newProxyInstance(classLoader, interfaces, (proxy, method, args) -> {
3531
try {
3632
return method.invoke(handler, args);
3733
} finally {
@@ -42,7 +38,6 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl
4238
default:
4339
}
4440
}
45-
}
4641
});
4742
}
4843

@@ -52,7 +47,7 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl
5247
* @param handlerClass the handler class
5348
* @return all interfaces implemented by this class
5449
*/
55-
static Class<?>[] allInterfaces(Class<?> handlerClass) {
50+
private static Class<?>[] allInterfaces(Class<?> handlerClass) {
5651
Set<Class<?>> allInterfaces = new HashSet<>();
5752
for (Class<?> clazz = handlerClass; clazz != null; clazz = clazz.getSuperclass()) {
5853
Collections.addAll(allInterfaces, clazz.getInterfaces());

client/src/main/java/org/asynchttpclient/handler/BodyDeferringAsyncHandler.java

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public State onHeadersReceived(HttpHeaders headers) throws Exception {
134134
}
135135

136136
@Override
137-
public State onTrailingHeadersReceived(HttpHeaders headers) throws Exception {
137+
public State onTrailingHeadersReceived(HttpHeaders headers) {
138138
responseBuilder.accumulate(headers);
139139
return State.CONTINUE;
140140
}
@@ -181,9 +181,7 @@ public Response onCompleted() throws IOException {
181181
try {
182182
semaphore.acquire();
183183
if (throwable != null) {
184-
IOException ioe = new IOException(throwable.getMessage());
185-
ioe.initCause(throwable);
186-
throw ioe;
184+
throw new IOException(throwable);
187185
} else {
188186
// sending out current response
189187
return responseBuilder.build();
@@ -258,14 +256,8 @@ public void close() throws IOException {
258256
// "join" async request
259257
try {
260258
getLastResponse();
261-
} catch (ExecutionException e) {
262-
IOException ioe = new IOException(e.getMessage());
263-
ioe.initCause(e.getCause());
264-
throw ioe;
265-
} catch (InterruptedException e) {
266-
IOException ioe = new IOException(e.getMessage());
267-
ioe.initCause(e);
268-
throw ioe;
259+
} catch (ExecutionException | InterruptedException e) {
260+
throw new IOException(e);
269261
}
270262
}
271263

0 commit comments

Comments
 (0)