mina-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Emmanuel Lecharny <elecha...@gmail.com>
Subject Re: mina 2.0.2: sporadic NPE in SimpleIoProcessorPool.add
Date Tue, 05 Apr 2011 09:48:26 GMT
On 4/5/11 11:33 AM, Francis ANDRE wrote:
> Hi Developers
>
>
>
> I got sporadic NPE as follow. Has someone an idea of the context that could
> lead to such NPE so I can try to find out how to always reproduce this NPE??

It can occurs in rare cases where the service is disposed, as the pool 
will be cleared (at least, this is what I can infer from the code).

Here is the code that generates a NPE :

     public final void add(S session) {
         getProcessor(session).add(session);
     }

     private IoProcessor<S> getProcessor(S session) {
         IoProcessor<S> processor = (IoProcessor<S>) 
session.getAttribute(PROCESSOR);

         if (processor == null) {
             if (disposed || disposing) {
                 throw new IllegalStateException("A disposed processor 
cannot be accessed.");
             }

             processor = pool[Math.abs((int) session.getId()) % 
pool.length]; /// --> Here, if the pool is cleared, we will get a null 
processor
             session.setAttributeIfAbsent(PROCESSOR, processor);
         }

         return processor;
     }


and the part that clear the pool :

     public final void dispose() {
         if (disposed) {
             return;
         }

         synchronized (disposalLock) {
             ...
             Arrays.fill(pool, null); /// -->> Here, the pool will now 
contain nulls
             disposed = true;
         }
     }


-- 
Regards,
Cordialement,
Emmanuel L├ęcharny
www.iktek.com


Mime
View raw message