Mehdisouid / google-api-java-client

Automatically exported from code.google.com/p/google-api-java-client
0 stars 0 forks source link

Batch requests should allow null callbacks #620

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Version of google-api-java-client (e.g. 1.5.0-beta)?

HEAD

Java environment (e.g. Java 6, Android 2.3, App Engine)?

App Engine

Describe the problem.

I'd like to perform a batch request, but I don't particularly care about the 
respective responses. I essentially want to "fire and forget" a series of API 
requests.

Currently I'm calling:

BatchRequest batch = compute.batch();
for (...) {
  compute.instances().insert(...).queue(batch, null);
}
batch.execute();

This results in an NPE because of a Preconditions.checkNotNull check on the 
callback:
java.lang.NullPointerException
    at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:193)
    at com.google.api.client.googleapis.batch.BatchRequest.queue(BatchRequest.java:161)
    at com.google.api.services.compute.Compute$Instances$Insert.queue(Compute.java:2642)

How would you expect it to be fixed?

Either remove the checkNotNull check, or provide another queue() method that 
doesn't take a callback. Ideally requests that don't configure a callback would 
also skip parsing of the response entirely, since nothing downstream requires 
any details of the response.

This would lead to clearer more succinct code than the current working 
alternative, which is to define a no-op JsonBatchCallback instance that does 
nothing.

Original issue reported on code.google.com by jasonhall@google.com on 1 Oct 2012 at 4:31

GoogleCodeExporter commented 9 years ago

Original comment by yan...@google.com on 2 Oct 2012 at 1:53

GoogleCodeExporter commented 9 years ago

Original comment by rmis...@google.com on 12 Dec 2012 at 2:41

GoogleCodeExporter commented 9 years ago

Original comment by yan...@google.com on 22 Jan 2013 at 4:14

GoogleCodeExporter commented 9 years ago

Original comment by yan...@google.com on 7 Feb 2013 at 12:05

GoogleCodeExporter commented 9 years ago

Original comment by yan...@google.com on 10 Jun 2013 at 1:29

GoogleCodeExporter commented 9 years ago

Original comment by yan...@google.com on 21 Jun 2013 at 2:06

GoogleCodeExporter commented 9 years ago

Original comment by pele...@google.com on 29 Jul 2013 at 6:08

GoogleCodeExporter commented 9 years ago

Original comment by yan...@google.com on 27 Sep 2013 at 12:03