Improved DEBUG log statements; reduced noise in the context logging

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@691587 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Oleg Kalnichevski 2008-09-03 12:22:55 +00:00
parent fb7a529419
commit 0cfdbb16a0
5 changed files with 28 additions and 16 deletions

View File

@ -215,7 +215,7 @@ public class ClientParamsStack extends AbstractHttpParams {
if ((result == null) && (applicationParams != null)) {
result = applicationParams.getParameter(name);
}
if (this.log.isDebugEnabled()) {
if (this.log.isDebugEnabled() && result != null) {
this.log.debug("'" + name + "': " + result);
}

View File

@ -330,10 +330,12 @@ public class DefaultRequestDirector implements RequestDirector {
if (HttpConnectionParams.isStaleCheckingEnabled(params)) {
// validate connection
this.log.debug("Stale connection check");
if (managedConn.isStale()) {
this.log.debug("Stale connection detected");
managedConn.close();
if (managedConn.isOpen()) {
this.log.debug("Stale connection check");
if (managedConn.isStale()) {
this.log.debug("Stale connection detected");
managedConn.close();
}
}
}
}
@ -446,10 +448,14 @@ public class DefaultRequestDirector implements RequestDirector {
// The connection is in or can be brought to a re-usable state.
reuse = reuseStrategy.keepAlive(response, context);
if(reuse) {
if (reuse) {
// Set the idle duration of this connection
long duration = keepAliveStrategy.getKeepAliveDuration(response, context);
managedConn.setIdleDuration(duration, TimeUnit.MILLISECONDS);
if (this.log.isDebugEnabled()) {
this.log.debug("Connection can be kept alive for " + duration + " ms");
}
}
RoutedRequest followup = handleResponse(roureq, response, context);
@ -457,7 +463,6 @@ public class DefaultRequestDirector implements RequestDirector {
done = true;
} else {
if (reuse) {
this.log.debug("Connection kept alive");
// Make sure the response body is fully consumed, if present
HttpEntity entity = response.getEntity();
if (entity != null) {

View File

@ -110,11 +110,10 @@ public class RequestWrapper extends AbstractHttpMessage implements HttpUriReques
}
public ProtocolVersion getProtocolVersion() {
if (this.version != null) {
return this.version;
} else {
return HttpProtocolParams.getVersion(getParams());
if (this.version == null) {
this.version = HttpProtocolParams.getVersion(getParams());
}
return this.version;
}
public void setProtocolVersion(final ProtocolVersion version) {

View File

@ -371,7 +371,7 @@ public class ConnPoolByRoute extends AbstractConnPool {
HttpRoute route = entry.getPlannedRoute();
if (log.isDebugEnabled()) {
log.debug("Freeing connection" +
log.debug("Releasing connection" +
" [" + route + "][" + entry.getState() + "]");
}
@ -390,6 +390,11 @@ public class ConnPoolByRoute extends AbstractConnPool {
RouteSpecificPool rospl = getRoutePool(route, true);
if (reusable) {
if (log.isDebugEnabled()) {
log.debug("Pooling connection" +
" [" + route + "][" + entry.getState() + "]" +
"; keep alive for " + validDuration + " " + timeUnit.toString());
}
rospl.freeEntry(entry);
freeConnections.add(entry);
idleConnHandler.add(entry.getConnection(), validDuration, timeUnit);

View File

@ -198,10 +198,6 @@ public class ThreadSafeClientConnManager implements ClientConnectionManager {
try {
// make sure that the response has been read completely
if (hca.isOpen() && !hca.isMarkedReusable()) {
if (log.isDebugEnabled()) {
log.debug
("Released connection open but not marked reusable.");
}
// In MTHCM, there would be a call to
// SimpleHttpConnectionManager.finishLastResponse(conn);
// Consuming the response is handled outside in 4.0.
@ -220,6 +216,13 @@ public class ThreadSafeClientConnManager implements ClientConnectionManager {
} finally {
BasicPoolEntry entry = (BasicPoolEntry) hca.getPoolEntry();
boolean reusable = hca.isMarkedReusable();
if (log.isDebugEnabled()) {
if (reusable) {
log.debug("Released connection is reusable.");
} else {
log.debug("Released connection is not reusable.");
}
}
hca.detach();
if (entry != null) {
connectionPool.freeEntry(entry, reusable, validDuration, timeUnit);