users@grizzly.java.net

Re: Async or not async, this is the problem

From: Jeanfrancois Arcand <Jeanfrancois.Arcand_at_Sun.COM>
Date: Wed, 17 Dec 2008 14:09:53 -0500

Salut,

rama wrote:
> on this snapshot problem is still present
> -- grizzly-http-webserver-1.9.2-20081217.130345-9.jar
>
>
> Probably it will take until tomorrow to see the correct snapshot?

Hum....Still seeing the exception(NPE) or no output? Strange....

A+

-- Jeanfrancois


> i haven't all the stuff to build the jar from svn here, i am afraid, i
> will try @ office tomorrow :)
>
> but, if in this snapshot problem should be fixed, probably it's not, so
> maybe the test had some usage :D
>
> let me know if in this snapshot the problem should be fixed, and i will
> try to send more information :)
>
>
> Il giorno 17/dic/08, alle ore 18:29, Jeanfrancois Arcand ha scritto:
>
>> 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
>>> <mailto:users-unsubscribe_at_grizzly.dev.java.net>
>>> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>>> <mailto:users-help_at_grizzly.dev.java.net>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
>> <mailto:users-unsubscribe_at_grizzly.dev.java.net>
>> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>> <mailto:users-help_at_grizzly.dev.java.net>
>>
>