Uploaded image for project: 'MINA'
  1. MINA
  2. DIRMINA-533

NPE in OrderedThreadPoolExecutor and UnorderedThreadPoolExecutor

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0.0-M1
    • 2.0.0-M2
    • Filter
    • None

    Description

      Quoted from the mailing list:

      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...

      Attachments

        Activity

          trustin Trustin Lee added a comment -

          Wilson's patch has been applied both to UnorederedThreadPoolExecutor and OrderedThreadPoolExecutor.

          trustin Trustin Lee added a comment - Wilson's patch has been applied both to UnorederedThreadPoolExecutor and OrderedThreadPoolExecutor.

          People

            trustin Trustin Lee
            trustin Trustin Lee
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: