- Any type which may have managed resources must implement
Closeable
and close any resources it manages.- For example, a service client might implement
Closeable
if it creates managed resources such as anExecutorService
. But, it shouldn't closeCloseable
s passed to it such as anHttpClient
.
- For example, a service client might implement
HttpClient
instances, since they are shared, must register with Cleaner and register a shutdown hook.- This will enable
HttpClient
to close if garbage collected or if the JVM is shutting down.
- This will enable
Response
instance must register with Cleaner so they do not leak connections if they aren't consumed before garbage collection.- Allow for
ExecutorService
to be configured where asynchronous or parallelized execution is needed. - If not set, default to
SharedExecutorService
as this is a central configuration point for users.