Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Batch requests should allow null callbacks #620

Open
GoogleCodeExporter opened this issue Mar 2, 2015 · 8 comments
Open

Batch requests should allow null callbacks #620

GoogleCodeExporter opened this issue Mar 2, 2015 · 8 comments

Comments

@GoogleCodeExporter
Copy link

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
Copy link
Author

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

  • Changed state: Accepted
  • Added labels: Milestone-Version1.13.0

@GoogleCodeExporter
Copy link
Author

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

  • Added labels: Milestone-Version1.14.0
  • Removed labels: Milestone-Version1.13.0

@GoogleCodeExporter
Copy link
Author

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

  • Added labels: Type-Enhancement, Milestone-Version2.1.0
  • Removed labels: Type-Defect, Milestone-Version1.14.0

@GoogleCodeExporter
Copy link
Author

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

  • Added labels: Milestone-Version1.16.0
  • Removed labels: Milestone-Version2.1.0

@GoogleCodeExporter
Copy link
Author

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

  • Added labels: Component-HTTP

@GoogleCodeExporter
Copy link
Author

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

  • Added labels: Milestone-Version1.17.0
  • Removed labels: Milestone-Version1.16.0

@GoogleCodeExporter
Copy link
Author

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

  • Added labels: Milestone-Version1.18.0
  • Removed labels: Milestone-Version1.17.0

@GoogleCodeExporter
Copy link
Author

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

  • Removed labels: Milestone-Version1.18.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant