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

java.lang.IllegalStateException: Connection pool shut down #494

Closed
sberss opened this issue Jul 11, 2024 · 1 comment · Fixed by #498
Closed

java.lang.IllegalStateException: Connection pool shut down #494

sberss opened this issue Jul 11, 2024 · 1 comment · Fixed by #498

Comments

@sberss
Copy link
Contributor

sberss commented Jul 11, 2024

I have run into a quite unusual issue where after the service has been running for 1 hour an error is thrown from here with a completely useless error message:

software.amazon.awssdk.core.exception.SdkClientException: Failed to send the request: A callback has reported failure.

This only occured when using temporary credentials, both with AssumeRoleWithWebIdentity and AssumeRole requests. I had a bit of a dig around and eventually got a debugger into the right place and found the following error message thrown when trying to refresh the credentials java.lang.IllegalStateException: Connection pool shut down. From this troubleshooting guide it suggests the error is thrown when there is an attempt to use a closed DefaultCredentialsProvider.

The only place I could find that was closing the DefaultCredentialsProvider was here. I was able to fudge in a fix by pulling the client allocation out of the try-with-resource block and this seems to work. I'm not sure if this is the correct fix as there is likely some interaction here that I don't quite understnad.

diff --git a/src/main/java/software/amazon/nio/spi/s3/S3FileSystemProvider.java b/src/main/java/software/amazon/nio/spi/s3/S3FileSystemProvider.java
index 55254d2..29ed0f4 100644
--- a/src/main/java/software/amazon/nio/spi/s3/S3FileSystemProvider.java
+++ b/src/main/java/software/amazon/nio/spi/s3/S3FileSystemProvider.java
@@ -384,7 +384,8 @@ public class S3FileSystemProvider extends FileSystemProvider {
         var timeOut = TIMEOUT_TIME_LENGTH_1;
         final var unit = MINUTES;

-        try (S3AsyncClient client = s3Directory.getFileSystem().client()) {
+        var client = s3Directory.getFileSystem().client();
+        try {
             client.putObject(
                 PutObjectRequest.builder()
                     .bucket(s3Directory.bucketName())

Sorry I don't have full stacktraces, reproducing this takes an age and I've been chasing this down for so long my brain is starting to melt! The easiest way to reproduce the issue is to set up an AWS profile that assumes a role, and then wait for an hour.

@markjschreiber
Copy link
Contributor

markjschreiber commented Jul 12, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants