Pergunta

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?

Foi útil?

Solução

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 Stacks 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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top