RestTemplate reading Json prohibits JDK HttpClient connection reuse (keep-alive) #27969
Labels
in: web
Issues in web modules (web, webmvc, webflux, websocket)
type: enhancement
A general enhancement
Milestone
Affects: 5.3.14
There is an issue regarding https connection reuse (keep-alive) when using jackson unmarshaller, chunked transfer encoding and RestTemplate. The connections are not reused, which leads to more TLS handshakes for subsequent calls.
AUTO_CLOSE_SOURCE
-Feature is enabled (which is the default), jackson closes theHttpInputStream
inUTF8StreamJsonParser._closeInput()
after the json doc is fully read.last-chunk
(as of RFC7230 4.1) is still "waiting on the wire".sun.net.www.http.ChunkedInputStream.hurry()
which aims to read all the remaining bytes.sun.net.www.http.ChunkedInputStream.readAheadNonBlocking()
in.available()
may not return all remaining bytes.ChunkedInputStream
that is not in stateSTATE_DONE
, which will lead to it being closed, instead of kept alive.This is a combination of multiple unrelated things, that may not be issues in their own rights.
hurry()
may leave unread bytes in the stream, which is probably okay, as close() was called prematurely.close()
prematurely, having not read all input.I open this bug against Spring, because I think it is the best place to fix the issue.
Find a reproducing project at: https://github.com/apinske/playground-http/tree/spring-framework-issues-27969
The text was updated successfully, but these errors were encountered: