users@grizzly.java.net

Re: WG: Re: Fwd: WG: Re: WG: Re: WG: Re: WG: Re: Asynchronous Request Processing with TCPIP

From: John ROM <snake-john_at_gmx.de>
Date: Wed, 09 Jul 2008 08:18:06 +0200

Hi Jeanfrancois,

because I am using Context.copyTo as an (maybe) intermediate solution.
I have an issue:

------------------ code --------------------------------
// workerCtx is current WorkerThread Context
        Context aCopy=new Context();
        
        workerCtx.getAsyncQueueWritable().writeToAsyncQueue(ByteBuffer.allocate(100));

        workerCtx.copyTo(aCopy);
        workerCtx.recycle();
        // now this causes nullpointer exception
        aCopy.getAsyncQueueWritable().writeToAsyncQueue(ByteBuffer.allocate(100));
--------------------- code -------------------------------------------
produces

java.lang.NullPointerException
        at com.sun.grizzly.Context$AsyncQueueWritableContextWrapper.writeToAsyncQueue(Context.java:685)

This is caused because copyTo copies the AsyncQueueWritableContextWrapper of workerCtx
which becomes null when workerCtx it gets recyled.

Cure is simple :

Index: Context.java
--- Context.java Base (BASE)
+++ Context.java Locally Modified (Based On LOCAL)
@@ -209,8 +209,7 @@
         copyContext.ioEvent = ioEvent;
         copyContext.asyncQueueReader = asyncQueueReader;
         copyContext.asyncQueueWriter = asyncQueueWriter;
- copyContext.asyncQueueReadable = asyncQueueReadable;
- copyContext.asyncQueueWritable = asyncQueueWritable;
+
     }
 
     /**




> That's doable, although it will be quite complicated to get the list of
> thread that are referencing that object. Or do I miss something?
>
> Thanks!
>
> -- Jeanfrancois
>
>

-- 
Psssst! Schon vom neuen GMX MultiMessenger gehört?
Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger