fuatbasik commented on code in PR #14161:
URL: https://github.com/apache/iceberg/pull/14161#discussion_r2372673520


##########
aws/src/main/java/org/apache/iceberg/aws/ApacheHttpClientConfigurations.java:
##########
@@ -44,7 +44,11 @@ private ApacheHttpClientConfigurations() {}
   public <T extends AwsSyncClientBuilder> void configureHttpClientBuilder(T 
awsClientBuilder) {
     ApacheHttpClient.Builder apacheHttpClientBuilder = 
ApacheHttpClient.builder();
     configureApacheHttpClientBuilder(apacheHttpClientBuilder);
-    awsClientBuilder.httpClientBuilder(apacheHttpClientBuilder);
+    // Use httpClient(<client>) method in AWS SDKv2 to prevent shared 
connection pools from closing
+    // prematurely.
+    // See:
+    // 
https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/core/client/builder/SdkAsyncClientBuilder.html#httpClient(software.amazon.awssdk.http.async.SdkAsyncHttpClient)
+    awsClientBuilder.httpClient(apacheHttpClientBuilder.build());

Review Comment:
   shouldn't we keep track of the object returned from 
`apacheHttpClientBuilder.build()` close it eventually?



##########
aws/src/main/java/org/apache/iceberg/aws/UrlConnectionHttpClientConfigurations.java:
##########
@@ -39,7 +39,11 @@ public <T extends AwsSyncClientBuilder> void 
configureHttpClientBuilder(T awsCli
     UrlConnectionHttpClient.Builder urlConnectionHttpClientBuilder =
         UrlConnectionHttpClient.builder();
     configureUrlConnectionHttpClientBuilder(urlConnectionHttpClientBuilder);
-    awsClientBuilder.httpClientBuilder(urlConnectionHttpClientBuilder);
+    // Use httpClient(<client>) method in AWS SDKv2 to prevent shared 
connection pools from closing
+    // prematurely.
+    // See:
+    // 
https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/core/client/builder/SdkAsyncClientBuilder.html#httpClient(software.amazon.awssdk.http.async.SdkAsyncHttpClient)
+    awsClientBuilder.httpClient(urlConnectionHttpClientBuilder.build());

Review Comment:
   shouldn't we keep track of the object returned from 
`urlConnectionHttpClientBuilder.build()` close it eventually?



##########
aws/src/test/java/org/apache/iceberg/aws/TestHttpClientProperties.java:
##########
@@ -40,16 +42,15 @@ public void testUrlHttpClientConfiguration() {
     properties.put(HttpClientProperties.CLIENT_TYPE, "urlconnection");
     HttpClientProperties httpProperties = new HttpClientProperties(properties);
     S3ClientBuilder mockS3ClientBuilder = Mockito.mock(S3ClientBuilder.class);
-    ArgumentCaptor<SdkHttpClient.Builder> httpClientBuilderCaptor =
-        ArgumentCaptor.forClass(SdkHttpClient.Builder.class);
+    ArgumentCaptor<SdkHttpClient> httpClientCaptor = 
ArgumentCaptor.forClass(SdkHttpClient.class);
 
     httpProperties.applyHttpClientConfigurations(mockS3ClientBuilder);
-    
Mockito.verify(mockS3ClientBuilder).httpClientBuilder(httpClientBuilderCaptor.capture());
-    SdkHttpClient.Builder capturedHttpClientBuilder = 
httpClientBuilderCaptor.getValue();
+    Mockito.verify(mockS3ClientBuilder).httpClient(httpClientCaptor.capture());
+    SdkHttpClient capturedHttpClient = httpClientCaptor.getValue();
 
-    assertThat(capturedHttpClientBuilder)
+    assertThat(capturedHttpClient)

Review Comment:
   is there a way to test capturedHttpClient.close() is not called, when 
`mockS3ClientBuilder.build().close()` is called?



-- 
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]

Reply via email to