Le 7/21/12 6:43 PM, [email protected] 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...


--
Regards,
Cordialement,
Emmanuel Lécharny
www.iktek.com

Reply via email to