So, IoHandler.messageReceived() is unrelated to MINA lifecycle, and errors handled "incorrectly" there will have no impact on MINA, although possibly on the application. Assuming I understand that correctly, thanks much for the response.
Emmanuel Lécharny <[email protected]> 07/21/2012 11:33 AM Please respond to users To: [email protected] cc: Subject: Re: proper handling of errors in IoHandler.messageReceived()? 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
