[ 
https://issues.apache.org/jira/browse/HTTPCORE-253?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13019293#comment-13019293
 ] 

Oleg Kalnichevski commented on HTTPCORE-253:
--------------------------------------------

> In which case, maybe we should consider moving the metrics to the request, 
> rather than the connection?

Connection metrics were intended primarily for custom connection keep-alive 
strategies so one could choose to close a connection after a certain number of 
messages or bytes of data transferred over that connection.

Actually I do not think there is anything in HttpCore that needs fixing as far 
as the connection metrics are concerned. We just need to think how to maintain 
counts of message / bytes transferred on the HttpClient level given that 
connections can be released to the pool early. One possibility I was thinking 
about was to make managed connections (AbstractClientConnAdaptor and its super 
classes) retain a deep copy of HttpConnectionMetrics after releasing the 
underlying connection back to the manager. This would enable the users to read 
the metrics off the connection object obtained from the local execution context.

Anyway, feel free to propose a solution that makes most sense from your 
perspective and with your JMeter hat on.

Oleg

> getMetrics() does not work for HEAD or other early release methods
> ------------------------------------------------------------------
>
>                 Key: HTTPCORE-253
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-253
>             Project: HttpComponents HttpCore
>          Issue Type: Bug
>            Reporter: Sebb
>             Fix For: 4.2
>
>
> The following code works fine for GET:
>            HttpResponse httpResponse =
> httpClient.execute(httpRequest, localContext);
>            HttpConnection conn = (HttpConnection)
> localContext.getAttribute(ExecutionContext.HTTP_CONNECTION);
>            HttpConnectionMetrics metrics = conn.getMetrics();
> but fails on the getMetrics() call when the request is HEAD:
>        org.apache.http.impl.conn.ConnectionShutdownException
>        at 
> org.apache.http.impl.conn.AbstractClientConnAdapter.assertValid(AbstractClientConnAdapter.java:154)
>        at 
> org.apache.http.impl.conn.AbstractClientConnAdapter.getMetrics(AbstractClientConnAdapter.java:190)
> This is because the getMetrics() method calls assertValid() which checks that 
> the connection has not been released, and the HEAD request is released as 
> soon as it completes, before returning to the caller.
> Possible solutions:
> - don't call assertValid() in getMetrics()
> - store a pointer to the metrics in the local context

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to