Mehdisouid / google-api-java-client

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

NullPointerException on error when doing resumable media upload #673

Closed GoogleCodeExporter closed 9 years ago

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

1.12.0-beta

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

Any

Describe the problem.

Reported by a customer, when doing media upload to the Storage API, they are 
getting this NullPointerException:

java.lang.NullPointerException
    at java.net.URI$Parser.parse(URI.java:3023)
    at java.net.URI.<init>(URI.java:595)
    at com.google.api.client.http.GenericUrl.<init>(GenericUrl.java:100)
    at com.google.api.client.googleapis.media.MediaHttpUploader.upload(MediaHttpUploader.java:269)
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:572)
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:492)
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:621)

Doing another kind of request to the same API with the same authorization 
information results in this error:

com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden
{
  "code" : 403,
  "errors" : [ {
    "domain" : "usageLimits",
    "message" : "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.",
    "reason" : "dailyLimitExceededUnreg",
    "extendedHelp" : "https://code.google.com/apis/console",
}]}

So most likely the upload initiation results in a 403 error as well.  The 
NullPointerException is being thrown on this line in MediaHttpUploader:

      uploadUrl = new GenericUrl(initialResponse.getHeaders().getLocation());

How would you expect it to be fixed?

Instead of throwing a NullPointerException, we should just return the 
HttpResponse on !initialResponse.isSuccessStatusCode().

Original issue reported on code.google.com by yan...@google.com on 3 Dec 2012 at 7:23

GoogleCodeExporter commented 9 years ago
https://codereview.appspot.com/6852066/

Original comment by rmis...@google.com on 5 Dec 2012 at 4:44

GoogleCodeExporter commented 9 years ago

Original comment by rmis...@google.com on 10 Dec 2012 at 2:19