Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Custom executorService not working #7159

Open
tucm opened this issue Dec 13, 2024 · 0 comments
Open

[Bug]: Custom executorService not working #7159

tucm opened this issue Dec 13, 2024 · 0 comments
Assignees
Labels
Bug An update to fix incorrect code or typos.

Comments

@tucm
Copy link

tucm commented Dec 13, 2024

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

@rlhagerm rlhagerm added the Bug An update to fix incorrect code or typos. label Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug An update to fix incorrect code or typos.
Projects
None yet
Development

No branches or pull requests

3 participants