hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sebb (JIRA)" <j...@apache.org>
Subject [jira] [Issue Comment Deleted] (HTTPCLIENT-1081) getMetrics() does not work for HEAD or other early release methods
Date Mon, 18 Jul 2016 20:33:20 GMT

     [ https://issues.apache.org/jira/browse/HTTPCLIENT-1081?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Sebb updated HTTPCLIENT-1081:
-----------------------------
    Comment: was deleted

(was: Github user PascalSchumacher commented on a diff in the pull request:

    https://github.com/apache/jmeter/pull/216#discussion_r71222330
  
    --- Diff: src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java ---
    @@ -147,6 +148,8 @@
         private static final int TIME_TO_LIVE = JMeterUtils.getPropDefault("httpclient4.time_to_live",
2000);
     
         private static final String CONTEXT_METRICS = "jmeter_metrics"; // TODO hack for
metrics related to HTTPCLIENT-1081, to be removed later
    +    
    +    private static final Pattern PORT_PATTERN = Pattern.compile("^\\d+$");
    --- End diff --
    
    I'm sure you are aware of this, but let's mention it anyway: Pattern is not thread-safe,
so you have to be careful with static instances. (Of course I lack the necessary knowledge
of jmeter to judge wether it's save to reuse the pattern in these classes.)
)

> getMetrics() does not work for HEAD or other early release methods
> ------------------------------------------------------------------
>
>                 Key: HTTPCLIENT-1081
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1081
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>            Reporter: Sebb
>             Fix For: 5.0
>
>
> 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 was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Mime
View raw message