Skip to content

[Bug]: Custom executorService not working  #7159

Open
@tucm

Description

@tucm

Expected behavior

Why is the custom executorService not working as expected in this code? The custom thread names (e.g., CustomPool-1) are not being applied, and the thread name still appears as [Thread-0] in the logs.

Actual behavior

Code:

ExecutorService executorService = Executors.newFixedThreadPool(10, new CustomThreadFactory("CustomPool"));

SdkAsyncHttpClient httpClient = NettyNioAsyncHttpClient.builder()
.maxConcurrency(50)
.connectionTimeout(Duration.ofSeconds(10))
.writeTimeout(Duration.ofSeconds(30))
.build();

S3AsyncClient s3AsyncClient = S3AsyncClient.builder()
.httpClient(httpClient)
.region(Region.US_EAST_2)
.credentialsProvider(StaticCredentialsProvider.create(
AwsBasicCredentials.create(accessKeyId, secretAccessKey)))
.build();

S3TransferManager transferManager = S3TransferManager.builder()
.s3Client(s3AsyncClient)
.executor(executorService)
.build();

// File upload task
UploadFileRequest uploadFileRequest = UploadFileRequest.builder()
.source(Paths.get(fullPath))
.addTransferListener(LoggingTransferListener.create())
.putObjectRequest(PutObjectRequest.builder()
.bucket(bucketName)
.key(keyFileName)
.build())
.build();

transferManager.uploadFile(uploadFileRequest).completionFuture().thenRun(() -> {
logger.info("Upload completed for: " + keyFileName);
});

Steps to reproduce

Run the codes.

From the logs, the threads handling upload and download tasks are still using the default thread names (e.g., [Thread-0]), rather than the custom names specified by the CustomThreadFactory. It appears that the custom executorService provided to the S3TransferManager is not being used as expected. Could this be a bug in the S3TransferManager or a misconfiguration in the code?

Logs / stacktrace (if applicable)

Logs:
[main] INFO software.amazon.awssdk.transfer.s3.progress.LoggingTransferListener - Transfer initiated...
[main] INFO software.amazon.awssdk.transfer.s3.progress.LoggingTransferListener - |                    | 0.0%
[main] INFO software.amazon.awssdk.transfer.s3.progress.LoggingTransferListener - Transfer initiated...
[Thread-0] INFO software.amazon.awssdk.transfer.s3.progress.LoggingTransferListener - |====================| 100.0%
[aws-java-sdk-NettyEventLoop-0-5] INFO software.amazon.awssdk.transfer.s3.progress.LoggingTransferListener - |====================| 100.0%
[sdk-async-response-1-0] INFO com.test.tucm.awssdkv2.demo.S3MultiThreadedUploadTestWithHttpClient - downloaded completed for: download.js
[sdk-async-response-1-0] INFO software.amazon.awssdk.transfer.s3.progress.LoggingTransferListener - Transfer complete!
[sdk-async-response-1-1] INFO com.test.tucm.awssdkv2.demo.S3MultiThreadedUploadTestWithHttpClient - Upload completed for: download.js
[sdk-async-response-1-1] INFO software.amazon.awssdk.transfer.s3.progress.LoggingTransferListener - Transfer complete!

Which SDK were you using?

Java

Which OS were you using?

macOS

SDK version

2.29.27

OS version

mac os 15.1.1

Metadata

Metadata

Assignees

Labels

BugAn update to fix incorrect code or typos.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions