Skip to content

Commit 66ce052

Browse files
committed
clean up static Exceptions
1 parent 6fbf2de commit 66ce052

File tree

6 files changed

+12
-27
lines changed

6 files changed

+12
-27
lines changed

src/main/java/com/ning/http/client/MaxRedirectException.java

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,9 @@ public class MaxRedirectException extends Exception {
2323
private static final long serialVersionUID = 1L;
2424

2525
public MaxRedirectException() {
26-
super();
2726
}
2827

2928
public MaxRedirectException(String msg) {
30-
super(msg);
29+
super(msg, null, true, false);
3130
}
32-
33-
public MaxRedirectException(Throwable cause) {
34-
super(cause);
35-
}
36-
37-
public MaxRedirectException(String message, Throwable cause) {
38-
super(message, cause);
39-
}
40-
}
31+
}

src/main/java/com/ning/http/client/providers/netty/channel/ChannelManager.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import static com.ning.http.client.providers.netty.util.HttpUtils.WEBSOCKET;
1717
import static com.ning.http.client.providers.netty.util.HttpUtils.isSecure;
1818
import static com.ning.http.client.providers.netty.util.HttpUtils.isWebSocket;
19-
import static com.ning.http.util.MiscUtils.buildStaticException;
19+
import static com.ning.http.util.MiscUtils.buildStaticIOException;
2020
import static org.jboss.netty.channel.Channels.pipeline;
2121
import static org.jboss.netty.handler.ssl.SslHandler.getDefaultBufferPool;
2222

@@ -123,9 +123,9 @@ public ChannelManager(AsyncHttpClientConfig config, NettyAsyncHttpProviderConfig
123123
}
124124
this.channelPool = channelPool;
125125

126-
tooManyConnections = buildStaticException(String.format("Too many connections %s", config.getMaxConnections()));
127-
tooManyConnectionsPerHost = buildStaticException(String.format("Too many connections per host %s", config.getMaxConnectionsPerHost()));
128-
poolAlreadyClosed = buildStaticException("Pool is already closed");
126+
tooManyConnections = buildStaticIOException(String.format("Too many connections %s", config.getMaxConnections()));
127+
tooManyConnectionsPerHost = buildStaticIOException(String.format("Too many connections per host %s", config.getMaxConnectionsPerHost()));
128+
poolAlreadyClosed = buildStaticIOException("Pool is already closed");
129129
maxTotalConnectionsEnabled = config.getMaxConnections() > 0;
130130
maxConnectionsPerHostEnabled = config.getMaxConnectionsPerHost() > 0;
131131

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
*/
1414
package com.ning.http.client.providers.netty.handler;
1515

16+
import static com.ning.http.util.MiscUtils.buildStaticIOException;
17+
1618
import org.jboss.netty.channel.Channel;
1719
import org.jboss.netty.channel.ChannelHandlerContext;
1820
import org.jboss.netty.channel.ChannelStateEvent;
@@ -40,10 +42,7 @@ public class Processor extends SimpleChannelUpstreamHandler {
4042

4143
private static final Logger LOGGER = LoggerFactory.getLogger(Processor.class);
4244

43-
public static final IOException CHANNEL_CLOSED_EXCEPTION = new IOException("Channel closed");
44-
static {
45-
CHANNEL_CLOSED_EXCEPTION.setStackTrace(new StackTraceElement[0]);
46-
}
45+
public static final IOException CHANNEL_CLOSED_EXCEPTION = buildStaticIOException("Channel closed");
4746

4847
private final AsyncHttpClientConfig config;
4948
private final ChannelManager channelManager;

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ public Protocol(ChannelManager channelManager, AsyncHttpClientConfig config, Net
8181
hasResponseFilters = !config.getResponseFilters().isEmpty();
8282
hasIOExceptionFilters = !config.getIOExceptionFilters().isEmpty();
8383
maxRedirectException = new MaxRedirectException("Maximum redirect reached: " + config.getMaxRedirects());
84-
maxRedirectException.setStackTrace(new StackTraceElement[] {});
8584
}
8685

8786
public abstract void handle(Channel channel, NettyResponseFuture<?> future, Object message) throws Exception;

src/main/java/com/ning/http/util/AsyncHttpProviderUtils.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*/
1313
package com.ning.http.util;
1414

15-
import static com.ning.http.util.MiscUtils.isNonEmpty;
15+
import static com.ning.http.util.MiscUtils.*;
1616
import static java.nio.charset.StandardCharsets.ISO_8859_1;
1717

1818
import com.ning.http.client.AsyncHttpClientConfig;
@@ -37,11 +37,7 @@
3737
*/
3838
public class AsyncHttpProviderUtils {
3939

40-
public static final IOException REMOTELY_CLOSED_EXCEPTION = new IOException("Remotely closed");
41-
42-
static {
43-
REMOTELY_CLOSED_EXCEPTION.setStackTrace(new StackTraceElement[] {});
44-
}
40+
public static final IOException REMOTELY_CLOSED_EXCEPTION = buildStaticIOException("Remotely closed");
4541

4642
public final static Charset DEFAULT_CHARSET = ISO_8859_1;
4743

src/main/java/com/ning/http/util/MiscUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public static void closeSilently(Closeable closeable) {
5858
}
5959
}
6060

61-
public static IOException buildStaticException(String message) {
61+
public static IOException buildStaticIOException(String message) {
6262
IOException ioe = new IOException(message);
6363
ioe.setStackTrace(new StackTraceElement[] {});
6464
return ioe;

0 commit comments

Comments
 (0)