wombatu-kun commented on code in PR #16656:
URL: https://github.com/apache/iceberg/pull/16656#discussion_r3353458870
##########
aws/src/integration/java/org/apache/iceberg/aws/s3/TestS3FileIO.java:
##########
@@ -376,6 +376,61 @@ public void assertPrefixIsAddedCorrectly(String suffix,
Map<String, String> prop
&& fi.createdAtMillis() <
Instant.now().minusSeconds(30).toEpochMilli());
}
+ @Test
+ public void testListPrefixNormalizesTrailingSlashForGeneralPurposeBucket() {
+ S3Client localMockedClient = mock(S3Client.class);
+
+ List<S3Object> s3Objects =
+ Arrays.asList(
+ S3Object.builder()
+ .key("warehouse/ns/table/data/file1.parquet")
+ .size(1024L)
+ .lastModified(Instant.now())
+ .build());
+
+ ListObjectsV2Response response =
ListObjectsV2Response.builder().contents(s3Objects).build();
+ ListObjectsV2Iterable mockedResponse = mock(ListObjectsV2Iterable.class);
+ Mockito.when(mockedResponse.stream()).thenReturn(Stream.of(response));
+
+ // Expect the request to have a trailing slash even though we pass a
prefix without one
+ Mockito.when(
+ localMockedClient.listObjectsV2Paginator(
+ ListObjectsV2Request.builder()
+ .prefix("warehouse/ns/table/")
+ .bucket(S3_GENERAL_PURPOSE_BUCKET)
+ .build()))
+ .thenReturn(mockedResponse);
+
+ S3FileIO localS3FileIo = new S3FileIO(() -> localMockedClient);
+ localS3FileIo.initialize(properties);
+
+ // Call listPrefix WITHOUT trailing slash
+ List<FileInfo> fileInfoList =
+ StreamSupport.stream(
Review Comment:
`Streams.stream(...)` (already imported and used in the sibling test below)
is simpler than the StreamSupport/Spliterators construction:
`Streams.stream(localS3FileIo.listPrefix("s3://bucket/warehouse/ns/table")).collect(Collectors.toList())`.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]