Skip to content

Commit 1cad354

Browse files
author
Stephane Landelle
committed
Add some final vars
1 parent 97faa28 commit 1cad354

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

providers/netty/src/main/java/org/asynchttpclient/providers/netty/handler/HttpProtocol.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ public void handle(final Channel channel, final NettyResponseFuture<?> future, f
393393
ByteBuf buf = chunk.content();
394394
try {
395395
if (!interrupt && (buf.readableBytes() > 0 || last)) {
396-
interrupt = updateBodyAndInterrupt(future, handler, bodyPartFactory.newResponseBodyPart(buf, last));
396+
interrupt = updateBodyAndInterrupt(future, handler, nettyConfig.getBodyPartFactory().newResponseBodyPart(buf, last));
397397
}
398398
} finally {
399399
// FIXME we shouldn't need this, should we? But a leak was reported there without it?!
@@ -406,7 +406,7 @@ public void handle(final Channel channel, final NettyResponseFuture<?> future, f
406406
}
407407
}
408408
} catch (Exception t) {
409-
if (t instanceof IOException && !config.getIOExceptionFilters().isEmpty()
409+
if (hasIOExceptionFilters && t instanceof IOException
410410
&& requestSender.applyIoExceptionFiltersAndReplayRequest(future, IOException.class.cast(t), channel)) {
411411
return;
412412
}

providers/netty/src/main/java/org/asynchttpclient/providers/netty/handler/Protocol.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
import org.asynchttpclient.org.jboss.netty.handler.codec.http.CookieDecoder;
4141
import org.asynchttpclient.providers.netty.Callback;
4242
import org.asynchttpclient.providers.netty.NettyAsyncHttpProviderConfig;
43-
import org.asynchttpclient.providers.netty.NettyAsyncHttpProviderConfig.ResponseBodyPartFactory;
4443
import org.asynchttpclient.providers.netty.channel.Channels;
4544
import org.asynchttpclient.providers.netty.future.NettyResponseFuture;
4645
import org.asynchttpclient.providers.netty.request.NettyRequestSender;
@@ -54,14 +53,20 @@ public abstract class Protocol {
5453

5554
protected final Channels channels;
5655
protected final AsyncHttpClientConfig config;
56+
protected final NettyAsyncHttpProviderConfig nettyConfig;
5757
protected final NettyRequestSender requestSender;
58-
protected final ResponseBodyPartFactory bodyPartFactory;
58+
59+
private final boolean hasResponseFilters;
60+
protected final boolean hasIOExceptionFilters;
5961

6062
public Protocol(Channels channels, AsyncHttpClientConfig config, NettyAsyncHttpProviderConfig nettyConfig, NettyRequestSender requestSender) {
6163
this.channels = channels;
6264
this.config = config;
6365
this.requestSender = requestSender;
64-
this.bodyPartFactory = nettyConfig.getBodyPartFactory();
66+
this.nettyConfig = nettyConfig;
67+
68+
hasResponseFilters = !config.getResponseFilters().isEmpty();
69+
hasIOExceptionFilters = !config.getIOExceptionFilters().isEmpty();
6570
}
6671

6772
public abstract void handle(Channel channel, NettyResponseFuture<?> future, Object message) throws Exception;
@@ -154,7 +159,7 @@ public void call() throws Exception {
154159
protected boolean handleResponseFiltersReplayRequestAndExit(Channel channel, NettyResponseFuture<?> future, HttpResponseStatus status, HttpResponseHeaders responseHeaders)
155160
throws IOException {
156161

157-
if (!config.getResponseFilters().isEmpty()) {
162+
if (hasResponseFilters) {
158163
AsyncHandler<?> handler = future.getAsyncHandler();
159164
FilterContext fc = new FilterContext.FilterContextBuilder().asyncHandler(handler).request(future.getRequest()).responseStatus(status).responseHeaders(responseHeaders)
160165
.build();

providers/netty/src/main/java/org/asynchttpclient/providers/netty/handler/WebSocketProtocol.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public void handle(Channel channel, NettyResponseFuture<?> future, Object e) thr
141141
ByteBuf buf = frame.content();
142142
if (buf != null && buf.readableBytes() > 0) {
143143
try {
144-
NettyResponseBodyPart rp = bodyPartFactory.newResponseBodyPart(buf, frame.isFinalFragment());
144+
NettyResponseBodyPart rp = nettyConfig.getBodyPartFactory().newResponseBodyPart(buf, frame.isFinalFragment());
145145
h.onBodyPartReceived(rp);
146146

147147
if (binaryFrame) {

0 commit comments

Comments
 (0)