diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2024-04-12 08:30:35 +0200 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2024-04-12 08:39:04 +0200 |
commit | 76a89b62274060452022ddf24a7685ee2f380cb4 (patch) | |
tree | ef924603de22efd026f519ab31fd8f5a6ff60f2f /vespaclient-java | |
parent | 7e7ebf7b527be1f163d497a41898e2252d878fe7 (diff) |
Replace all usages of Arrays.asList with List.of where possible.
Diffstat (limited to 'vespaclient-java')
5 files changed, 26 insertions, 17 deletions
diff --git a/vespaclient-java/src/main/java/com/yahoo/dummyreceiver/DummyReceiver.java b/vespaclient-java/src/main/java/com/yahoo/dummyreceiver/DummyReceiver.java index 8d8904f042f..9a7d8279b1b 100755..100644 --- a/vespaclient-java/src/main/java/com/yahoo/dummyreceiver/DummyReceiver.java +++ b/vespaclient-java/src/main/java/com/yahoo/dummyreceiver/DummyReceiver.java @@ -18,7 +18,6 @@ import com.yahoo.messagebus.Reply; import com.yahoo.messagebus.network.Identity; import com.yahoo.messagebus.network.rpc.RPCNetworkParams; -import java.util.Arrays; import java.util.LinkedList; import java.util.List; import java.util.concurrent.BlockingQueue; @@ -174,7 +173,7 @@ public class DummyReceiver implements MessageHandler { LogSetup.initVespaLogging("dummyreceiver"); DummyReceiver rcv = new DummyReceiver(); - if (!rcv.parseArgs(new LinkedList<>(Arrays.asList(args))) && !rcv.helpOption) { + if (!rcv.parseArgs(new LinkedList<>(List.of(args))) && !rcv.helpOption) { System.exit(1); } if (rcv.helpOption) { diff --git a/vespaclient-java/src/main/java/com/yahoo/vespafeeder/Arguments.java b/vespaclient-java/src/main/java/com/yahoo/vespafeeder/Arguments.java index 9c6613058f1..c81b8ff63b0 100644 --- a/vespaclient-java/src/main/java/com/yahoo/vespafeeder/Arguments.java +++ b/vespaclient-java/src/main/java/com/yahoo/vespafeeder/Arguments.java @@ -11,7 +11,6 @@ import java.io.BufferedOutputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.util.ArrayList; -import java.util.Arrays; import java.util.LinkedList; import java.util.List; @@ -107,7 +106,7 @@ public class Arguments { private void parse(String[] argList) throws HelpShownException { List<String> args = new LinkedList<>(); - args.addAll(Arrays.asList(argList)); + args.addAll(List.of(argList)); while (!args.isEmpty()) { String arg = args.remove(0); diff --git a/vespaclient-java/src/main/java/com/yahoo/vespaget/CommandLineOptions.java b/vespaclient-java/src/main/java/com/yahoo/vespaget/CommandLineOptions.java index 8182aa917ae..cd372e72e41 100644 --- a/vespaclient-java/src/main/java/com/yahoo/vespaget/CommandLineOptions.java +++ b/vespaclient-java/src/main/java/com/yahoo/vespaget/CommandLineOptions.java @@ -13,7 +13,6 @@ import org.apache.commons.cli.Options; import org.apache.commons.cli.ParseException; import java.io.InputStream; -import java.util.Arrays; import java.util.Iterator; import java.util.List; import java.util.Scanner; @@ -229,7 +228,7 @@ public class CommandLineOptions { private Iterator<String> getDocumentIds(CommandLine cl) { // Fetch document ids from stdin if no ids are passed in as command line arguments - List<String> documentIds = Arrays.asList(cl.getArgs()); + List<String> documentIds = List.of(cl.getArgs()); // WARNING: CommandLine.getArgs may return a single empty string as the only element if (documentIds.isEmpty() || documentIds.size() == 1 && documentIds.get(0).isEmpty()) { diff --git a/vespaclient-java/src/test/java/com/yahoo/vespafeeder/VespaFeederTestCase.java b/vespaclient-java/src/test/java/com/yahoo/vespafeeder/VespaFeederTestCase.java index 2cb3ab17df4..56ca142841c 100644 --- a/vespaclient-java/src/test/java/com/yahoo/vespafeeder/VespaFeederTestCase.java +++ b/vespaclient-java/src/test/java/com/yahoo/vespafeeder/VespaFeederTestCase.java @@ -7,7 +7,7 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.PrintStream; import java.util.ArrayList; -import java.util.Arrays; +import java.util.List; import com.yahoo.clientmetrics.RouteMetricSet; import com.yahoo.document.DocumentPut; @@ -39,7 +39,7 @@ public class VespaFeederTestCase { Arguments arguments = new Arguments(argsS.split(" "), DummySessionFactory.createWithAutoReply()); FeederConfig config = arguments.getFeederConfig(); - assertEquals(false, config.abortondocumenterror()); + assertFalse(config.abortondocumenterror()); assertEquals(13.0, config.timeout(), 0.00001); assertEquals(false, config.retryenabled()); assertEquals("e6", config.route()); @@ -103,7 +103,7 @@ public class VespaFeederTestCase { public void assertRenderErrorOutput(String expected, String[] errors) { ArrayList<String> l = new ArrayList<String>(); - l.addAll(Arrays.asList(errors)); + l.addAll(List.of(errors)); assertEquals(expected, VespaFeeder.renderErrors(l).getMessage()); } @@ -111,16 +111,29 @@ public class VespaFeederTestCase { void testRenderErrors() { { String[] errors = {"foo"}; - assertRenderErrorOutput("Errors:\n" + - "-------\n" + - " foo\n", errors); + assertRenderErrorOutput(""" + Errors: + ------- + foo + """, errors); } { String[] errors = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11"}; - assertRenderErrorOutput("First 10 errors (of 11):\n" + - "------------------------\n" + - " 1\n 2\n 3\n 4\n 5\n 6\n 7\n 8\n 9\n 10\n", errors); + assertRenderErrorOutput(""" + First 10 errors (of 11): + ------------------------ + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + """, errors); } } diff --git a/vespaclient-java/src/test/java/com/yahoo/vespaget/DocumentRetrieverTest.java b/vespaclient-java/src/test/java/com/yahoo/vespaget/DocumentRetrieverTest.java index ddaf057a0b9..1d8f050a037 100644 --- a/vespaclient-java/src/test/java/com/yahoo/vespaget/DocumentRetrieverTest.java +++ b/vespaclient-java/src/test/java/com/yahoo/vespaget/DocumentRetrieverTest.java @@ -23,7 +23,6 @@ import org.mockito.ArgumentMatcher; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.PrintStream; -import java.util.Arrays; import java.util.Collections; import java.util.Iterator; import java.util.List; @@ -99,7 +98,7 @@ public class DocumentRetrieverTest { } private static Iterator<String> asIterator(String... docIds) { - return Arrays.asList(docIds).iterator(); + return List.of(docIds).iterator(); } private static Reply createDocumentReply(String docId) { |