Issue 870 in google-api-java-client: cancel a pending server request

4 views
Skip to first unread message

google-api-...@googlecode.com

unread,
Apr 11, 2014, 2:13:43 PM4/11/14
to google-api-jav...@googlegroups.com
Status: New
Owner: wonder...@google.com
Labels: Type-Enhancement Priority-Medium

New issue 870 by ptuc...@google.com: cancel a pending server request
http://code.google.com/p/google-api-java-client/issues/detail?id=870

External references, such as a standards document, or specification?
Similar API:
https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Synchronous_and_Asynchronous_Requests

Java environments (e.g. Java 6, Android 2.3, App Engine, or All)?
Java & Android for my case, but it would be appropriate for All.

Please describe the feature requested.
I would like to be able to cancel a request generated by
com.google.api.client.googleapis.services.AbstractGoogleClient.
This probably would require an executeAsync method parallel to
AbstractGoogleClientRequest.execute. An AbstractGoogleClient.cancelAll
method would work for my case (ie, cancel all pending requests generated by
that client), but that's not as clean an API.


--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

google-api-...@googlecode.com

unread,
Dec 30, 2014, 11:40:43 AM12/30/14
to google-api-jav...@googlegroups.com
Updates:
Status: WontFix
Labels: -Priority-Medium Priority-low

Comment #1 on issue 870 by wonder...@google.com: cancel a pending server
request
https://code.google.com/p/google-api-java-client/issues/detail?id=870

Canceling an HTTP request that has been sent on the wire is not a good
idea. The only way to do this is by closing the connection, but the server
may never know that the client has closed so it may continue doing what
it's doing. This wastes resources and introduces network latencies.

Adding such an interface requires changes at both ends, and is difficult to
implement based on HTTP. If you really want to cancel an ongoing request,
you could call HttpRequest.executeAsync(), get a Future, and abandon it
once it times out. But again, this may cause resource waste at the server
side.

google-api-...@googlecode.com

unread,
Dec 30, 2014, 1:08:09 PM12/30/14
to google-api-jav...@googlegroups.com

Comment #2 on issue 870 by ptuc...@google.com: cancel a pending server
request
https://code.google.com/p/google-api-java-client/issues/detail?id=870

Right, that's why I recommended "an executeAsync method parallel to
AbstractGoogleClientRequest.execute".

google-api-...@googlecode.com

unread,
Dec 30, 2014, 1:49:41 PM12/30/14
to google-api-jav...@googlegroups.com

Comment #3 on issue 870 by wonder...@google.com: cancel a pending server
request
https://code.google.com/p/google-api-java-client/issues/detail?id=870

There's an executeAsync() method implemented by the underlining HttpRequest
[1], you can get access to it by calling
AbstractGoogleClientRequest.buildHttpRequest() [2].

Although named as executeAsync(), it's not a true async interface. But it
should be sufficient for your case.

[1]
https://code.google.com/p/google-http-java-client/source/browse/google-http-client/src/main/java/com/google/api/client/http/HttpRequest.java#1071
[2]
https://code.google.com/p/google-api-java-client/source/browse/google-api-client/src/main/java/com/google/api/client/googleapis/services/AbstractGoogleClientRequest.java#276
Reply all
Reply to author
Forward
0 new messages