I want to use so called "new HttpClient since Java 11" java.net.http.HttpClient
.
To me, it is very important to make sure that the TCP connection gets closed after an HTTP roundtrip completes, so that corresponding port gets released and resources - deallocated.
There is no .close()
or .disconnect()
or something like that available on the API.
It is very weird not to have a possibility to close the connection, and it is also weird why the expected behaviour (what is happening? is the connection getting closed automatically? when? how?) is never documented anywhere, including Introduction to the Java HTTP Client and Examples and Recipes .
Any tips?