[
https://issues.apache.org/jira/browse/HTTPCLIENT-1525?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14133183#comment-14133183
]
Joseph Walton commented on HTTPCLIENT-1525:
-------------------------------------------
This looks like a cosmetic bug; the call to {{entry.updateExpiry}} correctly
passes through the {{TimeUnit}}. However, the logging ignores it.
This patch uses the correct unit for logging, going via {{millis}} rather than
{{seconds}} to keep the fractional part:
{noformat}
---
a/httpclient/src/main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java
+++
b/httpclient/src/main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java
@@ -268,12 +268,13 @@ public class PoolingHttpClientConnectionManager
final ManagedHttpClientConnection conn = entry.getConnection();
try {
if (conn.isOpen()) {
+ TimeUnit effectiveUnit = tunit != null ? tunit :
TimeUnit.MILLISECONDS;
entry.setState(state);
- entry.updateExpiry(keepalive, tunit != null ? tunit :
TimeUnit.MILLISECONDS);
+ entry.updateExpiry(keepalive, effectiveUnit);
if (this.log.isDebugEnabled()) {
final String s;
if (keepalive > 0) {
- s = "for " + (double) keepalive / 1000 + "
seconds";
+ s = "for " + (double)
effectiveUnit.toMillis(keepalive) / 1000 + " seconds";
} else {
s = "indefinitely";
}
{noformat}
> The TimeUnit of Keepalive only support ”TimeUnit.MILLISECONDS"
> --------------------------------------------------------------
>
> Key: HTTPCLIENT-1525
> URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1525
> Project: HttpComponents HttpClient
> Issue Type: Bug
> Components: HttpClient
> Affects Versions: 4.3.4, 4.4 Alpha1
> Reporter: Takashi Narita
> Priority: Trivial
> Fix For: 4.3.6, 4.4 Alpha2
>
>
> Hi.
> The case when tunit non-TimeUnit.MILLISECONDS, the following is bug.
> [https://svn.apache.org/repos/asf/httpcomponents/httpclient/tags/4.4-alpha1/httpclient/src/main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java]
> {code:title=org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java|borderStyle=solid}
> public void releaseConnection(
> final HttpClientConnection managedConn,
> final Object state,
> final long keepalive, final TimeUnit tunit) {
> ...
> if (keepalive > 0) {
> s = "for " + (double) keepalive / 1000 + "
> seconds";
> } else {
> ...
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]