From 9a49629d17e50517de5014ee569ac693b930bb49 Mon Sep 17 00:00:00 2001 From: kimchy Date: Wed, 26 May 2010 09:16:10 +0300 Subject: [PATCH] throw an exception when an action is not found --- .../ActionNotFoundTransportException.java | 15 ++++++++++++--- .../transport/netty/MessageChannelHandler.java | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/transport/ActionNotFoundTransportException.java b/modules/elasticsearch/src/main/java/org/elasticsearch/transport/ActionNotFoundTransportException.java index bb045b3a96c..a4c2fa0c2f4 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/transport/ActionNotFoundTransportException.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/transport/ActionNotFoundTransportException.java @@ -20,11 +20,20 @@ package org.elasticsearch.transport; /** - * @author kimchy (Shay Banon) + * An exception indicating that a transport action was not found. + * + * @author kimchy (shay.banon) */ public class ActionNotFoundTransportException extends TransportException { - public ActionNotFoundTransportException(String message) { - super(message); + private final String action; + + public ActionNotFoundTransportException(String action) { + super("No handler for action [" + action + "]"); + this.action = action; + } + + public String action() { + return this.action; } } 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 d1910bd8c6d..3cc3f080f8e 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 @@ -164,7 +164,7 @@ public class MessageChannelHandler extends SimpleChannelUpstreamHandler { try { final TransportRequestHandler handler = transportServiceAdapter.handler(action); if (handler == null) { - logger.warn("No handler found for action [{}]", action); + throw new ActionNotFoundTransportException(action); } final Streamable streamable = handler.newInstance(); streamable.readFrom(buffer);