luvcjssy / google-api-java-client

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

MediaHttpUploader.serverErrorCallback() does not work if data has been partially or fully uploaded #772

Closed GoogleCodeExporter closed 9 years ago

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

1.14.1-beta

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

All

Describe the problem.

See:
http://javadoc.google-api-java-client.googlecode.com/hg/1.14.1-beta/com/google/a
pi/client/googleapis/media/MediaHttpUploader.html#serverErrorCallback()

I added a test in 
MediaHttpUploaderTest.testUpload_ResumableIOExceptionWithIOExceptionHandler to 
demonstrate what happens if data has been partially or fully uploaded despite 
the I/O exception.

I can actually reproduce this running against the production server.  I 
modified the drive-cmdline-sample by adding an HttpRequestInitializer that sets 
request.setReadTimeout(100) on the first upload call.  It actually uploads the 
whole thing, but it still times out and throws an I/O exception.  It then 
either throws an IllegalArgumentException or IllegalStateException depending on 
whether we know the content length.

While you are at it, we also need to deal with the possibility of the server 
error callback returning an OK response with the JSON metadata.  At least the 
documentation claims it is possible, but we should try to verify by testing it 
against the production server.

How would you expect it to be fixed?

This is potentially non-trivial because we also need to be sensitive to the 
chunk size.  My understanding is that the Google server requires the chunk size 
to be a certain multiple of 256KB.  Alternatively, we may want to respect the 
chunk size that the developer requested.  There is also the case of fully 
uploaded, in which case we need to just continue with the next chunk entirely.

Original issue reported on code.google.com by yan...@google.com on 23 Apr 2013 at 2:58

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

Original comment by pele...@google.com on 21 May 2013 at 9:30

GoogleCodeExporter commented 9 years ago

Original comment by pele...@google.com on 25 Jun 2013 at 6:57