From a10ab7fe0813d40c39f342c95ff249077862c256 Mon Sep 17 00:00:00 2001 From: kimchy Date: Fri, 27 Aug 2010 14:14:28 +0300 Subject: [PATCH] better exception thrown when failing to handle responses --- .../elasticsearch/common/collect/BoundedTreeSet.java | 4 +++- .../ResponseHandlerFailureTransportException.java | 12 ++++-------- .../elasticsearch/transport/TransportException.java | 2 +- .../transport/local/LocalTransport.java | 4 ++-- .../transport/netty/MessageChannelHandler.java | 6 +++--- 5 files changed, 13 insertions(+), 15 deletions(-) diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/common/collect/BoundedTreeSet.java b/modules/elasticsearch/src/main/java/org/elasticsearch/common/collect/BoundedTreeSet.java index 9c9d936df6f..4c5a292956c 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/common/collect/BoundedTreeSet.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/common/collect/BoundedTreeSet.java @@ -24,7 +24,9 @@ import java.util.Comparator; import java.util.TreeSet; /** - * @author kimchy (Shay Banon) + * A {@link TreeSet} that is bounded by size. + * + * @author kimchy (shay.banon) */ public class BoundedTreeSet extends TreeSet { diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/transport/ResponseHandlerFailureTransportException.java b/modules/elasticsearch/src/main/java/org/elasticsearch/transport/ResponseHandlerFailureTransportException.java index 79b8a19ea80..af5f60867dd 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/transport/ResponseHandlerFailureTransportException.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/transport/ResponseHandlerFailureTransportException.java @@ -20,15 +20,11 @@ package org.elasticsearch.transport; /** - * @author kimchy (Shay Banon) + * @author kimchy (shay.banon) */ -public class ResponseHandlerFailureTransportException extends TransportException { +public class ResponseHandlerFailureTransportException extends RemoteTransportException { - public ResponseHandlerFailureTransportException(String msg) { - super(msg); - } - - public ResponseHandlerFailureTransportException(String msg, Throwable cause) { - super(msg, cause); + public ResponseHandlerFailureTransportException(Throwable cause) { + super(cause.getMessage(), cause); } } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/transport/TransportException.java b/modules/elasticsearch/src/main/java/org/elasticsearch/transport/TransportException.java index 6da3521530e..eac11a8ee6d 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/transport/TransportException.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/transport/TransportException.java @@ -22,7 +22,7 @@ package org.elasticsearch.transport; import org.elasticsearch.ElasticSearchException; /** - * @author kimchy (Shay Banon) + * @author kimchy (shay.banon) */ public class TransportException extends ElasticSearchException { diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/transport/local/LocalTransport.java b/modules/elasticsearch/src/main/java/org/elasticsearch/transport/local/LocalTransport.java index 1ee8784c756..ff6d23a0f28 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/transport/local/LocalTransport.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/transport/local/LocalTransport.java @@ -237,7 +237,7 @@ public class LocalTransport extends AbstractLifecycleComponent implem try { handler.handleResponse(streamable); } catch (Exception e) { - handleException(handler, new ResponseHandlerFailureTransportException("Failed to handle response", e)); + handleException(handler, new ResponseHandlerFailureTransportException(e)); } } }); @@ -246,7 +246,7 @@ public class LocalTransport extends AbstractLifecycleComponent implem //noinspection unchecked handler.handleResponse(streamable); } catch (Exception e) { - handleException(handler, new ResponseHandlerFailureTransportException("Failed to handle response", e)); + handleException(handler, new ResponseHandlerFailureTransportException(e)); } } } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/transport/netty/MessageChannelHandler.java b/modules/elasticsearch/src/main/java/org/elasticsearch/transport/netty/MessageChannelHandler.java index 8b13085b8dc..2654fb80470 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/transport/netty/MessageChannelHandler.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/transport/netty/MessageChannelHandler.java @@ -133,7 +133,7 @@ public class MessageChannelHandler extends SimpleChannelUpstreamHandler { try { handler.handleResponse(streamable); } catch (Exception e) { - handleException(handler, new ResponseHandlerFailureTransportException("Failed to handle response", e)); + handleException(handler, new ResponseHandlerFailureTransportException(e)); } } }); @@ -142,7 +142,7 @@ public class MessageChannelHandler extends SimpleChannelUpstreamHandler { handler.handleResponse(streamable); } } catch (Exception e) { - handleException(handler, new ResponseHandlerFailureTransportException("Failed to handle response", e)); + handleException(handler, new ResponseHandlerFailureTransportException(e)); } } @@ -159,7 +159,7 @@ public class MessageChannelHandler extends SimpleChannelUpstreamHandler { private void handleException(final TransportResponseHandler handler, Throwable error) { if (!(error instanceof RemoteTransportException)) { - error = new RemoteTransportException("None remote transport exception", error); + error = new RemoteTransportException(error.getMessage(), error); } final RemoteTransportException rtx = (RemoteTransportException) error; if (handler.spawn()) {