mina-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Emmanuel Lécharny <elecha...@gmail.com>
Subject Re: proper handling of errors in IoHandler.messageReceived()?
Date Sat, 21 Jul 2012 18:33:43 GMT
Le 7/21/12 6:43 PM, mark@smartmonsters.com a écrit :
> What are the best practices for handling errors in
> IoHandler.messageReceived()?
> Example: if either input parameter is null, should you simply return?
> Throw a new NPE?  Etc.
Well, it's really up to the application coder to know how to react when 
you get an error.

Keep in mind that the messageReceived() call is just a way to inform the 
IoHandler (the application endpoint) that a new message has arrived. 
MINA knows absolutely *nothing* about it.

Now, if the message you have received is checked and is seen as invalid, 
then again, it's up to your application to react accordingly to what 
your application is supposed to do when a message has been received.

Just ask yourself this question :
"if the client has just directly called messageReceived() directly 
without going through MINA, how should the application react?"

I can just say that you can :
- close the session
- send back an error message to the client
- ignore the message
- try to fix the message and process it
- have your application totally blow... :)

Hope that helps...

Emmanuel Lécharny

View raw message