Skip to content

Reading large file from ReactiveGridFsTemplate causes a stackoverflow and the code to hang [DATAMONGO-2393] #3253

Closed
@spring-projects-issues

Description

@spring-projects-issues

Nick Stolwijk opened DATAMONGO-2393 and commented

When I try to read a bigger file from GridFs with the ReactiveGridFsTemplate the test fails and hangs with a StackOverflow exception.

Drop-in test for ReactiveGridFsTemplateTests.java

@Test // DATAMONGO-2393
public void getResourceShouldRetrieveLargeContentByIdentity() throws IOException {
   byte[] content = new byte[64_000];
   ThreadLocalRandom.current().nextBytes(content);
   AsyncInputStream upload = AsyncStreamHelper.toAsyncInputStream(new ByteArrayInputStream(content));

   ObjectId reference = operations.store(upload, "foo.xml", null, null).block();

   operations.findOne(query(where("_id").is(reference))).flatMap(operations::getResource)
         .flatMapMany(ReactiveGridFsResource::getDownloadStream) //
         .transform(DataBufferUtils::join) //
         .as(StepVerifier::create) //
         .consumeNextWith(dataBuffer -> {

            byte[] actual = new byte[dataBuffer.readableByteCount()];
            dataBuffer.read(actual);

            assertThat(actual).isEqualTo(content);
         }) //
         .verifyComplete();
}

Affects: 2.2 GA (Moore)

Reference URL: https://stackoverflow.com/questions/58335826/stackoverflowerror-while-reading-file-from-reactive-gridfs

Referenced from: pull request #799

Backported to: 2.2.1 (Moore SR1)

Metadata

Metadata

Assignees

Labels

in: coreIssues in core supporttype: bugA general bug

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions