-
-
Notifications
You must be signed in to change notification settings - Fork 816
Closed
Description
(note: replaces FasterXML/jackson-databind#3520)
It looks like JDK's HttpURLConnection
has unfortunate handling of some error cases, leading to leakage of not-fully-closed HTTP connections under some error conditions. See FasterXML/jackson-databind#3455 for details.
It seems like we might be able to handle some of those cases if we could do something like:
URLConnection connection = new URL(url).openConnection();
try (InputStream stream = connection.getInputStream()) {
// parse JSON
} finally {
// java.net.HttpURLConnection.HttpURLConnection
if (connection instanceof HttpURLConnection) {
((HttpURLConnection) connection).disconnect();
}
}
(as suggested by @fxha -- thanks!)
But due to separation of concerns, this cannot (or should not) be done in databind. Instead we could wrap URL-backed InputStream
in these cases, delegated all calls except for close()
: and in close()
we would do disconnect.
Metadata
Metadata
Assignees
Labels
No labels