DWR

Grizzly Continuation resume being called before flush completes

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Normal Normal
  • Resolution: Fixed
  • Affects Version/s: 2.0.1, 2.0.2, 2.0.3, 2.0.4, 2.0.5, 2.0.6, 2.0.7, 3.0.M1, 3.0.RC1, 3.0.RC2
  • Fix Version/s: 3.0.RC3
  • Component/s: Reverse Ajax
  • Documentation Required:
    No
  • Description:
    Hide
    GrizzlyContinuationSleeper.wakeUp

           case SLEEPING:
              ....
                        // Flush bytes (if any) first before resuming as
                        // Grizzly Comet isn't allowing writes once the
                        // continuation is resumed.
                        onAwakening.run();
                        continuation.resume();
                    }
              ...

    From the comments Grizzly does not allow writes once the continuation has been resumed. However, the call to run will return immediately so the continuation is being resumed before everything has been flushed to the browser (in onAwakening.run()).

    Please see:
    [dwr-users] Re: "No data received from server" from Explorer and Firefox
    Show
    GrizzlyContinuationSleeper.wakeUp        case SLEEPING:           ....                     // Flush bytes (if any) first before resuming as                     // Grizzly Comet isn't allowing writes once the                     // continuation is resumed.                     onAwakening.run();                     continuation.resume();                 }           ... From the comments Grizzly does not allow writes once the continuation has been resumed. However, the call to run will return immediately so the continuation is being resumed before everything has been flushed to the browser (in onAwakening.run()). Please see: [dwr-users] Re: "No data received from server" from Explorer and Firefox

Activity

Hide
David Marginian added a comment - 12/Sep/11 4:33 AM

Per the description the reason for this is resume was being called on the continuation before onAwakening.run() had executed.

Old Code:
onAwakening.run();
continuation.resume();

I fixed this (still need to get this reviewed by the team) by using an executor and Future to only resume the continuation when onAwakening.run() had finished executing:

// Flush bytes (if any) first before resuming as
// Grizzly Comet isn't allowing writes once the
// continuation is resumed.
ExecutorService executor = Executors.newFixedThreadPool(1);
Future<?> submit = executor.submit(onAwakening);
if (!Thread.currentThread().isInterrupted()) { // Wait for onAwakening to complete. submit.get(); // It is now ok to resume. continuation.resume(); }

Show
David Marginian added a comment - 12/Sep/11 4:33 AM Per the description the reason for this is resume was being called on the continuation before onAwakening.run() had executed. Old Code: onAwakening.run(); continuation.resume(); I fixed this (still need to get this reviewed by the team) by using an executor and Future to only resume the continuation when onAwakening.run() had finished executing: // Flush bytes (if any) first before resuming as // Grizzly Comet isn't allowing writes once the // continuation is resumed. ExecutorService executor = Executors.newFixedThreadPool(1); Future<?> submit = executor.submit(onAwakening); if (!Thread.currentThread().isInterrupted()) { // Wait for onAwakening to complete. submit.get(); // It is now ok to resume. continuation.resume(); }
Hide
David Marginian added a comment - 12/Dec/11 5:11 PM

Mike, this fix is checked in. Can you review the code (GrizzlyContinuationSleeper) and resolve if everything looks ok?

Show
David Marginian added a comment - 12/Dec/11 5:11 PM Mike, this fix is checked in. Can you review the code (GrizzlyContinuationSleeper) and resolve if everything looks ok?

People

Dates

  • Created:
    07/Sep/11 6:03 AM
    Updated:
    29/Nov/12 3:55 PM
    Resolved:
    29/Nov/12 3:55 PM