Inspect Java HTTP connection pool
-
28-09-2019 - |
문제
HttpUrlConnection uses persistent connections by default (http://download.oracle.com/javase/6/docs/technotes/guides/net/http-keepalive.html). Is there any way to inspect Java HTTP connection pool? Eg check how many open connections in the pool?
해결책
Unfortunately no. In Oracle's VM, you can in theory inspect the static cache in sun.net.www.http.HttpClient.kac
using reflection. This is a Map
, which values are Stack
s of cached HttpClient
instances. The cache however also contains already closed or timed out connections and it does not seem to be a reasonable easy way to filter these out, without actually performing a real HTTP request, in which case abandoned connections will automatically reconnect.
제휴하지 않습니다 StackOverflow