mina-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff MAURY <jeffma...@jeffmaury.com>
Subject Re: response null in multi threaded
Date Wed, 30 Oct 2013 10:02:04 GMT
Your code is wrong because you swallow the interrupted exception, so you
will call getMessage even if you got a timeout condition  hence the null
value returned.

Jeff


On Wed, Oct 30, 2013 at 10:40 AM, Joachim Rodrigues <
rodrigues.joachim@gmail.com> wrote:

> Hi I'm working on a multi threaded project that create about 200
> simltaneous threads.
> For each thread i have a mina connection to a server.
>
> And sometimes when retrieving the response,  the object response  is null
>
>
>         Object response = null;
>
>         session.write(frame);
>         if (frame.isWaitForResponse()) {
>             ReadFuture read = session.read();
>             try {
>                 read.await(collectorResponseTimeOut);
>             } catch (InterruptedException e) {
>                 e.printStackTrace();
>
>             }
>             response = read.getMessage();
>
>
>
> it stoped to be null when i added
>
>              response.getClass();
>
> at the end, just after  response = read.getMessage();
> Then no more null objects.
>
> Does anyone knows why ?
>
>
> Thanks
>



-- 
Jeff MAURY


"Legacy code" often differs from its suggested alternative by actually
working and scaling.
 - Bjarne Stroustrup

http://www.jeffmaury.com
http://riadiscuss.jeffmaury.com
http://www.twitter.com/jeffmaury

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message