Canged behaviour of AnnotationSupport to throw an exception on message not matched

This commit is contained in:
selva.andre
2014-08-18 22:57:53 +02:00
parent 4fe7b6754c
commit 98f04859ab
@@ -52,21 +52,18 @@ class AnnotationSupport {
* Dispatch a call to the wrapped target invoking the method that match the * Dispatch a call to the wrapped target invoking the method that match the
* msg class. * 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()); Method targetMethod = this.messageClassToMethod.get(msg.getClass());
if (targetMethod == null) { if (targetMethod == null) {
return false; throw new RuntimeException("Can't dispatch to any @MQTTMessage marked the message: " + msg);
} }
try { try {
targetMethod.invoke(targetInstance, session, msg); targetMethod.invoke(targetInstance, session, msg);
} catch (Exception ex) { } catch (Exception ex) {
throw new RuntimeException(ex); throw new RuntimeException(ex);
} }
return true;
} }
} }