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

SDK Clients are Closeable and documented as thread safe but don't provide an isClosed() method #5235

Open
markjschreiber opened this issue May 20, 2024 · 1 comment
Labels
feature-request A feature should be added or improved.

Comments

@markjschreiber
Copy link

Describe the bug

Because SDK clients are Closeable they might be auto-closed if placed in a "try with resources" block. The SDK documentation encourages re-use of clients and advertises them as thread safe. This can mean another thread or a try with resources block might close a client without you realizing. Unfortunately you cannot check if the client is still open because there is no isClosed() method.

Expected Behavior

Ability to determine if a client is closed.

Current Behavior

No ability to determine if a client is closed (without making an API call).

Reproduction Steps

S3Client client;

// on another thread
try (client = S3Client.builder().build()) {
   // do some things
}

// back on the main thread the client has been auto closed but you don't know and cannot tell
client.headBucketRequest(...);  // will fail

### Possible Solution

* presence of an `isClosed()` method
* Or, to make it truly safe, future calls to a closed client could automatically re-establish a connection pool internally

### Additional Information/Context

_No response_

### AWS Java SDK version used

2.25.51

### JDK version used

OpenJDK Runtime Environment Corretto-17.0.11.9.1 (build 17.0.11+9-LTS)

### Operating System and version

Mac OS 14.4.1 (23E224)
@markjschreiber markjschreiber added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels May 20, 2024
@debora-ito debora-ito added feature-request A feature should be added or improved. needs-review This issue or PR needs review from the team. and removed bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels May 22, 2024
@debora-ito
Copy link
Member

@markjschreiber feature request acknowledged, added to the backlog.

@debora-ito debora-ito removed the needs-review This issue or PR needs review from the team. label Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request A feature should be added or improved.
Projects
None yet
Development

No branches or pull requests

2 participants