users@grizzly.java.net

Re: How to implement the client's message flow based on async read/write?

From: John ROM <snake-john_at_gmx.de>
Date: Mon, 16 Jun 2008 13:49:56 +0200

Hi Yi,

maybe Alexy could also look at this?

In HttpResponseParserFilter you have a
public boolean releaseBuffer() {
                savedBuffer = null;
            return true;
}

This leads to
com.sun.grizzly.filter.ParserProtocolFilter.saveParser(SelectionKey key, ProtocolParser parser)
which overwrites anything in the SelectionKey which is not under the control of WorkerThread.

So in your Code you need something like:
AttributeHolder ah = ctx.getAttributeHolderByScope(AttributeScope.CONNECTION);

if (ah == null) {
      ah=((WorkerThread) Thread.currentThread()).getAttachment();
      tx.getSelectionKey().attach(ah);
}

Anyway with your code in a real situation you may also run into other problems,
because your write("Get.Http..") will be called on any Selection.Key.OP_READ event
Probably something you do not want...

Many Greetings
John

-- 
Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! 
Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer