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