Hello,
working like a charm now!
Thanks!
Rama
> Hi Rama,
>
> it's my mistake, in prev. sample I suggested you to use something like:
>
> 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;
>
> which wasn't (and isn't) correct, please return the INTERRUPT result, not FINISH.
> You're actually completing/finishing the task by calling:
> asyncExecutor.getAsyncTask().doTask();
>
>
> so by returning the INTERRUPT - you just tell the current thread and executor to forget about this task (cause it has been processed).
>
> Thanks.
>
> WBR,
> Alexey.
>
> On 04/21/2011 03:00 PM, rama.rama wrote:
>> Hello guys,
>>
>> i am facing a strange problem with 1.9.34-servlet-http
>>
>> as always, a test case at the end of the email will be useful to check it.
>>
>> basically, that's what i have do
>> 1. create a gws with async/std
>> 2. add an empty async (that will just make request proceed)
>> 3. add a normal adapter that will send out a file, wihtout too many chech
>>
>>
>> now, if you create an empty html, this will work like a charm.
>> if you create this html
>> <html>
>> <head>
>> <link href="inc/css/text_content.css" rel="stylesheet" type="text/css" />
>> <link href="inc/css/text_content_custom.css" rel="stylesheet" type="text/css" />
>>
>> </head>
>> <body>
>>
>> </body>
>> </html>
>>
>> and do 2-3 request, everyhing stop to work...
>> probably because this will do 2 requests chained after the 1st one (html after begin parsed, ask for the 2 css)
>>
>> ah, and no, the issue isn't that i am serving always the same file, nor is relative to the browser, i have try
>> with chrome, safari and ff 3 and 4.
>>
>> I have simplify the test case, obviusly mine was a fully working webservices (working with 1.9.19)
>> here i have stiripped out a lot of stuff..
>> you can make it serve the 'correct' file using uri, but this isn't really necessary in this test.
>>
>> hope that this small example help you to catch what's happen
>> (the code have some other testing stuff on it, sorry guys)
>>
>> Rama
>>
>> ------------------------------------------------------------------------------------------------------------------------------------------------
>> 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 {
>> StringBuilder someJunk = new StringBuilder();
>> grizzlyResponse.setContentType(MimeType.get("html"));
>>
>>
>>
>> for (int i = 0; i< 10; i++) someJunk.append(someJunk);
>>
>> FileInputStream fis = new FileInputStream(new File("/Users/ramarama/IdeaProject/c2w_test/c2w/default/test.html"));
>> byte b[] = new byte[32768];
>> ByteChunk chunk = new ByteChunk();
>> int rd;
>> while ((rd = fis.read(b))> 0) {
>> chunk.setBytes(b, 0, rd);
>> grizzlyResponse.getResponse().doWrite(chunk);
>> }
>>
>>
>> req.incrementAndGet();
>> } catch (IOException e) {
>>
>> }
>> }
>> }
>>
>>
>> }
>>
>