You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by Wilson Yeung <wi...@gmail.com> on 2008/02/15 02:21:49 UTC

exception in OrderedThreadPoolExecutor

After sending a bunch of UDP datagrams, sleep for 30 seconds, then
this gets printed to console:

     [java] Exception in thread "pool-1-thread-1" java.lang.NullPointerException
     [java] 	at
org.apache.mina.filter.executor.OrderedThreadPoolExecutor.getSessionBuffer(OrderedThreadPoolExecutor.java:447)
     [java] 	at
org.apache.mina.filter.executor.OrderedThreadPoolExecutor.access$900(OrderedThreadPoolExecutor.java:52)
     [java] 	at
org.apache.mina.filter.executor.OrderedThreadPoolExecutor$Worker.run(OrderedThreadPoolExecutor.java:492)
     [java] 	at java.lang.Thread.run(Thread.java:613)

And then no more messages are ever sent despite how I might try.

If I modify OrderedThreadPoolExecutor like so:

clara:executor wilson$ svn diff OrderedThreadPoolExecutor.java
Index: OrderedThreadPoolExecutor.java
===================================================================
--- OrderedThreadPoolExecutor.java	(revision 627903)
+++ OrderedThreadPoolExecutor.java	(working copy)
@@ -489,7 +489,9 @@
                     }

                     try {
-                        runTasks(getSessionBuffer(session));
+                       if (session != null) {
+                            runTasks(getSessionBuffer(session));
+                        }
                     } finally {
                         idleWorkers.incrementAndGet();
                     }

Then all is well.  Any ideas?  Am I abusing Mina, or is it an honest
to goodness Mina bug?

Wilson

Re: exception in OrderedThreadPoolExecutor

Posted by "이희승 (Trustin Lee)" <tr...@gmail.com>.
2008-02-20 (수), 20:36 +0900, 이희승 (Trustin Lee) 쓰시길:
> 2008-02-20 (수), 08:23 +0100, Niklas Therning 쓰시길:
> > Wilson Yeung wrote:
> > > After sending a bunch of UDP datagrams, sleep for 30 seconds, then
> > > this gets printed to console:
> > >
> > >      [java] Exception in thread "pool-1-thread-1" java.lang.NullPointerException
> > >      [java] 	at
> > > org.apache.mina.filter.executor.OrderedThreadPoolExecutor.getSessionBuffer(OrderedThreadPoolExecutor.java:447)
> > >      [java] 	at
> > > org.apache.mina.filter.executor.OrderedThreadPoolExecutor.access$900(OrderedThreadPoolExecutor.java:52)
> > >      [java] 	at
> > > org.apache.mina.filter.executor.OrderedThreadPoolExecutor$Worker.run(OrderedThreadPoolExecutor.java:492)
> > >      [java] 	at java.lang.Thread.run(Thread.java:613)
> > >
> > > And then no more messages are ever sent despite how I might try.
> > >
> > > If I modify OrderedThreadPoolExecutor like so:
> > >
> > > clara:executor wilson$ svn diff OrderedThreadPoolExecutor.java
> > > Index: OrderedThreadPoolExecutor.java
> > > ===================================================================
> > > --- OrderedThreadPoolExecutor.java	(revision 627903)
> > > +++ OrderedThreadPoolExecutor.java	(working copy)
> > > @@ -489,7 +489,9 @@
> > >                      }
> > >
> > >                      try {
> > > -                        runTasks(getSessionBuffer(session));
> > > +                       if (session != null) {
> > > +                            runTasks(getSessionBuffer(session));
> > > +                        }
> > >                      } finally {
> > >                          idleWorkers.incrementAndGet();
> > >                      }
> > >
> > > Then all is well.  Any ideas?  Am I abusing Mina, or is it an honest
> > > to goodness Mina bug?
> > >
> > > Wilson
> > >   
> > 
> > Do you have a test case which triggers this problem? You should open up 
> > a JIRA issue and attach your test case and we will have a look at it.
> 
> The stack trace Wilson provided is very weird.  According to the trace,
> it seems like OrderedThreadPoolExecutor.getSessionBuffer() throws a NPE
> because the specified session is null.  The specified session is get
> from IoEvent object.  Now if you look into the IoEvent class, its
> constructor throws NPE if the specified session is null.  This means
> that the session parameter that is passed to
> OrderedThreadPoolExecutor.getSessionBuffer() cannot be null at all.
> 
> So.. any clue? :(

Ugh... my reasoning was wrong.  It's
OrderedThreadPoolExecutor.fetchSession() that returns null, and it's
possible.  Wilson's patch looks reasonable.  Let me fix it soon...

Thanks,
-- 
Trustin Lee - Principal Software Engineer, JBoss, Red Hat
--
what we call human nature is actually human habit
--
http://gleamynode.net/

Re: exception in OrderedThreadPoolExecutor

Posted by "이희승 (Trustin Lee)" <tr...@gmail.com>.
2008-02-20 (수), 08:23 +0100, Niklas Therning 쓰시길:
> Wilson Yeung wrote:
> > After sending a bunch of UDP datagrams, sleep for 30 seconds, then
> > this gets printed to console:
> >
> >      [java] Exception in thread "pool-1-thread-1" java.lang.NullPointerException
> >      [java] 	at
> > org.apache.mina.filter.executor.OrderedThreadPoolExecutor.getSessionBuffer(OrderedThreadPoolExecutor.java:447)
> >      [java] 	at
> > org.apache.mina.filter.executor.OrderedThreadPoolExecutor.access$900(OrderedThreadPoolExecutor.java:52)
> >      [java] 	at
> > org.apache.mina.filter.executor.OrderedThreadPoolExecutor$Worker.run(OrderedThreadPoolExecutor.java:492)
> >      [java] 	at java.lang.Thread.run(Thread.java:613)
> >
> > And then no more messages are ever sent despite how I might try.
> >
> > If I modify OrderedThreadPoolExecutor like so:
> >
> > clara:executor wilson$ svn diff OrderedThreadPoolExecutor.java
> > Index: OrderedThreadPoolExecutor.java
> > ===================================================================
> > --- OrderedThreadPoolExecutor.java	(revision 627903)
> > +++ OrderedThreadPoolExecutor.java	(working copy)
> > @@ -489,7 +489,9 @@
> >                      }
> >
> >                      try {
> > -                        runTasks(getSessionBuffer(session));
> > +                       if (session != null) {
> > +                            runTasks(getSessionBuffer(session));
> > +                        }
> >                      } finally {
> >                          idleWorkers.incrementAndGet();
> >                      }
> >
> > Then all is well.  Any ideas?  Am I abusing Mina, or is it an honest
> > to goodness Mina bug?
> >
> > Wilson
> >   
> 
> Do you have a test case which triggers this problem? You should open up 
> a JIRA issue and attach your test case and we will have a look at it.

