Skip to content

Commit 32023fa

Browse files
author
Stephane Landelle
committed
Have one MaxRedirectException instance per Protocol instance
1 parent 9036b03 commit 32023fa

File tree

1 file changed

+4
-1
lines changed
  • src/main/java/com/ning/http/client/providers/netty/handler

1 file changed

+4
-1
lines changed

src/main/java/com/ning/http/client/providers/netty/handler/Protocol.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ public abstract class Protocol {
6969
private final boolean hasResponseFilters;
7070
protected final boolean hasIOExceptionFilters;
7171
private final TimeConverter timeConverter;
72+
private final MaxRedirectException maxRedirectException;
7273

7374
public static final Set<Integer> REDIRECT_STATUSES = new HashSet<Integer>();
7475
static {
@@ -98,6 +99,8 @@ public Protocol(ChannelManager channelManager, AsyncHttpClientConfig config, Net
9899
hasResponseFilters = !config.getResponseFilters().isEmpty();
99100
hasIOExceptionFilters = !config.getIOExceptionFilters().isEmpty();
100101
timeConverter = config.getTimeConverter();
102+
maxRedirectException = new MaxRedirectException("Maximum redirect reached: " + config.getMaxRedirects());
103+
maxRedirectException.setStackTrace(new StackTraceElement[] {});
101104
}
102105

103106
public abstract void handle(Channel channel, NettyResponseFuture<?> future, Object message) throws Exception;
@@ -126,7 +129,7 @@ protected boolean exitAfterHandlingRedirect(//
126129

127130
if (followRedirect(config, request) && REDIRECT_STATUSES.contains(statusCode)) {
128131
if (future.incrementAndGetCurrentRedirectCount() >= config.getMaxRedirects()) {
129-
throw new MaxRedirectException("Maximum redirect reached: " + config.getMaxRedirects());
132+
throw maxRedirectException;
130133

131134
} else {
132135
// We must allow 401 handling again.

0 commit comments

Comments
 (0)