Hi David,
sorry to say, but it looks like bigger issue in Grizzly 1.9.x.
When you don't read all the request bytes before resuming the response -
Grizzly tries to read the remaining bytes, but it's possible Grizzly
will read data from the next request and here the problem comes.
The fix doesn't look trivial at all.
I can suggest you either use Grizzly 2.x, which should work fine for
that scenario,
or, workaround the issue by setting header (Connection: close) for
cases, where you don't suppose to read all the input bytes. For example:
@Override
public void service( Request req, Response res ) throws Exception
{
int read;
if( rejected )
{
res.setStatus( 509 );
res.setMessage( "[Simple] Sorry but I don't want to process
it ! It's my choice !" );
------ HERE --->>>>> res.setHeader("Connection", "close");
}
else
{
// Write somewhere the content of the request
while( (read=req.doRead(bc))!=-1 )
{
os.write( bc.getBuffer(), bc.getStart(), read );
}
// Simulate some more time consuming operation
Thread.sleep( 1500 );
// Respond
res.setStatus( 200 );
res.setMessage( "[Simple] Ok, understand" );
}
}
Thanks.
WBR,
Alexey.
On 07/06/2011 07:09 PM, Gay David (Annecy) wrote:
>
> Ho, I see.
>
> Yes, I modify the test but I put the same name as the previous one for
> the archive.
>
> Here is the new archive in attachement.
>
> Thanks
>
> David
>
> *De :*Oleksiy Stashok [mailto:oleksiy.stashok_at_oracle.com]
> *Envoyé :* mercredi 6 juillet 2011 19:02
> *À :* users_at_grizzly.java.net
> *Objet :* Re: Grizzly Suspend
>
> Are you using the same test? Cause I wasn't able to reproduce the NPE
> with the latest 1.9.37-SNAPSHOT.
> If you have updated test - pls. send it.
>
> Thanks.
>
> WBR,
> Alexey.
>
> On 07/06/2011 06:55 PM, Gay David (Annecy) wrote:
>
> Hi,
>
> No I've got the errors with the latest 1.9.37-SNAPSHOT and 1.9.36.
>
> Thanks
>
> David
>
> *De :*Oleksiy Stashok [mailto:oleksiy.stashok_at_oracle.com]
> *Envoyé :* mercredi 6 juillet 2011 18:50
> *À :* users_at_grizzly.java.net <mailto:users_at_grizzly.java.net>
> *Objet :* Re: Grizzly Suspend
>
> Hi David,
>
> just to make sure, does everything work fine with 1.9.37-SNAPSHOT?
>
> Thanks.
>
> Alexey.
>
> On 07/06/2011 10:50 AM, Gay David (Annecy) wrote:
>
> Oups, bad info : I just reproduce the same errors with Grizzly 1.9.36
>
> Regards
>
> David
>
> *De :*Gay David (Annecy) [mailto:dgay_at_axway.com]
> *Envoyé :* mercredi 6 juillet 2011 10:47
> *À :* users_at_grizzly.java.net <mailto:users_at_grizzly.java.net>
> *Objet :* RE: Grizzly Suspend
>
> Hi Alexey,
>
> Thanks for your quick reply and fix.
>
> I manage to checkout the trunk : I had to fight a little bit with GIT,
> cause it's pretty new for me, but it's ok now :-)
>
> Unfortunately, I still have the error "Invalid chunk header" error in
> my application server.
>
> So, I modify the test to better reflect what is done : you can see
> that it mix simple Adapter and GrizzlyAdapter.
>
> That's the case in the application server.
>
> When I run this test against the 1.9.37-SNAPSHOT I see these errors :
>
> GRAVE: GRIZZLY0040: Request header is too large.
>
> java.nio.BufferOverflowException
>
> at
> com.sun.grizzly.tcp.http11.InternalInputBuffer.fill(InternalInputBuffer.java:765)
>
> at
> com.sun.grizzly.tcp.http11.InternalInputBuffer.parseHeader(InternalInputBuffer.java:615)
>
> at
> com.sun.grizzly.tcp.http11.InternalInputBuffer.parseHeaders(InternalInputBuffer.java:555)
>
> at
> com.sun.grizzly.http.ProcessorTask.parseRequest(ProcessorTask.java:881)
>
> at
> com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:692)
>
> at
> com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1022)
>
> at
> com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
>
> at
> com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
>
> at
> com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
>
> at
> com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
>
> at
> com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
>
> at
> com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
>
> and
>
> GRAVE: GRIZZLY0051: ProcessorTask exception.
>
> java.lang.NullPointerException
>
> at
> com.sun.grizzly.http.SocketChannelOutputBuffer.setSelectionKey(SocketChannelOutputBuffer.java:211)
>
> at
> com.sun.grizzly.http.ProcessorTask.postProcess(ProcessorTask.java:966)
>
> at
> com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1023)
>
> at
> com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
>
> at
> com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
>
> at
> com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
>
> at
> com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
>
> at
> com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
>
> at
> com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
>
> at
> com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
>
> at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
>
> at
> com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
>
> at
> com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
>
> at java.lang.Thread.run(Thread.java:662)
>
> It's still not my "Invalid chunk header" but, it may be related ?
>
> Is there a problem in my code here ?
>
> BTW : I try to re-run this test against 1.9.36 several times, without
> seeing any problem (even if I still have the "Invalid chunk header" in
> my server)
>
> Thanks again for your help
>
> Regards
>
> David
>
> *De :*Oleksiy Stashok [mailto:oleksiy.stashok_at_oracle.com]
> *Envoyé :* lundi 4 juillet 2011 16:07
> *À :* users_at_grizzly.java.net <mailto:users_at_grizzly.java.net>
> *Objet :* Re: Grizzly Suspend
>
> Hi David,
>
> thanks a lot for the testcase!
> We've fixed it [1] on the trunk. Fix is going to be available in the
> next 1.9.37 release.
>
> Thanks.
>
> WBR,
> Alexey.
>
> [1] http://java.net/jira/browse/GRIZZLY-1035
>
> ...
>