better handling of failures in transport to catch assertions
make sure we also catch assertions (well Throwable) in our transport layer and properly log or callback the exception handler in that case
This commit is contained in:
parent
68ce3eff04
commit
29d337c44b
|
@ -182,7 +182,7 @@ public class TransportService extends AbstractLifecycleComponent<TransportServic
|
|||
}
|
||||
clientHandlers.put(requestId, new RequestHolder<T>(handler, node, action, timeoutHandler));
|
||||
transport.sendRequest(node, requestId, action, request, options);
|
||||
} catch (final Exception e) {
|
||||
} catch (final Throwable e) {
|
||||
// usually happen either because we failed to connect to the node
|
||||
// or because we failed serializing the message
|
||||
clientHandlers.remove(requestId);
|
||||
|
|
|
@ -208,11 +208,11 @@ public class LocalTransport extends AbstractLifecycleComponent<Transport> implem
|
|||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
} catch (Throwable e) {
|
||||
if (sendRequestId != null) {
|
||||
TransportResponseHandler handler = transportServiceAdapter.remove(sendRequestId);
|
||||
if (handler != null) {
|
||||
handler.handleException(new RemoteTransportException(nodeName(), localAddress, action, e));
|
||||
handleException(handler, new RemoteTransportException(nodeName(), localAddress, action, e));
|
||||
}
|
||||
} else {
|
||||
logger.warn("Failed to receive message for action [" + action + "]", e);
|
||||
|
@ -246,7 +246,7 @@ public class LocalTransport extends AbstractLifecycleComponent<Transport> implem
|
|||
final TransportResponse response = handler.newInstance();
|
||||
try {
|
||||
response.readFrom(buffer);
|
||||
} catch (Exception e) {
|
||||
} catch (Throwable e) {
|
||||
handleException(handler, new TransportSerializationException("Failed to deserialize response of type [" + response.getClass().getName() + "]", e));
|
||||
return;
|
||||
}
|
||||
|
@ -256,7 +256,7 @@ public class LocalTransport extends AbstractLifecycleComponent<Transport> implem
|
|||
public void run() {
|
||||
try {
|
||||
handler.handleResponse(response);
|
||||
} catch (Exception e) {
|
||||
} catch (Throwable e) {
|
||||
handleException(handler, new ResponseHandlerFailureTransportException(e));
|
||||
}
|
||||
}
|
||||
|
@ -279,6 +279,10 @@ public class LocalTransport extends AbstractLifecycleComponent<Transport> implem
|
|||
error = new RemoteTransportException("None remote transport exception", error);
|
||||
}
|
||||
final RemoteTransportException rtx = (RemoteTransportException) error;
|
||||
handler.handleException(rtx);
|
||||
try {
|
||||
handler.handleException(rtx);
|
||||
} catch (Throwable t) {
|
||||
logger.error("failed to handle exception response [{}]", t, handler);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -143,7 +143,7 @@ public class MessageChannelHandler extends SimpleChannelUpstreamHandler {
|
|||
final TransportResponse response = handler.newInstance();
|
||||
try {
|
||||
response.readFrom(buffer);
|
||||
} catch (Exception e) {
|
||||
} catch (Throwable e) {
|
||||
handleException(handler, new TransportSerializationException("Failed to deserialize response of type [" + response.getClass().getName() + "]", e));
|
||||
return;
|
||||
}
|
||||
|
@ -176,7 +176,11 @@ public class MessageChannelHandler extends SimpleChannelUpstreamHandler {
|
|||
}
|
||||
final RemoteTransportException rtx = (RemoteTransportException) error;
|
||||
if (handler.executor() == ThreadPool.Names.SAME) {
|
||||
handler.handleException(rtx);
|
||||
try {
|
||||
handler.handleException(rtx);
|
||||
} catch (Throwable e) {
|
||||
logger.error("failed to handle exception response [{}]", e, handler);
|
||||
}
|
||||
} else {
|
||||
threadPool.executor(handler.executor()).execute(new Runnable() {
|
||||
@Override
|
||||
|
@ -184,7 +188,7 @@ public class MessageChannelHandler extends SimpleChannelUpstreamHandler {
|
|||
try {
|
||||
handler.handleException(rtx);
|
||||
} catch (Throwable e) {
|
||||
logger.error("Failed to handle exception response", e);
|
||||
logger.error("failed to handle exception response [{}]", e, handler);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue