users@grizzly.java.net

Re: Async or not async, this is the problem

From: Patrick Julien <pjulien_at_gmail.com>
Date: Wed, 17 Dec 2008 12:57:18 -0500

On Wed, Dec 17, 2008 at 12:29 PM, Jeanfrancois Arcand
<Jeanfrancois.Arcand_at_sun.com> wrote:
> Salut,
>
> I think it is fixed now. I've added two new unit tests which helped me
> reproduce your issue. Can you try and let me know?
>
> Thanks for your help!!
>
> -- Jeanfrancois
>
> Jeanfrancois Arcand wrote:
>>
>> Salut,
>>
>> give me 1 hour and I will fix the issue. Meanwhile can you file an issue
>> explaining that the response is not flushed?
>>
>> https://grizzly.dev.java.net/issues/
>>
>> Thanks!
>>
>> -- Jeanfrancois
>>
>>
>> rama wrote:
>>>
>>> |you have find a bug :-) Just add response.flushBuffer() after your write
>>> and that will works. I will fix that ASAP.
>>>
>>>>
>>>> I've missed that one. Can you increate the suspend timeout (put 10 000)
>>>> as I suspect you have a race here.
>>>>
>>>>
>>>
>>>
>>> sure, here is a new "version" of the test
>>> As you can see, the sleep in the thread is 10.000, i have "removed" the
>>> static from fakeSession, and create a new one (this is just a test)
>>> i got the "start" when fakesession thread startup, and i got the "resume"
>>> when fakesession thread resume the request...but i don't get nothing
>>> on output....
>>>
>>>
>>> and, after adding the flushbuffer, i got...
>>>
>>> Exception in thread "Thread-2" _java.lang.NullPointerException_
>>> at
>>> com.sun.grizzly.http.DefaultProcessorTask.action(_DefaultProcessorTask.java:1049_)
>>> at com.sun.grizzly.tcp.Response.action(_Response.java:253_)
>>> at com.sun.grizzly.tcp.Response.doWrite(_Response.java:653_)
>>> at
>>> com.sun.grizzly.tcp.http11.GrizzlyOutputBuffer.realWriteBytes(_GrizzlyOutputBuffer.java:468_)
>>> at com.sun.grizzly.util.buf.ByteChunk.flushBuffer(_ByteChunk.java:433_)
>>> at
>>> com.sun.grizzly.util.buf.C2BConverter.flushBuffer(_C2BConverter.java:197_)
>>> at
>>> com.sun.grizzly.tcp.http11.GrizzlyOutputBuffer.realWriteChars(_GrizzlyOutputBuffer.java:667_)
>>> at com.sun.grizzly.util.buf.CharChunk.flushBuffer(_CharChunk.java:467_)
>>> at
>>> com.sun.grizzly.tcp.http11.GrizzlyOutputBuffer.doFlush(_GrizzlyOutputBuffer.java:418_)
>>> at
>>> com.sun.grizzly.tcp.http11.GrizzlyOutputBuffer.flush(_GrizzlyOutputBuffer.java:401_)
>>> at
>>> com.sun.grizzly.tcp.http11.GrizzlyWriter.flush(_GrizzlyWriter.java:133_)
>>> at Webserver$1.service(_Webserver.java:27_)
>>> at Webserver$1$1.resumed(_Webserver.java:43_)
>>> at Webserver$1$1.resumed(_Webserver.java:1_)
>>> at
>>> com.sun.grizzly.tcp.Response$ResponseAttachment.resume(_Response.java:901_)
>>> at com.sun.grizzly.tcp.Response.resume(_Response.java:738_)
>>> at
>>> com.sun.grizzly.tcp.http11.GrizzlyResponse.resume(_GrizzlyResponse.java:1555_)
>>> at Webserver$FakeSession.run(_Webserver.java:72_)
>>>
>>>
>>> public class Webserver {
>>>
>>> public static void main(String[] args) {
>>> try {
>>>
>>>
>>> GrizzlyWebServer ws = new GrizzlyWebServer();
>>> ws.addGrizzlyAdapter(new GrizzlyAdapter() {
>>> public void service(final GrizzlyRequest req, final GrizzlyResponse res)
>>> {
>>> if (res.isSuspended()) {
>>> try {
>>> res.getWriter().println("rama stupid");
>>> res.flushBuffer();
>>> } catch (IOException e) {
>>> e.printStackTrace();
>>> }
>>> return;
>>> } System.out.println("REQ "+req.getRequestURI()+"
>>> "+Thread.currentThread().toString());
>>> FakeSession s = new FakeSession();
>>> s.res = res;
>>> s.start();
>>> res.suspend(50000, this, new CompletionHandler<GrizzlyAdapter>() {
>>> public void cancelled(GrizzlyAdapter arg0) {
>>>
>>>
>>> }
>>> public void resumed(GrizzlyAdapter arg0) {
>>> System.out.println("RESUME");
>>> arg0.service(req, res);
>>> try {
>>> arg0.afterService(req, res);
>>> } catch (Exception e) {
>>> // TODO Auto-generated catch block
>>> e.printStackTrace();
>>> }
>>> }
>>> });
>>>
>>> }
>>> }, new String[]{});
>>> ws.start();
>>> } catch (IOException ex){
>>> // Something when wrong.
>>> } }
>>>
>>>
>>> static class FakeSession extends Thread {
>>> protected GrizzlyResponse res;
>>>
>>>
>>> public void run() {
>>> try {
>>> System.out.println("START");
>>> Thread.sleep(10000);
>>> } catch (InterruptedException e) {
>>> // TODO Auto-generated catch block
>>> e.printStackTrace();
>>> }
>>> res.resume();
>>> }
>>> }
>>>
>>>
>>> }
>>>
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
>> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>
>



-- 
http://www.spectrumdt.com
http://codepimps.org