danielcweeks commented on a change in pull request #1863:
URL: https://github.com/apache/iceberg/pull/1863#discussion_r534550155
##########
File path: aws/src/main/java/org/apache/iceberg/aws/s3/BaseS3File.java
##########
@@ -75,13 +76,14 @@ public boolean exists() {
}
}
- protected HeadObjectResponse getObjectMetadata() throws S3Exception {
+ protected S3Object getObjectMetadata() throws S3Exception {
if (metadata == null) {
- HeadObjectRequest.Builder requestBuilder = HeadObjectRequest.builder()
+ ListObjectsV2Response response =
client().listObjectsV2(ListObjectsV2Request.builder()
.bucket(uri().bucket())
- .key(uri().key());
- S3RequestUtil.configureEncryption(awsProperties, requestBuilder);
- metadata = client().headObject(requestBuilder.build());
+ .prefix(uri().key())
+ .maxKeys(1)
+ .build());
+ metadata = response.hasContents() ? response.contents().get(0) : null;
Review comment:
I think this changes the exception behavior a little bit because now
`S3InputFile.getLength()` will throw NPE as opposed to S3 NOT_FOUND in the
event it does not exist and `getLength()` is called. Not a huge issue, but we
might consider improving that a little.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]