Skip to content

Commit d47c56e

Browse files
committed
minor clean up
1 parent e3f152c commit d47c56e

File tree

175 files changed

+990
-1381
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

+990
-1381
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 & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,20 +121,20 @@ public void onThrowable(Throwable t) {
121121
}
122122

123123
@Override
124-
public State onStatusReceived(HttpResponseStatus responseStatus) throws Exception {
124+
public State onStatusReceived(HttpResponseStatus responseStatus) {
125125
responseBuilder.reset();
126126
responseBuilder.accumulate(responseStatus);
127127
return State.CONTINUE;
128128
}
129129

130130
@Override
131-
public State onHeadersReceived(HttpHeaders headers) throws Exception {
131+
public State onHeadersReceived(HttpHeaders headers) {
132132
responseBuilder.accumulate(headers);
133133
return State.CONTINUE;
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();

client/src/main/java/org/asynchttpclient/handler/resumable/PropertiesBasedResumableProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public class PropertiesBasedResumableProcessor implements ResumableAsyncHandler.
3737
private final ConcurrentHashMap<String, Long> properties = new ConcurrentHashMap<>();
3838

3939
private static String append(Map.Entry<String, Long> e) {
40-
return new StringBuilder(e.getKey()).append('=').append(e.getValue()).append('\n').toString();
40+
return e.getKey() + '=' + e.getValue() + '\n';
4141
}
4242

4343
/**

client/src/main/java/org/asynchttpclient/handler/resumable/ResumableAsyncHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ public State onHeadersReceived(HttpHeaders headers) throws Exception {
174174
}
175175

176176
@Override
177-
public State onTrailingHeadersReceived(HttpHeaders headers) throws Exception {
177+
public State onTrailingHeadersReceived(HttpHeaders headers) {
178178
responseBuilder.accumulate(headers);
179179
return State.CONTINUE;
180180
}
@@ -292,7 +292,7 @@ private static class NULLResumableListener implements ResumableListener {
292292

293293
private long length = 0L;
294294

295-
public void onBytesReceived(ByteBuffer byteBuffer) throws IOException {
295+
public void onBytesReceived(ByteBuffer byteBuffer) {
296296
length += byteBuffer.remaining();
297297
}
298298

client/src/main/java/org/asynchttpclient/handler/resumable/ResumableIOExceptionFilter.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,13 @@
1414

1515
import org.asynchttpclient.Request;
1616
import org.asynchttpclient.filter.FilterContext;
17-
import org.asynchttpclient.filter.FilterException;
1817
import org.asynchttpclient.filter.IOExceptionFilter;
1918

2019
/**
2120
* Simple {@link org.asynchttpclient.filter.IOExceptionFilter} that replay the current {@link org.asynchttpclient.Request} using a {@link ResumableAsyncHandler}
2221
*/
2322
public class ResumableIOExceptionFilter implements IOExceptionFilter {
24-
public <T> FilterContext<T> filter(FilterContext<T> ctx) throws FilterException {
23+
public <T> FilterContext<T> filter(FilterContext<T> ctx) {
2524
if (ctx.getIOException() != null && ctx.getAsyncHandler() instanceof ResumableAsyncHandler) {
2625

2726
Request request = ResumableAsyncHandler.class.cast(ctx.getAsyncHandler()).adjustRequestRange(ctx.getRequest());

client/src/main/java/org/asynchttpclient/netty/NettyResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public final String getHeader(CharSequence name) {
114114

115115
@Override
116116
public final List<String> getHeaders(CharSequence name) {
117-
return headers != null ? getHeaders().getAll(name) : Collections.<String>emptyList();
117+
return headers != null ? getHeaders().getAll(name) : Collections.emptyList();
118118
}
119119

120120
@Override

client/src/main/java/org/asynchttpclient/netty/NettyResponseFuture.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -207,10 +207,10 @@ public V get(long l, TimeUnit tu) throws InterruptedException, TimeoutException,
207207
return future.get(l, tu);
208208
}
209209

210-
private V getContent() throws ExecutionException {
210+
private void loadContent() throws ExecutionException {
211211
if (future.isDone()) {
212212
try {
213-
return future.get();
213+
future.get();
214214
} catch (InterruptedException e) {
215215
throw new RuntimeException("unreachable", e);
216216
}
@@ -236,7 +236,7 @@ private V getContent() throws ExecutionException {
236236
future.completeExceptionally(ex);
237237
}
238238
}
239-
return future.getNow(null);
239+
future.getNow(null);
240240
}
241241

242242
// org.asynchttpclient.ListenableFuture
@@ -255,7 +255,7 @@ public final void done() {
255255
return;
256256

257257
try {
258-
getContent();
258+
loadContent();
259259
} catch (ExecutionException ignored) {
260260

261261
} catch (RuntimeException t) {
@@ -307,10 +307,6 @@ public Uri getUri() {
307307
return targetRequest.getUri();
308308
}
309309

310-
public ChannelPoolPartitioning getConnectionPoolPartitioning() {
311-
return connectionPoolPartitioning;
312-
}
313-
314310
public ProxyServer getProxyServer() {
315311
return proxyServer;
316312
}

client/src/main/java/org/asynchttpclient/netty/SimpleChannelFutureListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
public abstract class SimpleChannelFutureListener implements ChannelFutureListener {
2121

2222
@Override
23-
public final void operationComplete(ChannelFuture future) throws Exception {
23+
public final void operationComplete(ChannelFuture future) {
2424
Channel channel = future.channel();
2525
if (future.isSuccess()) {
2626
onSuccess(channel);

0 commit comments

Comments
 (0)