The stack trace Wilson provided is very weird.  According to the trace,
it seems like OrderedThreadPoolExecutor.getSessionBuffer() throws a NPE
because the specified session is null.  The specified session is get
from IoEvent object.  Now if you look into the IoEvent class, its
constructor throws NPE if the specified session is null.  This means
that the session parameter that is passed to
OrderedThreadPoolExecutor.getSessionBuffer() cannot be null at all.

So.. any clue? :(
-- 
Trustin Lee - Principal Software Engineer, JBoss, Red Hat
--
what we call human nature is actually human habit
--
http://gleamynode.net/

Re: exception in OrderedThreadPoolExecutor

Posted by Niklas Therning <ni...@trillian.se>.
Wilson Yeung wrote:
> After sending a bunch of UDP datagrams, sleep for 30 seconds, then
> this gets printed to console:
>
>      [java] Exception in thread "pool-1-thread-1" java.lang.NullPointerException
>      [java] 	at
> org.apache.mina.filter.executor.OrderedThreadPoolExecutor.getSessionBuffer(OrderedThreadPoolExecutor.java:447)
>      [java] 	at
> org.apache.mina.filter.executor.OrderedThreadPoolExecutor.access$900(OrderedThreadPoolExecutor.java:52)
>      [java] 	at
> org.apache.mina.filter.executor.OrderedThreadPoolExecutor$Worker.run(OrderedThreadPoolExecutor.java:492)
>      [java] 	at java.lang.Thread.run(Thread.java:613)
>
> And then no more messages are ever sent despite how I might try.
>
> If I modify OrderedThreadPoolExecutor like so:
>
> clara:executor wilson$ svn diff OrderedThreadPoolExecutor.java
> Index: OrderedThreadPoolExecutor.java
> ===================================================================
> --- OrderedThreadPoolExecutor.java	(revision 627903)
> +++ OrderedThreadPoolExecutor.java	(working copy)
> @@ -489,7 +489,9 @@
>                      }
>
>                      try {
> -                        runTasks(getSessionBuffer(session));
> +                       if (session != null) {
> +                            runTasks(getSessionBuffer(session));
> +                        }
>                      } finally {
>                          idleWorkers.incrementAndGet();
>                      }
>
> Then all is well.  Any ideas?  Am I abusing Mina, or is it an honest
> to goodness Mina bug?
>
> Wilson
>   

Do you have a test case which triggers this problem? You should open up 
a JIRA issue and attach your test case and we will have a look at it.

/Niklas