users@grizzly.java.net

Re: grizzly 1.9.x async question

From: Rama <ramarro28_at_gmail.com>
Date: Tue, 22 Nov 2011 15:26:14 +0100

java.nio.charset.UnsupportedCharsetException: a
        at java.nio.charset.Charset.forName(Charset.java:505)
        at com.sun.grizzly.util.Utils.lookupCharset(Utils.java:81)
        at com.sun.grizzly.util.buf.B2CConverter.init(B2CConverter.java:112)
        at com.sun.grizzly.util.buf.B2CConverter.<init>(B2CConverter.java:101)
        at com.sun.grizzly.tcp.http11.GrizzlyInputBuffer.setConverter(GrizzlyInputBuffer.java:596)
        at com.sun.grizzly.tcp.http11.GrizzlyInputBuffer.checkConverter(GrizzlyInputBuffer.java:562)
        at com.sun.grizzly.tcp.http11.GrizzlyRequest.getReader(GrizzlyRequest.java:1065)
        at test.DemoWebServer$MyGrizzlyAdapter.service(DemoWebServer.java:73)
        at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:179)
        at com.sun.grizzly.tcp.http11.GrizzlyAdapterChain.service(GrizzlyAdapterChain.java:196)
        at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:179)
        at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:833)
        at com.sun.grizzly.arp.DefaultAsyncExecutor.execute(DefaultAsyncExecutor.java:159)
        at test.DemoWebServer$MyAsyncFilter.doFilter(DemoWebServer.java:52)
        at com.sun.grizzly.arp.DefaultAsyncExecutor.invokeFilters(DefaultAsyncExecutor.java:171)
        at com.sun.grizzly.arp.DefaultAsyncExecutor.interrupt(DefaultAsyncExecutor.java:143)
        at com.sun.grizzly.arp.AsyncProcessorTask.doTask(AsyncProcessorTask.java:99)
        at com.sun.grizzly.http.TaskBase.run(TaskBase.java:193)
        at com.sun.grizzly.http.TaskBase.execute(TaskBase.java:175)
        at com.sun.grizzly.arp.DefaultAsyncHandler.handle(DefaultAsyncHandler.java:145)
        at com.sun.grizzly.arp.AsyncProtocolFilter.execute(AsyncProtocolFilter.java:210)
        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:680)
