Skip to content

Commit 1d965d7

Browse files
author
Stephane Landelle
committed
Minor clean up
1 parent baa150b commit 1d965d7

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

src/main/java/com/ning/http/client/providers/netty/NettyAsyncHttpProvider.java

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,8 @@ public boolean remove(Object o) {
199199
private final Protocol webSocketProtocol = new WebSocketProtocol();
200200

201201
private static boolean isNTLM(List<String> auth) {
202-
return isNonEmpty(auth) && auth.get(0).startsWith("NTLM");
203-
}
202+
return isNonEmpty(auth) && auth.get(0).startsWith("NTLM");
203+
}
204204

205205
public NettyAsyncHttpProvider(AsyncHttpClientConfig config) {
206206

@@ -923,7 +923,7 @@ private <T> ListenableFuture<T> doConnect(final Request request, final AsyncHand
923923
HttpRequest nettyRequest = null;
924924

925925
if (f == null) {
926-
nettyRequest = buildRequest(config, request, uri, false, bufferedBytes, proxyServer);
926+
nettyRequest = buildRequest(config, request, uri, false, bufferedBytes, proxyServer);
927927
f = newFuture(uri, request, asyncHandler, nettyRequest, config, this, proxyServer);
928928
} else {
929929
nettyRequest = buildRequest(config, request, uri, f.isConnectAllowed(), bufferedBytes, proxyServer);
@@ -1168,9 +1168,9 @@ private Realm kerberosChallenge(List<String> proxyAuth, Request request, ProxySe
11681168
}
11691169

11701170
private void addType3NTLMAuthorizationHeader(
1171-
List<String> auth,
1172-
FluentCaseInsensitiveStringsMap headers,
1173-
String username,
1171+
List<String> auth,
1172+
FluentCaseInsensitiveStringsMap headers,
1173+
String username,
11741174
String password,
11751175
String domain,
11761176
String workstation) throws NTLMEngineException {
@@ -1202,7 +1202,7 @@ private Realm ntlmChallenge(List<String> wwwAuth, Request request, ProxyServer p
12021202
newRealm = new Realm.RealmBuilder().clone(realm).setScheme(realm.getAuthScheme()).setUri(uri.getRawPath()).setMethodName(request.getMethod()).setNtlmMessageType2Received(true).build();
12031203
future.getAndSetAuth(false);
12041204
} else {
1205-
addType3NTLMAuthorizationHeader(wwwAuth, headers, principal, password, ntlmDomain, ntlmHost);
1205+
addType3NTLMAuthorizationHeader(wwwAuth, headers, principal, password, ntlmDomain, ntlmHost);
12061206

12071207
Realm.RealmBuilder realmBuilder;
12081208
Realm.AuthScheme authScheme;
@@ -1377,7 +1377,7 @@ public void channelClosed(ChannelHandlerContext ctx, ChannelStateEvent e) throws
13771377
p.onClose(ctx, e);
13781378

13791379
if (future != null && !future.isDone() && !future.isCancelled()) {
1380-
if (!remotelyClosed(ctx.getChannel(), future)) {
1380+
if (remotelyClosed(ctx.getChannel(), future)) {
13811381
abort(future, new IOException("Remotely Closed"));
13821382
}
13831383
} else {
@@ -1389,18 +1389,20 @@ public void channelClosed(ChannelHandlerContext ctx, ChannelStateEvent e) throws
13891389
protected boolean remotelyClosed(Channel channel, NettyResponseFuture<?> future) {
13901390

13911391
if (isClose.get()) {
1392-
return false;
1392+
return true;
13931393
}
13941394

13951395
connectionsPool.removeAll(channel);
13961396

1397-
if (future == null && channel.getPipeline().getContext(NettyAsyncHttpProvider.class).getAttachment() instanceof NettyResponseFuture) {
1398-
future = (NettyResponseFuture<?>) channel.getPipeline().getContext(NettyAsyncHttpProvider.class).getAttachment();
1397+
if (future == null) {
1398+
Object attachment = channel.getPipeline().getContext(NettyAsyncHttpProvider.class).getAttachment();
1399+
if (attachment instanceof NettyResponseFuture)
1400+
future = (NettyResponseFuture<?>) attachment;
13991401
}
14001402

14011403
if (future == null || future.cannotBeReplay()) {
14021404
log.debug("Unable to recover future {}\n", future);
1403-
return false;
1405+
return true;
14041406
}
14051407

14061408
future.setState(NettyResponseFuture.STATE.RECONNECTED);
@@ -1409,13 +1411,13 @@ protected boolean remotelyClosed(Channel channel, NettyResponseFuture<?> future)
14091411

14101412
try {
14111413
nextRequest(future.getRequest(), future);
1412-
return true;
1414+
return false;
14131415
} catch (IOException iox) {
14141416
future.setState(NettyResponseFuture.STATE.CLOSED);
14151417
future.abort(iox);
14161418
log.error("Remotely Closed, unable to recover", iox);
1419+
return true;
14171420
}
1418-
return false;
14191421
}
14201422

14211423
private void markAsDone(final NettyResponseFuture<?> future, final ChannelHandlerContext ctx) throws MalformedURLException {

0 commit comments

Comments
 (0)