Skip to content

Commit

Permalink
Rename StackTraceInspector methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephane Landelle committed Feb 20, 2015
1 parent 8596041 commit e6db2bd
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 14 deletions.
Expand Up @@ -25,22 +25,22 @@ private static boolean exceptionInMethod(Throwable t, String className, String m
return false;
}

private static boolean abortOnConnectCloseException(Throwable t) {
private static boolean recoverOnConnectCloseException(Throwable t) {
return exceptionInMethod(t, "sun.nio.ch.SocketChannelImpl", "checkConnect")
|| (t.getCause() != null && abortOnConnectCloseException(t.getCause()));
|| (t.getCause() != null && recoverOnConnectCloseException(t.getCause()));
}

public static boolean abortOnNetty3DisconnectException(Throwable t) {
public static boolean recoverOnNetty3DisconnectException(Throwable t) {
return exceptionInMethod(t, "io.netty.handler.ssl.SslHandler", "disconnect")
|| (t.getCause() != null && abortOnConnectCloseException(t.getCause()));
|| (t.getCause() != null && recoverOnConnectCloseException(t.getCause()));
}

public static boolean abortOnNetty4DisconnectException(Throwable t) {
public static boolean recoverOnNetty4DisconnectException(Throwable t) {
return exceptionInMethod(t, "io.netty.handler.ssl.SslHandler", "disconnect")
|| (t.getCause() != null && abortOnConnectCloseException(t.getCause()));
|| (t.getCause() != null && recoverOnConnectCloseException(t.getCause()));
}

public static boolean abortOnReadOrWriteException(Throwable t) {
public static boolean recoverOnReadOrWriteException(Throwable t) {

try {
for (StackTraceElement element : t.getStackTrace()) {
Expand All @@ -53,7 +53,7 @@ public static boolean abortOnReadOrWriteException(Throwable t) {
}

if (t.getCause() != null)
return abortOnReadOrWriteException(t.getCause());
return recoverOnReadOrWriteException(t.getCause());

return false;
}
Expand Down
Expand Up @@ -158,7 +158,7 @@ public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws
}

// FIXME how does recovery occur?!
if (StackTraceInspector.abortOnReadOrWriteException(cause)) {
if (StackTraceInspector.recoverOnReadOrWriteException(cause)) {
LOGGER.debug("Trying to recover from dead Channel: {}", channel);
return;
}
Expand Down
Expand Up @@ -91,7 +91,7 @@ private void onFutureFailure(Channel channel, Throwable cause) {
LOGGER.debug("Trying to recover from failing to connect channel {} with a retry value of {} ", channel, canRetry);
if (canRetry
&& cause != null
&& (cause instanceof ClosedChannelException || future.getState() != NettyResponseFuture.STATE.NEW || StackTraceInspector.abortOnNetty3DisconnectException(cause))) {
&& (cause instanceof ClosedChannelException || future.getState() != NettyResponseFuture.STATE.NEW || StackTraceInspector.recoverOnNetty3DisconnectException(cause))) {

if (!requestSender.retry(future))
return;
Expand Down
Expand Up @@ -51,7 +51,7 @@ private boolean abortOnThrowable(Throwable cause, Channel channel) {
if (cause != null && future.getState() != NettyResponseFuture.STATE.NEW) {
// The write operation failed. If the channel was cached, it means it got asynchronously closed.
// Let's retry a second time.
if (cause instanceof IllegalStateException || cause instanceof ClosedChannelException || StackTraceInspector.abortOnReadOrWriteException(cause)) {
if (cause instanceof IllegalStateException || cause instanceof ClosedChannelException || StackTraceInspector.recoverOnReadOrWriteException(cause)) {
LOGGER.debug(cause == null ? "" : cause.getMessage(), cause);
Channels.silentlyCloseChannel(channel);

Expand Down
Expand Up @@ -141,7 +141,7 @@ public void exceptionCaught(ChannelHandlerContext ctx, Throwable e) throws Excep
}
}

if (StackTraceInspector.abortOnReadOrWriteException(cause)) {
if (StackTraceInspector.recoverOnReadOrWriteException(cause)) {
LOGGER.debug("Trying to recover from dead Channel: {}", channel);
return;
}
Expand Down
Expand Up @@ -89,7 +89,7 @@ private void onFutureFailure(Channel channel, Throwable cause) {
LOGGER.debug("Trying to recover from failing to connect channel {} with a retry value of {} ", channel, canRetry);
if (canRetry//
&& cause != null//
&& (cause instanceof ClosedChannelException || future.getState() != NettyResponseFuture.STATE.NEW || StackTraceInspector.abortOnNetty4DisconnectException(cause))) {
&& (cause instanceof ClosedChannelException || future.getState() != NettyResponseFuture.STATE.NEW || StackTraceInspector.recoverOnNetty4DisconnectException(cause))) {

if (requestSender.retry(future)) {
return;
Expand Down
Expand Up @@ -55,7 +55,7 @@ public ProgressListener(AsyncHttpClientConfig config,//
private boolean abortOnThrowable(Throwable cause, Channel channel) {

if (cause != null && future.getState() != NettyResponseFuture.STATE.NEW) {
if (cause instanceof IllegalStateException || cause instanceof ClosedChannelException || StackTraceInspector.abortOnReadOrWriteException(cause)) {
if (cause instanceof IllegalStateException || cause instanceof ClosedChannelException || StackTraceInspector.recoverOnReadOrWriteException(cause)) {
LOGGER.debug(cause.getMessage(), cause);
Channels.silentlyCloseChannel(channel);

Expand Down

0 comments on commit e6db2bd

Please sign in to comment.