Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Not all bytes were read from the S3ObjectInputStream, aborting HTTP connection

Tags:

aws-java-sdk

I recently had to upgrade to aws-java-sdk 1.11.108. I have a java program that downloads s3 objects (8 to 10 GB in size) to EC2 box and process it as a stream. This program has had been working for over 2 years w/o any problems, but after updating to the latest version of aws-java-sdk my file-download aborts midway with the following WARN message in the logs (no exception)

WARN:com.amazonaws.services.s3.internal.S3AbortableInputStream - Not all bytes were read from the S3ObjectInputStream, aborting HTTP connection. This is likely an error and may result in sub-optimal behavior. Request only the bytes you need via a ranged GET or drain the input stream after use.

S3Object s3Obj = s3client.getObject(new GetObjectRequest(bucketName, s3FileName));
Reader reader = new BufferedReader(new InputStreamReader(new  GZIPInputStream(s3Obj.getObjectContent());

I will appreciate if somebody can tell why the stream is aborting silently w/o throwing any exception, and what is the best way to make it work.

Thanks

like image 596
dee Avatar asked Mar 31 '17 20:03

dee


1 Answers

Be sure to close() the input stream only once.

like image 151
Roland Ettinger Avatar answered Nov 09 '22 23:11

Roland Ettinger