----
public class DemoWebServer {
    static final AtomicInteger req = new AtomicInteger();
    public static void main(String args[]) {
        GrizzlyWebServer test = new GrizzlyWebServer(7777,
"/Users/ramarama/IdeaProject/c2w_test/c2w/default/");
        test.addGrizzlyAdapter(new MyGrizzlyAdapter(), new String[]{"/"});
        test.getSelectorThread().setDisplayConfiguration(true);
        test.getSelectorThread().setCompression("on");
        test.getSelectorThread().setKeepAliveTimeoutInSeconds(-1);
        test.getSelectorThread().setMaxKeepAliveRequests(-1);
        test.addAsyncFilter(new MyAsyncFilter());
        try {
            test.start();
        } catch (IOException e) {
            e.printStackTrace();  //To change body of catch statement
use File | Settings | File Templates.
        }
        while (true) {
            try {
                Thread.sleep(20500);
            } catch (Exception e) {
            }
        }
    }
    static class MyAsyncFilter implements AsyncFilter {
        public Result doFilter(final AsyncExecutor asyncExecutor) {
                try {
                    asyncExecutor.execute();
                    asyncExecutor.getAsyncTask().doTask();
                } catch (Exception e) {
                    e.printStackTrace();  //To change body of catch
statement use File | Settings | File Templates.
                }
                return Result.FINISH;
        }
    }
    static class MyGrizzlyAdapter extends GrizzlyAdapter {
        public MyGrizzlyAdapter() {
            this.setHandleStaticResources(false);
        }
        public void service(GrizzlyRequest grizzlyRequest,
GrizzlyResponse grizzlyResponse) {
            try {
                grizzlyRequest.setCharacterEncoding("UTF-8");
                grizzlyRequest.getReader();
                grizzlyResponse.getWriter().write("suca");
            } catch (IOException e) {
            }
        }
    }
}
2011/11/22 Oleksiy Stashok <oleksiy.stashok_at_oracle.com>:
> Hi Rama,
>
> It's very weird :(
> can you pls. give us the testcase to reproduce this?
>
> Thanks.
>
> WBR,
> Alexey.
>
>
> On 11/22/2011 03:05 PM, Rama wrote:
>>
>> Hi Alexey,
>>
>> i run into a big ussue with 1.9.41, making me impossible to test it :(
>>
>> Seems that there was some change on how httpReq.getReader(); is
>> handled (or on how headers is handled)
>>
>> i got an exception "invalid character encoding 'a' " while doing
>> getReader() if the client is flash player.
>>
>> with 1.9.36 there isn't such problem.
>>
>> Also, on java.net the pages of gws are outdated (javadoc+source code +
>> repos with jars) and i wasn't able to crawl on
>> source code to get track a bit better the issue.
>>
>> imho, there is some default character encoding handling (maybe when
>> missing on request) and this default is 'a' that sound quite strange
>> to me.
>>
>> Ciao,
>> R.
>>
>> 2011/11/21 Oleksiy Stashok<oleksiy.stashok_at_oracle.com>:
>>>
>>> Hi Rama,
>>>
>>> 1.9.41 has been released, artifacts could be found on the maven central
>>> http://repo1.maven.org/
>>>
>>> WBR,
>>> Alexey.
>>>
>>> On 11/18/2011 02:10 PM, Rama wrote:
>>>>
>>>> Sure, there is a .jar for that?
>>>>
>>>> warm regards
>>>>
>>>>
>>>> 2011/11/14 Oleksiy Stashok<oleksiy.stashok_at_oracle.com>:
>>>>>
>>>>> Hi Rama,
>>>>>
>>>>> can you pls. check the latest 1.9.41-SNAPSHOT?
>>>>>
>>>>> Thanks.
>>>>>
>>>>> WBR,
>>>>> Alexey.
>>>>>
>>>>> On 11/14/2011 02:05 PM, Oleksiy Stashok wrote:
>>>>>>
>>>>>> Hi Rama,
>>>>>>
>>>>>> it's a bug, I mean (1), the (2), IMO, comes from (1).
>>>>>> Can I ask you to file an issue?
>>>>>>
>>>>>> I will fix it asap.
>>>>>>
>>>>>> Thank you.
>>>>>>
>>>>>> WBR,
>>>>>> Alexey.
>>>>>>
>>>>>> On 11/14/2011 10:41 AM, Rama wrote:
>>>>>>>
>>>>>>> Hi there, i have some question regarding async adapter in gws 1.9.X
>>>>>>> series.
>>>>>>>
>>>>>>>
>>>>>>> let's suppose that i'll chain a AsyncFilter to my webserver and i
>>>>>>> suspend the request as follow (pseudocode)
>>>>>>>
>>>>>>>
>>>>>>> public Result doFilter(AsyncExecutor asyncExecutor) {
>>>>>>> queue.add(asyncExecutor,System.currenttimemillis());
>>>>>>>  return Result.INTERRUPT;
>>>>>>> }
>>>>>>>
>>>>>>>
>>>>>>> later i'll iterate on the queue and i'll check if the timeout is>
>>>>>>> than 30.000 and if yes, i'll execute the request
>>>>>>>
>>>>>>> if (systemcurrent>      eta+30000) {
>>>>>>>             a.execute();
>>>>>>>             a.getAsyncTask().doTask();
>>>>>>> }
>>>>>>>
>>>>>>>
>>>>>>> basically i expect that all the requests get delayed by 30sec, but
>>>>>>> this doesn't happen :(
>>>>>>> on safari for istance, request get delayed by 20sec (no idea why)
>>>>>>>
>>>>>>>
>>>>>>> Also, if i set
>>>>>>> "this.getSelectorThread().setKeepAliveTimeoutInSeconds(1);"
>>>>>>> i got connection closed
>>>>>>> on client side.
>>>>>>>
>>>>>>> Why keepalive is related to the async stuff?
>>>>>>> If yes, what's happen when i reach the max_keepalive_num_request with
>>>>>>> async?!?
>>>>>>>
>>>>>>> honestly i don't get why keepalivetimeout influence async stuff.
>>>>>>>
>>>>>>>
>>>>>>> So basically, summarizing the questions
>>>>>>>
>>>>>>> 1) why keepalive_timeout influence async request?
>>>>>>> 2) why async request finish BEFORE what they should? there is any
>>>>>>> parsing related to browser header that i don't get?
>>>>>>>
>>>>>>>
>>>>>>> tnx!
>>>
>
>