I have the following code, which is used by the s3 object, but perhaps there will be a wait after the return: Not all bytes were read from the S3ObjectInputStream, aborting HTTPconnection. This is likely an error and may result in suboptimal behavior. Request only the bytes you need is a ranged GET or drain the input stream after use. How do I get rid of this warning? As you can see, I have already tried to use ranged get
public CheckMimeTypeResult isValidObjectInQuarantineBucket(String bucket, String key) {
GetObjectRequest request = new GetObjectRequest(bucket, key)
.withRange(0, 1);
try (S3Object s3Object = s3client.getObject(request)) {
String mimeType = getMimeType(s3Object);
CheckMimeTypeResult result = isSupportedMimeType(mimeType) ?
checkMimeType(key, mimeType) : new CheckMimeTypeResult(false, false, mimeType);
log.debug("isValidObjectInQuarantineBucket() - end: key = {}, result = {}", key, result);
return result;
} catch (Exception ex) {
log.warn("Could not detect mime type for key {}. ex = {}", key, ex.getMessage(), ex);
CheckMimeTypeResult result = new CheckMimeTypeResult(false, false, null);
log.debug("isValidObjectInQuarantineBucket() - end: key = {}, result = {}", key, result);
return result;
}
}