Skip to content

Commit

Permalink
Reuse URIAuthority(Host) constructor avoiding creating new Host
Browse files Browse the repository at this point in the history
instances

Note: Host is immutable and therefore safe to pass on and reuse
  • Loading branch information
garydgregory committed Oct 29, 2024
1 parent a510c68 commit dbb3cd4
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ private void execute(
exchangeHandler.produceRequest((request, entityDetails, httpContext) -> {
final HttpHost host = target != null ? target : defaultTarget(request);
if (request.getAuthority() == null) {
request.setAuthority(new URIAuthority(host.getHostName(), host.getPort()));
request.setAuthority(new URIAuthority(host));
}
connPool.getSession(host, timeout, new FutureCallback<IOSession>() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ public void execute(
exchangeHandler.produceRequest((request, entityDetails, requestContext) -> {
final HttpHost host = target != null ? target : defaultTarget(request);
if (request.getAuthority() == null) {
request.setAuthority(new URIAuthority(host.getHostName(), host.getPort()));
request.setAuthority(new URIAuthority(host));
}
connect(host, timeout, null, new FutureCallback<AsyncClientEndpoint>() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ public ClassicHttpResponse execute(
}
}
if (request.getAuthority() == null) {
request.setAuthority(new URIAuthority(targetHost.getHostName(), targetHost.getPort()));
request.setAuthority(new URIAuthority(targetHost));
}
final ClassicHttpResponse response = execute(connection, request, informationCallback, context);
final HttpEntity entity = response.getEntity();
Expand Down

0 comments on commit dbb3cd4

Please sign in to comment.