SDK Clients are `Closeable` and documented as thread safe but don't provide an `isClosed()` method
- Dominant language
- Java
- Stars
- 2.6k
- Forks
- 1k
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 51
Description
### 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)
Contributor guide
Assessment
This issue has not been assessed yet.