You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by Ashish <pa...@gmail.com> on 2008/11/29 13:47:53 UTC

Use of IoHandler -> exceptionCaught()

The documentation says

**
Invoked when any exception is thrown by user {@link IoHandler}
implementation or by MINA.  If <code>cause</code> is an instance of
{@link IOException}, MINA will close the connection automatically

**

The fact that I am trying to understand here is about Exception
handling strategy in MINA while decoding protocol specific bytes
and there are violations in packet structure.

Will exceptionCaught() be called if Protocol Decoder throws an
exception or it shall handle only. IoHandler's are typically meant to
handle business logic.
So if there is an error while decoding an error,
1. Is it okay to throw an error from the decoder and process it in
exceptionCaught().

Are there other scenarios where this function can be used

-- 
thanks
ashish

Blog: http://www.ashishpaliwal.com/blog

My Photo Galleries: http://www.pbase.com/ashishpaliwal

Re: Use of IoHandler -> exceptionCaught()

Posted by Ashish <pa...@gmail.com>.
Thanks! it a bit clear now. Let me experiment with it.

On Sat, Nov 29, 2008 at 7:00 PM, Emmanuel Lecharny <el...@gmail.com> wrote:
> Hi Ashish,
>
> Ashish wrote:
>>
>> The documentation says
>>
>> **
>> Invoked when any exception is thrown by user {@link IoHandler}
>> implementation or by MINA.  If <code>cause</code> is an instance of
>> {@link IOException}, MINA will close the connection automatically
>>
>> **
>>
>> The fact that I am trying to understand here is about Exception
>> handling strategy in MINA while decoding protocol specific bytes
>> and there are violations in packet structure.
>>
>> Will exceptionCaught() be called if Protocol Decoder throws an
>> exception or it shall handle only. IoHandler's are typically meant to
>> handle business logic.
>> So if there is an error while decoding an error,
>> 1. Is it okay to throw an error from the decoder and process it in
>> exceptionCaught().
>>
>> Are there other scenarios where this function can be used
>>
>
> I must say that this is an area where the semantic of the ExceptionCaught
> message is everything but clear. It needs to be clarified in 3.0, for sure.
>
> Obviously, an error while decoding a message could lead to the session
> closing, but this should be optional (ie, it's up to the application to
> decide what to do).
>
> In any case, the exceptionCaught message is just generate to allow all the
> filters (and the handler) to clean what need to be cleaned, as the exception
> will not be caaught by the filters (unless someone want to modify the
> existing filters ...), so this is the only way to propagate the exception
> correctly.
>
>
> --
> --
> cordialement, regards,
> Emmanuel Lécharny
> www.iktek.com
> directory.apache.org
>
>
>



-- 
thanks
ashish

Blog: http://www.ashishpaliwal.com/blog

My Photo Galleries: http://www.pbase.com/ashishpaliwal

Re: Use of IoHandler -> exceptionCaught()

Posted by Emmanuel Lecharny <el...@gmail.com>.
Hi Ashish,

Ashish wrote:
> The documentation says
>
> **
> Invoked when any exception is thrown by user {@link IoHandler}
> implementation or by MINA.  If <code>cause</code> is an instance of
> {@link IOException}, MINA will close the connection automatically
>
> **
>
> The fact that I am trying to understand here is about Exception
> handling strategy in MINA while decoding protocol specific bytes
> and there are violations in packet structure.
>
> Will exceptionCaught() be called if Protocol Decoder throws an
> exception or it shall handle only. IoHandler's are typically meant to
> handle business logic.
> So if there is an error while decoding an error,
> 1. Is it okay to throw an error from the decoder and process it in
> exceptionCaught().
>
> Are there other scenarios where this function can be used
>   
I must say that this is an area where the semantic of the 
ExceptionCaught message is everything but clear. It needs to be 
clarified in 3.0, for sure.

Obviously, an error while decoding a message could lead to the session 
closing, but this should be optional (ie, it's up to the application to 
decide what to do).

In any case, the exceptionCaught message is just generate to allow all 
the filters (and the handler) to clean what need to be cleaned, as the 
exception will not be caaught by the filters (unless someone want to 
modify the existing filters ...), so this is the only way to propagate 
the exception correctly.


-- 
--
cordialement, regards,
Emmanuel Lécharny
www.iktek.com
directory.apache.org