Skip to content

[CRT Client] Publisher error appears on AwsEventLoop threads in addition to CompletableFuture #6715

@lthoulon-locala

Description

@lthoulon-locala

Describe the bug

When using the CRT-based S3 client (S3AsyncClient.crtCreate()) with S3TransferManager.upload() and AsyncRequestBody.fromPublisher(), if the publisher emits an error, the exception appears on AwsEventLoop threads (triggering the JVM's default uncaught exception handler).

The error is also correctly propagated to the CompletableFuture, so our application handles it fine. However, the stderr output is unexpected.

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

We would expect the exception to only propagate to the CompletableFuture, without being thrown on event loop threads.

Current Behavior

The exception is:

  1. Correctly propagated to the CompletableFuture
  2. Also appears as an uncaught exception on AwsEventLoop threads

Stderr output:

Exception in thread "AwsEventLoop6" java.lang.IllegalArgumentException: test error
	at ...

Reproduction Steps

Using the CRT-based S3 client and Reactor Flux as the Publisher implementation:

val s3Client = S3AsyncClient.crtCreate()

val s3TransferManager = S3TransferManager.builder()
    .s3Client(s3Client)
    .build()

val flux: Flux<ByteBuffer> = Flux.error(IllegalArgumentException("test error"))

val result = s3TransferManager
    .upload { builder ->
        builder
            .requestBody(AsyncRequestBody.fromPublisher(flux))
            .putObjectRequest { it.bucket("my-bucket").key("my-key") }
    }
    .completionFuture()

assertFailsWith<CompletionException> {
    result.join()  // Error is propagated correctly
}

// Stderr shows: "Exception in thread "AwsEventLoop6" java.lang.IllegalArgumentException: test error"

We observed that this does not happen with the Netty-based client (S3AsyncClient.builder().build()).

Possible Solution

No response

Additional Information/Context

No response

AWS Java SDK version used

2.41.22 + aws-crt 0.43.1

JDK version used

21

Operating System and version

macOS Tahoe 16.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue is a bug.needs-triageThis issue or PR still needs to be triaged.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions