hugoloza / gwt-platform

Automatically exported from code.google.com/p/gwt-platform
0 stars 0 forks source link

Calling DispatchRequest.Cancel() with CachingClientHandler blocks all subsequent requests. #272

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Calling Cancel() in a DispatchRequest when using the 
AbstractCachingClientActionHandler blocks all subsequent request for the same 
action and onSuccess() is never called.

Now, AbstractCachingClientActionHandler.execute() buffers all requests for the 
same action so that only one callback is dispatched (for the first request). 
Thus, when the callback succeeds or fails, all pending requests are called.

The problem is that if the first request is cancelled, onFailure() or 
onSuccess() are never called, and the ArrayList for the action is never freed 
and requests get continuosly added to the array (and no callback is made).

Possible solution:
If the first request is cancelled, the whole array gets useless so it could be 
completely cleared.
If any other request is cancelled, the present behavior is ok.

The check for the array could be modified with:

    if (pendingRequestCallbacks != null) {
        // Has the first request been cancelled
        if ( pendingRequestCallbacks.size() > 0 && !pendingRequestCallbacks.get(0).isPending() )
            pendingRequestCallbacks.clear();
        else {
            CallbackDispatchRequest<R> callbackDispatchRequest = new DefaultCallbackDispatchRequest<R>(resultCallback);

            // Add callback to pending list and return
            pendingRequestCallbacks.add(callbackDispatchRequest);

            return callbackDispatchRequest;
        }
    }

Or perhaps we could implement something so the rest of the requests are still 
usable. A new callback could be fired with the present request.

Which would be the best approach?

Original issue reported on code.google.com by chemamol...@gmail.com on 7 Jan 2011 at 2:33

GoogleCodeExporter commented 9 years ago

Original comment by philippe.beaudoin on 25 Jan 2011 at 6:40

GoogleCodeExporter commented 9 years ago
Bumping to 0.7, preparing release 0.6.

Original comment by philippe.beaudoin on 6 Jun 2011 at 8:17

GoogleCodeExporter commented 9 years ago

Original comment by philippe.beaudoin on 1 Feb 2012 at 6:52