You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by Gohan <ha...@gmail.com> on 2007/08/07 15:17:29 UTC

Is sessionClosed called after exceptionCaught?

Hi, 

Could anyone answer to the question stated in the topic?

Thanks
-- 
View this message in context: http://www.nabble.com/Is-sessionClosed-called-after-exceptionCaught--tf4230055s16868.html#a12034063
Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.


Re: Is sessionClosed called after exceptionCaught?

Posted by Mark <el...@gmail.com>.
Not unless you tell your program to do so.

-- 
..Cheers
Mark

On 8/7/07, Gohan <ha...@gmail.com> wrote:
>
>
> Hi,
>
> Could anyone answer to the question stated in the topic?
>
> Thanks
> --
> View this message in context:
> http://www.nabble.com/Is-sessionClosed-called-after-exceptionCaught--tf4230055s16868.html#a12034063
> Sent from the Apache MINA Support Forum mailing list archive at Nabble.com
> .
>
>

Re: Is sessionClosed called after exceptionCaught?

Posted by mat <fo...@gmail.com>.
I believe you have to call it by yourself.

http://svn.apache.org/viewvc/mina/branches/1.0/example/src/main/java/org/apache/mina/example/echoserver/EchoProtocolHandler.java?revision=555855&view=markup

On 8/7/07, Gohan <ha...@gmail.com> wrote:
>
>
> Hi,
>
> Could anyone answer to the question stated in the topic?
>
> Thanks
> --
> View this message in context:
> http://www.nabble.com/Is-sessionClosed-called-after-exceptionCaught--tf4230055s16868.html#a12034063
> Sent from the Apache MINA Support Forum mailing list archive at Nabble.com
> .
>
>

Re: Is sessionClosed called after exceptionCaught?

Posted by Mark <el...@gmail.com>.
No.  You have to call sessionClosed() yourself if you would like.  The MINA
framework provides you that level of flexibility and you may use it as you
wish.

-- 
..Cheers
Mark

On 8/7/07, Gohan <ha...@gmail.com> wrote:
>
>
> Hi,
>
> When implementing a subclass of IoHandlerAdapter, is sessionClosed(..)
> always called even after exceptionCaught(..) has been called? The reason
> I'm
> asking is because I wonder if I have to call my "cleanup" method in both
> sessionClosed(..) and exceptionCaught(..) or if it's enough to just call
> it
> in sessionClosed(..).
>
> Thanks
> --
> View this message in context:
> http://www.nabble.com/Is-sessionClosed-called-after-exceptionCaught--tf4230055s16868.html#a12034063
> Sent from the Apache MINA Support Forum mailing list archive at Nabble.com
> .
>
>

Re: Is sessionClosed called after exceptionCaught?

Posted by Trustin Lee <tr...@gmail.com>.
On 8/8/07, mat <fo...@gmail.com> wrote:
>   public void exceptionCaught(IoSession session, Throwable cause) {
>        cause.printStackTrace();
>
>        if (cause instanceof IOException)
>           return;
>
>        session.close();
>    }

It's OK to call session.close() many times, so you don't need the if block.

HTH,
Trustin
-- 
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6

Re: Is sessionClosed called after exceptionCaught?

Posted by mat <fo...@gmail.com>.
   public void exceptionCaught(IoSession session, Throwable cause) {
        cause.printStackTrace();

        if (cause instanceof IOException)
           return;

        session.close();
    }



On 8/8/07, Trustin Lee <tr...@gmail.com> wrote:
>
> On 8/7/07, Gohan <ha...@gmail.com> wrote:
> >
> > Hi,
> >
> > When implementing a subclass of IoHandlerAdapter, is sessionClosed(..)
> > always called even after exceptionCaught(..) has been called? The reason
> I'm
> > asking is because I wonder if I have to call my "cleanup" method in both
> > sessionClosed(..) and exceptionCaught(..) or if it's enough to just call
> it
> > in sessionClosed(..).
>
> If the caught exception is an IOException, the connection is closed
> automatically, and consequently, sessionClosed() will be invoked.
>
> Otherwise, you could call session.close() in exceptionCaught().
>
> HTH,
> Trustin
> --
> what we call human nature is actually human habit
> --
> http://gleamynode.net/
> --
> PGP Key ID: 0x0255ECA6
>

Re: Is sessionClosed called after exceptionCaught?

Posted by Trustin Lee <tr...@gmail.com>.
On 8/7/07, Gohan <ha...@gmail.com> wrote:
>
> Hi,
>
> When implementing a subclass of IoHandlerAdapter, is sessionClosed(..)
> always called even after exceptionCaught(..) has been called? The reason I'm
> asking is because I wonder if I have to call my "cleanup" method in both
> sessionClosed(..) and exceptionCaught(..) or if it's enough to just call it
> in sessionClosed(..).

If the caught exception is an IOException, the connection is closed
automatically, and consequently, sessionClosed() will be invoked.

Otherwise, you could call session.close() in exceptionCaught().

HTH,
Trustin
-- 
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6