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

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 361693864af4fa2bf71a301d928ed45c57721c34
Author: Benoit Tellier <[email protected]>
AuthorDate: Thu Nov 25 14:20:27 2021 +0700

    JAMES-3676 S3 blob store should not fail upon many partial reads
---
 .../blob/objectstorage/aws/S3BlobStoreDAOTest.java | 25 ++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git 
a/server/blob/blob-s3/src/test/java/org/apache/james/blob/objectstorage/aws/S3BlobStoreDAOTest.java
 
b/server/blob/blob-s3/src/test/java/org/apache/james/blob/objectstorage/aws/S3BlobStoreDAOTest.java
index 2786acd..5f19f46 100644
--- 
a/server/blob/blob-s3/src/test/java/org/apache/james/blob/objectstorage/aws/S3BlobStoreDAOTest.java
+++ 
b/server/blob/blob-s3/src/test/java/org/apache/james/blob/objectstorage/aws/S3BlobStoreDAOTest.java
@@ -21,6 +21,11 @@ package org.apache.james.blob.objectstorage.aws;
 import static org.apache.james.blob.api.BlobStoreDAOFixture.ELEVEN_KILOBYTES;
 import static org.apache.james.blob.api.BlobStoreDAOFixture.TEST_BUCKET_NAME;
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatCode;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.stream.IntStream;
 
 import org.apache.james.blob.api.BlobStoreDAO;
 import org.apache.james.blob.api.BlobStoreDAOContract;
@@ -34,6 +39,7 @@ import org.junit.jupiter.api.extension.ExtendWith;
 import com.google.common.io.ByteSource;
 
 import reactor.core.publisher.Flux;
+import reactor.core.publisher.Mono;
 
 @ExtendWith(DockerAwsS3Extension.class)
 public class S3BlobStoreDAOTest implements BlobStoreDAOContract {
@@ -82,4 +88,23 @@ public class S3BlobStoreDAOTest implements 
BlobStoreDAOContract {
         
assertThat(Flux.from(testee().listBlobs(TEST_BUCKET_NAME)).count().block())
             .isEqualTo(count);
     }
+
+    @Test
+    void readShouldNotLeakHttpConnexionsForUnclosedStreams() {
+        BlobStoreDAO store = testee();
+
+        TestBlobId blobId = new TestBlobId("id");
+        Mono.from(store.save(TEST_BUCKET_NAME, blobId, 
ByteSource.wrap(ELEVEN_KILOBYTES))).block();
+
+        assertThatCode(() -> IntStream.range(0, 256)
+            .forEach(i -> {
+                InputStream inputStream = store.read(TEST_BUCKET_NAME, blobId);
+                // Close the stream without reading it
+                try {
+                    inputStream.close();
+                } catch (IOException e) {
+                    throw new RuntimeException(e);
+                }
+            })).doesNotThrowAnyException();
+    }
 }

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to