Skip to content

Commit

Permalink
HTTPCLIENT-895: Log object lookups by short lived components impair p…
Browse files Browse the repository at this point in the history
…erformance

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/branches/4.0.x@885903 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
ok2c committed Dec 1, 2009
1 parent 8346dfe commit e84af26
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 10 deletions.
7 changes: 7 additions & 0 deletions RELEASE_NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,16 @@ This is a bug fix release that addresses a number of issues discovered since
the previous stable release. None of the fixed bugs is considered critical.
Most notably this release eliminates eliminates dependency on JCIP annotations.

This release is also expected to improve performance by 5 to 10% due to
elimination of unnecessary Log object lookups by short-lived components.

Changelog
-------------------

* [HTTPCLIENT-895] Eliminated Log object lookups by short-lived components
impairing performance.
Contributed by Oleg Kalnichevski <olegk at apache.org>

* [HTTPCLIENT-885] URLEncodedUtils now correctly parses form-url-encoded
entities that specify a charset.
Contributed by Oleg Kalnichevski <olegk at apache.org>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,7 @@ protected RequestDirector createClientRequestDirector(
final UserTokenHandler stateHandler,
final HttpParams params) {
return new DefaultRequestDirector(
log,
requestExec,
conman,
reustrat,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@

import org.apache.http.annotation.NotThreadSafe;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.http.params.HttpParams;
import org.apache.http.params.AbstractHttpParams;

Expand Down Expand Up @@ -73,8 +71,6 @@
@NotThreadSafe
public class ClientParamsStack extends AbstractHttpParams {

private final Log log = LogFactory.getLog(getClass());

/** The application parameter collection, or <code>null</code>. */
protected final HttpParams applicationParams;

Expand Down Expand Up @@ -211,10 +207,6 @@ public Object getParameter(String name) {
if ((result == null) && (applicationParams != null)) {
result = applicationParams.getParameter(name);
}
if (this.log.isDebugEnabled() && result != null) {
this.log.debug("'" + name + "': " + result);
}

return result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
@NotThreadSafe // e.g. managedConn
public class DefaultRequestDirector implements RequestDirector {

private final Log log = LogFactory.getLog(getClass());
private final Log log;

/** The connection manager. */
protected final ClientConnectionManager connManager;
Expand Down Expand Up @@ -184,7 +184,8 @@ public class DefaultRequestDirector implements RequestDirector {

private HttpHost virtualHost;

public DefaultRequestDirector(
DefaultRequestDirector(
final Log log,
final HttpRequestExecutor requestExec,
final ClientConnectionManager conman,
final ConnectionReuseStrategy reustrat,
Expand All @@ -198,6 +199,10 @@ public DefaultRequestDirector(
final UserTokenHandler userTokenHandler,
final HttpParams params) {

if (log == null) {
throw new IllegalArgumentException
("Log may not be null.");
}
if (requestExec == null) {
throw new IllegalArgumentException
("Request executor may not be null.");
Expand Down Expand Up @@ -246,6 +251,7 @@ public DefaultRequestDirector(
throw new IllegalArgumentException
("HTTP parameters may not be null");
}
this.log = log;
this.requestExec = requestExec;
this.connManager = conman;
this.reuseStrategy = reustrat;
Expand All @@ -267,6 +273,34 @@ public DefaultRequestDirector(
this.proxyAuthState = new AuthState();
} // constructor

public DefaultRequestDirector(
final HttpRequestExecutor requestExec,
final ClientConnectionManager conman,
final ConnectionReuseStrategy reustrat,
final ConnectionKeepAliveStrategy kastrat,
final HttpRoutePlanner rouplan,
final HttpProcessor httpProcessor,
final HttpRequestRetryHandler retryHandler,
final RedirectHandler redirectHandler,
final AuthenticationHandler targetAuthHandler,
final AuthenticationHandler proxyAuthHandler,
final UserTokenHandler userTokenHandler,
final HttpParams params) {
this(LogFactory.getLog(DefaultRequestDirector.class),
requestExec,
conman,
reustrat,
kastrat,
rouplan,
httpProcessor,
retryHandler,
redirectHandler,
targetAuthHandler,
proxyAuthHandler,
userTokenHandler,
params);

}

private RequestWrapper wrapRequest(
final HttpRequest request) throws ProtocolException {
Expand Down

0 comments on commit e84af26

Please sign in to comment.