On 2/11/08 4:16 PM, "Jeanfrancois Arcand" <Jeanfrancois.Arcand_at_Sun.COM>
wrote:
>
>
> Erik Svensson wrote:
>> A question here:
>>
>> In DefaultProtocolChainInstanceHandler
>> the method poll looks like:
>>
>> public ProtocolChain poll() {
>> ProtocolChain protocolChain = protocolChains.poll();
>> if (protocolChain == null){
>> protocolChain = new DefaultProtocolChain();
>> }
>> return protocolChain;
>> }
>>
>> Should there be a 'offer(protocolChain)' here?
>>
>> public ProtocolChain poll() {
>> ProtocolChain protocolChain = protocolChains.poll();
>> if (protocolChain == null){
>> protocolChain = new DefaultProtocolChain();
>> // PATCH
>> offer(protocolChain);
>> // END PATCH
>> }
>> return protocolChain;
>> }
>>
>> Otherwise a new protocolchain will be created everytime poll is called
>> unless one is manually added through offer.
>
> The contract here is when you do poll, you also invoke the
> DefaultProtocolChainInstanceHandler.offer() method. But you found a bug
> in Grizzly as the offer method is never called!!
>
> Originally, the offer() method was called...looks like we lost it
> between 1.5.x and 1.7.1! Let me re-add it so your stuff can work. Now
> Your patch will not work as two thread might ends up with the same
> protocol chain, and since the protocol chain are stateful, we will get
> data corruption.
Yes, I noticed that. I need to think out some other way to cut down the code
needed to set things up before I can give this to my co-developers.
cheers
Erik Svensson, SIX AB