summaryrefslogtreecommitdiffstats
path: root/vespa-feed-client
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2024-04-11 15:09:55 +0200
committerHenning Baldersheim <balder@yahoo-inc.com>2024-04-11 21:04:22 +0200
commit2d6bbe0b8bff09d105b77161c1d26a00ce43bf0c (patch)
treef9948a9904d837960887e81a956b29f92d918002 /vespa-feed-client
parent6923743ed320ce339727ad57f6fc2da5f82f5e3f (diff)
Unify on List.of
Diffstat (limited to 'vespa-feed-client')
-rw-r--r--vespa-feed-client/src/main/java/ai/vespa/feed/client/impl/FeedClientBuilderImpl.java3
-rw-r--r--vespa-feed-client/src/main/java/ai/vespa/feed/client/impl/JettyCluster.java5
-rw-r--r--vespa-feed-client/src/test/java/ai/vespa/feed/client/impl/HttpFeedClientTest.java12
3 files changed, 9 insertions, 11 deletions
diff --git a/vespa-feed-client/src/main/java/ai/vespa/feed/client/impl/FeedClientBuilderImpl.java b/vespa-feed-client/src/main/java/ai/vespa/feed/client/impl/FeedClientBuilderImpl.java
index 0268f1a4394..c271ac356e9 100644
--- a/vespa-feed-client/src/main/java/ai/vespa/feed/client/impl/FeedClientBuilderImpl.java
+++ b/vespa-feed-client/src/main/java/ai/vespa/feed/client/impl/FeedClientBuilderImpl.java
@@ -15,7 +15,6 @@ import java.security.cert.X509Certificate;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -195,7 +194,7 @@ public class FeedClientBuilderImpl implements FeedClientBuilder {
/** Sets client SSL certificate/key */
@Override
public FeedClientBuilderImpl setCertificate(X509Certificate certificate, PrivateKey privateKey) {
- return setCertificate(Collections.singletonList(certificate), privateKey);
+ return setCertificate(List.of(certificate), privateKey);
}
@Override
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 5454249d52e..df010a167f6 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
@@ -41,7 +41,6 @@ import java.net.Inet4Address;
import java.net.InetSocketAddress;
import java.net.URI;
import java.time.Duration;
-import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
@@ -194,7 +193,7 @@ class JettyCluster implements Cluster {
proxySslCtxFactory.setSslContext(b.constructProxySslContext());
try { proxySslCtxFactory.start(); } catch (Exception e) { throw new IOException(e); }
httpClient.getProxyConfiguration().addProxy(
- new HttpProxy(address, proxySslCtxFactory, new Origin.Protocol(Collections.singletonList("h2"), false)));
+ new HttpProxy(address, proxySslCtxFactory, new Origin.Protocol(List.of("h2"), false)));
URI proxyUri = URI.create(endpointUri(b.proxy));
httpClient.getAuthenticationStore().addAuthenticationResult(new Authentication.Result() {
@Override public URI getURI() { return proxyUri; }
@@ -205,7 +204,7 @@ class JettyCluster implements Cluster {
} else {
// Assume insecure proxy uses HTTP/1.1
httpClient.getProxyConfiguration().addProxy(
- new HttpProxy(address, false, new Origin.Protocol(Collections.singletonList("http/1.1"), false)));
+ new HttpProxy(address, false, new Origin.Protocol(List.of("http/1.1"), false)));
// Bug in Jetty cause authentication result to be ignored for HTTP/1.1 CONNECT requests
httpClient.getRequestListeners().add(new Request.Listener() {
@Override
diff --git a/vespa-feed-client/src/test/java/ai/vespa/feed/client/impl/HttpFeedClientTest.java b/vespa-feed-client/src/test/java/ai/vespa/feed/client/impl/HttpFeedClientTest.java
index c79bb7b4606..28bde16f457 100644
--- a/vespa-feed-client/src/test/java/ai/vespa/feed/client/impl/HttpFeedClientTest.java
+++ b/vespa-feed-client/src/test/java/ai/vespa/feed/client/impl/HttpFeedClientTest.java
@@ -13,7 +13,7 @@ import org.junit.jupiter.api.Test;
import java.net.URI;
import java.time.Duration;
-import java.util.Collections;
+import java.util.List;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
@@ -42,7 +42,7 @@ class HttpFeedClientTest {
@Override public void await() { throw new UnsupportedOperationException(); }
@Override public CompletableFuture<HttpResponse> enqueue(DocumentId documentId, HttpRequest request) { return dispatch.get().apply(documentId, request); }
}
- FeedClient client = new HttpFeedClient(new FeedClientBuilderImpl(Collections.singletonList(URI.create("https://dummy:123"))).setDryrun(true),
+ FeedClient client = new HttpFeedClient(new FeedClientBuilderImpl(List.of(URI.create("https://dummy:123"))).setDryrun(true),
new DryrunCluster(),
new MockRequestStrategy());
@@ -214,7 +214,7 @@ class HttpFeedClientTest {
void testHandshake() {
// dummy:123 does not exist, and results in a host-not-found exception.
FeedException exception = assertThrows(FeedException.class,
- () -> new HttpFeedClient(new FeedClientBuilderImpl(Collections.singletonList(URI.create("https://dummy:123")))));
+ () -> new HttpFeedClient(new FeedClientBuilderImpl(List.of(URI.create("https://dummy:123")))));
String message = exception.getMessage();
assertTrue(message.startsWith("failed handshake with server after "), message);
assertTrue(message.contains("java.net.UnknownHostException"), message);
@@ -237,19 +237,19 @@ class HttpFeedClientTest {
// Old server, and speed-test.
assertEquals("server does not support speed test; upgrade to a newer version",
assertThrows(FeedException.class,
- () -> new HttpFeedClient(new FeedClientBuilderImpl(Collections.singletonList(URI.create("https://dummy:123"))).setSpeedTest(true),
+ () -> new HttpFeedClient(new FeedClientBuilderImpl(List.of(URI.create("https://dummy:123"))).setSpeedTest(true),
cluster,
null))
.getMessage());
// Old server.
- new HttpFeedClient(new FeedClientBuilderImpl(Collections.singletonList(URI.create("https://dummy:123"))),
+ new HttpFeedClient(new FeedClientBuilderImpl(List.of(URI.create("https://dummy:123"))),
cluster,
null);
// New server.
response.set(okResponse);
- new HttpFeedClient(new FeedClientBuilderImpl(Collections.singletonList(URI.create("https://dummy:123"))),
+ new HttpFeedClient(new FeedClientBuilderImpl(List.of(URI.create("https://dummy:123"))),
cluster,
null);
}