From 98f04859abc469878c4b3a61fe0f593e623cb22f Mon Sep 17 00:00:00 2001 From: "selva.andre" Date: Mon, 18 Aug 2014 22:57:53 +0200 Subject: [PATCH] Canged behaviour of AnnotationSupport to throw an exception on message not matched --- .../messaging/spi/impl/AnnotationSupport.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/broker/src/main/java/org/dna/mqtt/moquette/messaging/spi/impl/AnnotationSupport.java b/broker/src/main/java/org/dna/mqtt/moquette/messaging/spi/impl/AnnotationSupport.java index e676d82e..3be8836d 100644 --- a/broker/src/main/java/org/dna/mqtt/moquette/messaging/spi/impl/AnnotationSupport.java +++ b/broker/src/main/java/org/dna/mqtt/moquette/messaging/spi/impl/AnnotationSupport.java @@ -52,21 +52,18 @@ class AnnotationSupport { * Dispatch a call to the wrapped target invoking the method that match the * msg class. * - * @return true iff the dispatched method was found. + * @throws RuntimeException if the message can't be routed to any annotated method, + * or if there are any errors during invocation. */ - boolean dispatch(ServerChannel session, AbstractMessage msg) { + void dispatch(ServerChannel session, AbstractMessage msg) { Method targetMethod = this.messageClassToMethod.get(msg.getClass()); if (targetMethod == null) { - return false; + throw new RuntimeException("Can't dispatch to any @MQTTMessage marked the message: " + msg); } try { targetMethod.invoke(targetInstance, session, msg); } catch (Exception ex) { throw new RuntimeException(ex); } - - return true; } - - }