This is an automated email from the ASF dual-hosted git repository.

tilman pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tika.git


The following commit(s) were added to refs/heads/main by this push:
     new 6b0548f1b TIKA-4525: simplify getObject, as suggested by ChatGPT
6b0548f1b is described below

commit 6b0548f1ba6224a4d33fea762cca6ae6107f4744
Author: Tilman Hausherr <[email protected]>
AuthorDate: Fri Oct 24 14:15:56 2025 +0200

    TIKA-4525: simplify getObject, as suggested by ChatGPT
---
 .../org/apache/tika/pipes/s3/tests/PipeIntegrationTests.java   |  6 +-----
 .../org/apache/tika/pipes/s3/tests/S3PipeIntegrationTest.java  | 10 ++++------
 2 files changed, 5 insertions(+), 11 deletions(-)

diff --git 
a/tika-integration-tests/tika-pipes-s3-integration-tests/src/test/java/org/apache/tika/pipes/s3/tests/PipeIntegrationTests.java
 
b/tika-integration-tests/tika-pipes-s3-integration-tests/src/test/java/org/apache/tika/pipes/s3/tests/PipeIntegrationTests.java
index 96df9cd56..11a9de9c8 100644
--- 
a/tika-integration-tests/tika-pipes-s3-integration-tests/src/test/java/org/apache/tika/pipes/s3/tests/PipeIntegrationTests.java
+++ 
b/tika-integration-tests/tika-pipes-s3-integration-tests/src/test/java/org/apache/tika/pipes/s3/tests/PipeIntegrationTests.java
@@ -37,11 +37,9 @@ import org.junit.jupiter.api.Disabled;
 import org.junit.jupiter.api.Test;
 import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider;
 import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider;
-import software.amazon.awssdk.core.ResponseInputStream;
 import software.amazon.awssdk.regions.Region;
 import software.amazon.awssdk.services.s3.S3Client;
 import software.amazon.awssdk.services.s3.model.GetObjectRequest;
-import software.amazon.awssdk.services.s3.model.GetObjectResponse;
 import software.amazon.awssdk.services.s3.model.ListObjectsV2Request;
 import software.amazon.awssdk.services.s3.model.S3Object;
 
@@ -86,9 +84,7 @@ public class PipeIntegrationTests {
             }
             System.out.println("id: " + cnt + " :: " + key + " : " + 
s3Object.size());
             GetObjectRequest objectRequest = 
GetObjectRequest.builder().bucket(bucket).key(key).build();
-            try (ResponseInputStream<GetObjectResponse> is = 
s3Client.getObject(objectRequest)) {
-                Files.copy(is, targ);
-            }
+            s3Client.getObject(objectRequest, targ);
             cnt++;
             sz += s3Object.size();
         }
diff --git 
a/tika-integration-tests/tika-pipes-s3-integration-tests/src/test/java/org/apache/tika/pipes/s3/tests/S3PipeIntegrationTest.java
 
b/tika-integration-tests/tika-pipes-s3-integration-tests/src/test/java/org/apache/tika/pipes/s3/tests/S3PipeIntegrationTest.java
index cb2a85fb0..407dc0b09 100644
--- 
a/tika-integration-tests/tika-pipes-s3-integration-tests/src/test/java/org/apache/tika/pipes/s3/tests/S3PipeIntegrationTest.java
+++ 
b/tika-integration-tests/tika-pipes-s3-integration-tests/src/test/java/org/apache/tika/pipes/s3/tests/S3PipeIntegrationTest.java
@@ -41,7 +41,7 @@ import org.testcontainers.containers.ComposeContainer;
 import org.testcontainers.junit.jupiter.Testcontainers;
 import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
 import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
-import software.amazon.awssdk.core.ResponseInputStream;
+import software.amazon.awssdk.core.ResponseBytes;
 import software.amazon.awssdk.core.checksums.RequestChecksumCalculation;
 import software.amazon.awssdk.core.sync.RequestBody;
 import software.amazon.awssdk.regions.Region;
@@ -152,12 +152,10 @@ class S3PipeIntegrationTest {
 
         for (String testFile : testFiles) {
             GetObjectRequest objectRequest = 
GetObjectRequest.builder().bucket(EMIT_BUCKET).key(testFile + ".json").build();
-            try (ResponseInputStream<GetObjectResponse> is = 
s3Client.getObject(objectRequest)) {
-                Assertions.assertNotNull(is);
-                String data = IOUtils.toString(is, StandardCharsets.UTF_8);
-                Assertions.assertTrue(data.contains("body-of-" + testFile),
+            ResponseBytes<GetObjectResponse> objectAsBytes = 
s3Client.getObjectAsBytes(objectRequest);
+            String data = objectAsBytes.asString(StandardCharsets.UTF_8);
+            Assertions.assertTrue(data.contains("body-of-" + testFile),
                         "Should be able to read the parsed body of the HTML 
file as the body of the document");
-            }
         }
     }
 

Reply via email to