Skip to content

Commit 9298959

Browse files
authored
General formatting and cleanup (#1844)
1 parent d4115c3 commit 9298959

File tree

83 files changed

+595
-737
lines changed

Some content is hidden

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

83 files changed

+595
-737
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ public interface AsyncHttpClientConfig {
230230
* In the case of a POST/Redirect/Get scenario where the server uses a 302 for the redirect, should AHC respond to the redirect with a GET or whatever the original method was.
231231
* Unless configured otherwise, for a 302, AHC, will use a GET for this case.
232232
*
233-
* @return <code>true</code> if strict 302 handling is to be used, otherwise {@code false}.
233+
* @return {@code true} if strict 302 handling is to be used, otherwise {@code false}.
234234
*/
235235
boolean isStrict302Handling();
236236

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

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

18-
import io.netty.buffer.ByteBuf;
1918
import io.netty.handler.codec.http.DefaultHttpHeaders;
2019
import io.netty.handler.codec.http.HttpHeaders;
2120
import io.netty.handler.codec.http.cookie.Cookie;
@@ -57,7 +56,7 @@ public abstract class RequestBuilderBase<T extends RequestBuilderBase<T>> {
5756

5857
private static final Logger LOGGER = LoggerFactory.getLogger(RequestBuilderBase.class);
5958
private static final Uri DEFAULT_REQUEST_URL = Uri.create("http://localhost");
60-
public static NameResolver<InetAddress> DEFAULT_NAME_RESOLVER = new DefaultNameResolver(ImmediateEventExecutor.INSTANCE);
59+
public static final NameResolver<InetAddress> DEFAULT_NAME_RESOLVER = new DefaultNameResolver(ImmediateEventExecutor.INSTANCE);
6160
// builder only fields
6261
protected UriEncoder uriEncoder;
6362
protected List<Param> queryParams;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
public class DefaultKeepAliveStrategy implements KeepAliveStrategy {
3131

3232
/**
33-
* Implemented in accordance with RFC 7230 section 6.1 https://tools.ietf.org/html/rfc7230#section-6.1
33+
* Implemented in accordance with RFC 7230 section 6.1 <a href="http://github.com/%3C/span%3Ehttps://tools.ietf.org/html/rfc7230#section-6.1%3Cspan%20class="x x-first x-last">">...</a>
3434
*/
3535
@Override
3636
public boolean keepAlive(InetSocketAddress remoteAddress, Request ahcRequest, HttpRequest request, HttpResponse response) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,6 @@ private static Class<?>[] allInterfaces(Class<?> handlerClass) {
7171
for (Class<?> clazz = handlerClass; clazz != null; clazz = clazz.getSuperclass()) {
7272
Collections.addAll(allInterfaces, clazz.getInterfaces());
7373
}
74-
return allInterfaces.toArray(new Class[allInterfaces.size()]);
74+
return allInterfaces.toArray(new Class[0]);
7575
}
7676
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
* OutputStream fos = ...
5050
* BodyDeferringAsyncHandler bdah = new BodyDeferringAsyncHandler(fos);
5151
* // client executes async
52-
* Future&lt;Response&gt; fr = client.prepareGet(&quot;http://foo.com/aresource&quot;).execute(
52+
* Future&lt;Response&gt; fr = client.prepareGet(&quot;<a href="http://github.com/%3C/span%3Ehttp://foo.com/aresource&quot;%3Cspan%20class="x x-first x-last">">...</a>).execute(
5353
* bdah);
5454
* // main thread will block here until headers are available
5555
* Response response = bdah.getResponse();

client/src/main/java/org/asynchttpclient/netty/future/StackTraceInspector.java

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,11 @@ private static boolean exceptionInMethod(Throwable t, String className, String m
3737
}
3838

3939
private static boolean recoverOnConnectCloseException(Throwable t) {
40-
return exceptionInMethod(t, "sun.nio.ch.SocketChannelImpl", "checkConnect")
41-
|| t.getCause() != null && recoverOnConnectCloseException(t.getCause());
40+
while (true) {
41+
if (exceptionInMethod(t, "sun.nio.ch.SocketChannelImpl", "checkConnect")) return true;
42+
if (t.getCause() == null) return false;
43+
t = t.getCause();
44+
}
4245
}
4346

4447
public static boolean recoverOnNettyDisconnectException(Throwable t) {
@@ -48,21 +51,24 @@ public static boolean recoverOnNettyDisconnectException(Throwable t) {
4851
}
4952

5053
public static boolean recoverOnReadOrWriteException(Throwable t) {
51-
if (t instanceof IOException && "Connection reset by peer".equalsIgnoreCase(t.getMessage())) {
52-
return true;
53-
}
54+
while (true) {
55+
if (t instanceof IOException && "Connection reset by peer".equalsIgnoreCase(t.getMessage())) {
56+
return true;
57+
}
5458

55-
try {
56-
for (StackTraceElement element : t.getStackTrace()) {
57-
String className = element.getClassName();
58-
String methodName = element.getMethodName();
59-
if ("sun.nio.ch.SocketDispatcher".equals(className) && ("read".equals(methodName) || "write".equals(methodName))) {
60-
return true;
59+
try {
60+
for (StackTraceElement element : t.getStackTrace()) {
61+
String className = element.getClassName();
62+
String methodName = element.getMethodName();
63+
if ("sun.nio.ch.SocketDispatcher".equals(className) && ("read".equals(methodName) || "write".equals(methodName))) {
64+
return true;
65+
}
6166
}
67+
} catch (Throwable ignore) {
6268
}
63-
} catch (Throwable ignore) {
64-
}
6569

66-
return t.getCause() != null && recoverOnReadOrWriteException(t.getCause());
70+
if (t.getCause() == null) return false;
71+
t = t.getCause();
72+
}
6773
}
6874
}

client/src/main/java/org/asynchttpclient/netty/handler/AsyncHttpClientHandler.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,13 @@
1515
*/
1616
package org.asynchttpclient.netty.handler;
1717

18-
import io.netty.buffer.ByteBuf;
1918
import io.netty.channel.Channel;
2019
import io.netty.channel.ChannelHandlerContext;
2120
import io.netty.channel.ChannelInboundHandlerAdapter;
2221
import io.netty.handler.codec.PrematureChannelClosureException;
23-
import io.netty.handler.codec.http.HttpContent;
2422
import io.netty.handler.codec.http.LastHttpContent;
2523
import io.netty.util.ReferenceCountUtil;
2624
import org.asynchttpclient.AsyncHttpClientConfig;
27-
import org.asynchttpclient.HttpResponseBodyPart;
2825
import org.asynchttpclient.exception.ChannelClosedException;
2926
import org.asynchttpclient.netty.DiscardEvent;
3027
import org.asynchttpclient.netty.NettyResponseFuture;

client/src/main/java/org/asynchttpclient/netty/handler/intercept/ProxyUnauthorized407Interceptor.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ public boolean exitAfterHandling407(Channel channel, NettyResponseFuture<?> futu
144144
try {
145145
kerberosProxyChallenge(proxyRealm, proxyServer, requestHeaders);
146146
} catch (SpnegoEngineException e) {
147-
// FIXME
148147
String ntlmHeader2 = getHeaderWithPrefix(proxyAuthHeaders, "NTLM");
149148
if (ntlmHeader2 != null) {
150149
LOGGER.warn("Kerberos/Spnego proxy auth failed, proceeding with NTLM");

client/src/main/java/org/asynchttpclient/netty/handler/intercept/Unauthorized401Interceptor.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,7 @@ public boolean exitAfterHandling401(Channel channel, NettyResponseFuture<?> futu
139139
}
140140
try {
141141
kerberosChallenge(realm, request, requestHeaders);
142-
143142
} catch (SpnegoEngineException e) {
144-
// FIXME
145143
String ntlmHeader2 = getHeaderWithPrefix(wwwAuthHeaders, "NTLM");
146144
if (ntlmHeader2 != null) {
147145
LOGGER.warn("Kerberos/Spnego auth failed, proceeding with NTLM");

0 commit comments

Comments
 (0)