diff options
author | Bjørn Christian Seime <bjorncs@yahooinc.com> | 2023-07-06 18:26:15 +0200 |
---|---|---|
committer | Bjørn Christian Seime <bjorncs@yahooinc.com> | 2023-07-06 18:26:15 +0200 |
commit | f44c0fe6af06a966a655c1efd50bc2873c7b0e5f (patch) | |
tree | ea763a0f5ee71f8b0cc6258fa5fb60325df49a35 /vespa-feed-client | |
parent | 987daa580a155e2f1ff7eb4be21e60e620d2886d (diff) |
Only create URI instance once
Ensure that Jetty's HttpRequest doesn't recreate URI multiple times.
Diffstat (limited to 'vespa-feed-client')
-rw-r--r-- | vespa-feed-client/src/main/java/ai/vespa/feed/client/impl/JettyCluster.java | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/vespa-feed-client/src/main/java/ai/vespa/feed/client/impl/JettyCluster.java b/vespa-feed-client/src/main/java/ai/vespa/feed/client/impl/JettyCluster.java index 9b2b91699ac..9f5523b062c 100644 --- a/vespa-feed-client/src/main/java/ai/vespa/feed/client/impl/JettyCluster.java +++ b/vespa-feed-client/src/main/java/ai/vespa/feed/client/impl/JettyCluster.java @@ -70,11 +70,9 @@ class JettyCluster implements Cluster { Endpoint endpoint = findLeastBusyEndpoint(endpoints); long reqTimeoutMillis = req.timeout() != null ? req.timeout().toMillis() * 11 / 10 + 1000 : IDLE_TIMEOUT.toMillis(); - Request jettyReq = client.newRequest(endpoint.uri.getHost(), portOf(endpoint.uri)) + Request jettyReq = client.newRequest(URI.create(endpoint.uri + req.path())) .version(HttpVersion.HTTP_2) - .scheme(endpoint.uri.getScheme()) .method(HttpMethod.fromString(req.method())) - .path(req.path()) .headers(hs -> req.headers().forEach((k, v) -> hs.add(k, v.get()))) .idleTimeout(IDLE_TIMEOUT.toMillis(), MILLISECONDS) .timeout(reqTimeoutMillis, MILLISECONDS); @@ -164,8 +162,8 @@ class JettyCluster implements Cluster { private static class Endpoint { final AtomicInteger inflight = new AtomicInteger(); - final URI uri; - Endpoint(URI uri) { this.uri = uri; } + final String uri; + Endpoint(URI uri) { this.uri = String.format("%s://%s:%s", uri.getScheme(), uri.getHost(), portOf(uri)); } } private static class FeedContent extends AbstractRequestContent { |