Here is the warning I get:
S3AbortableInputStream: not all bytes were read from S3ObjectInputStream, interrupting the HTTP connection. This is probably a mistake and may lead to suboptimal behavior. Request only the bytes you need via GET Ranged or drain the input stream after use.
I tried using try with resources, but S3ObjectInputStream does not seem to close with this method.
try (S3Object s3object = s3Client.getObject(new GetObjectRequest(bucket, key));
S3ObjectInputStream s3ObjectInputStream = s3object.getObjectContent();
BufferedReader reader = new BufferedReader(new InputStreamReader(s3ObjectInputStream, StandardCharsets.UTF_8));
){
}
I also tried the code below and explicitly close, but this also does not work:
S3Object s3object = s3Client.getObject(new GetObjectRequest(bucket, key));
S3ObjectInputStream s3ObjectInputStream = s3object.getObjectContent();
try (BufferedReader reader = new BufferedReader(new InputStreamReader(s3ObjectInputStream, StandardCharsets.UTF_8));
){
s3ObjectInputStream.close();
s3object.close();
}
Any help would be appreciated.
PS: I only read two lines of the file from S3, and the file has more data.