diff options
author | Harald Musum <musum@yahooinc.com> | 2024-04-11 23:13:46 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-11 23:13:46 +0200 |
commit | 7e7ebf7b527be1f163d497a41898e2252d878fe7 (patch) | |
tree | 879722e0afee0c88ad22344000c1567d79d741fa /jdisc_core/src/main/java | |
parent | a6fe59bf11e974b409caf73ac606ba750f45db8e (diff) | |
parent | 2d6bbe0b8bff09d105b77161c1d26a00ce43bf0c (diff) |
Merge pull request #30891 from vespa-engine/balder/list-dot-of
Unify on List.of
Diffstat (limited to 'jdisc_core/src/main/java')
6 files changed, 17 insertions, 23 deletions
diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/application/BundleInstaller.java b/jdisc_core/src/main/java/com/yahoo/jdisc/application/BundleInstaller.java index 60ca0851fd4..1e0050335dc 100644 --- a/jdisc_core/src/main/java/com/yahoo/jdisc/application/BundleInstaller.java +++ b/jdisc_core/src/main/java/com/yahoo/jdisc/application/BundleInstaller.java @@ -5,11 +5,9 @@ import com.google.inject.Inject; import org.osgi.framework.Bundle; import org.osgi.framework.BundleException; -import java.util.Arrays; import java.util.LinkedList; import java.util.List; -import static java.util.Collections.singletonList; /** * <p>This is a utility class to help with installing, starting, stopping and uninstalling OSGi Bundles. You can choose @@ -30,7 +28,7 @@ public final class BundleInstaller { } public List<Bundle> installAndStart(String... locations) throws BundleException { - return installAndStart(Arrays.asList(locations)); + return installAndStart(List.of(locations)); } public List<Bundle> installAndStart(Iterable<String> locations) throws BundleException { @@ -56,7 +54,7 @@ public final class BundleInstaller { } public void stopAndUninstall(Bundle... bundles) throws BundleException { - stopAndUninstall(Arrays.asList(bundles)); + stopAndUninstall(List.of(bundles)); } public void stopAndUninstall(Iterable<Bundle> bundles) throws BundleException { @@ -76,7 +74,7 @@ public final class BundleInstaller { throw new BundleException("OSGi header '" + OsgiHeader.APPLICATION + "' not allowed for " + "non-application bundle " + bundle.getSymbolicName() + "."); } - osgiFramework.startBundles(singletonList(bundle), false); + osgiFramework.startBundles(List.of(bundle), false); } private void stop(Bundle bundle) throws BundleException { diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/application/ContainerBuilder.java b/jdisc_core/src/main/java/com/yahoo/jdisc/application/ContainerBuilder.java index 6550d9b5386..8b3fe4c13aa 100644 --- a/jdisc_core/src/main/java/com/yahoo/jdisc/application/ContainerBuilder.java +++ b/jdisc_core/src/main/java/com/yahoo/jdisc/application/ContainerBuilder.java @@ -8,7 +8,6 @@ import com.google.inject.Module; import com.yahoo.jdisc.Container; import com.yahoo.jdisc.handler.RequestHandler; -import java.util.Collections; import java.util.HashMap; import java.util.LinkedList; import java.util.List; @@ -107,7 +106,7 @@ public class ContainerBuilder { public static List<String> safeStringSplit(Object obj, String delim) { if (!(obj instanceof String)) { - return Collections.emptyList(); + return List.of(); } List<String> lst = new LinkedList<>(); for (String str : ((String)obj).split(delim)) { diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/core/Main.java b/jdisc_core/src/main/java/com/yahoo/jdisc/core/Main.java index edd4dd40496..b2a8660e2a8 100644 --- a/jdisc_core/src/main/java/com/yahoo/jdisc/core/Main.java +++ b/jdisc_core/src/main/java/com/yahoo/jdisc/core/Main.java @@ -6,8 +6,7 @@ import com.yahoo.jdisc.application.ContainerBuilder; import com.yahoo.jdisc.application.OsgiFramework; import java.io.IOException; -import java.util.Arrays; -import java.util.Collections; +import java.util.List; /** * @author Simon Thoresen Hult @@ -31,7 +30,7 @@ public class Main { static Iterable<Module> newConfigModule() { String configFile = System.getProperty("jdisc.config.file"); if (configFile == null) { - return Collections.emptyList(); + return List.of(); } Module configModule; try { @@ -39,7 +38,7 @@ public class Main { } catch (IOException e) { throw new IllegalStateException("Exception thrown while reading config file '" + configFile + "'.", e); } - return Arrays.asList(configModule); + return List.of(configModule); } } diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/handler/RequestDispatch.java b/jdisc_core/src/main/java/com/yahoo/jdisc/handler/RequestDispatch.java index ef420d69f16..c39a70c7093 100644 --- a/jdisc_core/src/main/java/com/yahoo/jdisc/handler/RequestDispatch.java +++ b/jdisc_core/src/main/java/com/yahoo/jdisc/handler/RequestDispatch.java @@ -8,7 +8,7 @@ import com.yahoo.jdisc.Response; import com.yahoo.jdisc.SharedResource; import java.nio.ByteBuffer; -import java.util.Collections; +import java.util.List; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; import java.util.concurrent.Executor; @@ -35,7 +35,7 @@ import java.util.concurrent.TimeoutException; * } * @Override * protected Iterable<ByteBuffer> requestContent() { - * return Collections.singleton(ByteBuffer.wrap(new byte[] { 6, 9 })); + * return Set.of(ByteBuffer.wrap(new byte[] { 6, 9 })); * } * @Override * public ContentChannel handleResponse(Response response) { @@ -69,7 +69,7 @@ public abstract class RequestDispatch implements Future<Response>, ResponseHandl * @return The ByteBuffers to write to the Request's ContentChannel. */ protected Iterable<ByteBuffer> requestContent() { - return Collections.emptyList(); + return List.of(); } /** diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/handler/ResponseDispatch.java b/jdisc_core/src/main/java/com/yahoo/jdisc/handler/ResponseDispatch.java index ff1f23917d7..0670aa5ea67 100644 --- a/jdisc_core/src/main/java/com/yahoo/jdisc/handler/ResponseDispatch.java +++ b/jdisc_core/src/main/java/com/yahoo/jdisc/handler/ResponseDispatch.java @@ -5,8 +5,7 @@ import com.yahoo.jdisc.Response; import com.yahoo.jdisc.SharedResource; import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.Collections; +import java.util.List; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; @@ -28,7 +27,7 @@ import java.util.concurrent.TimeoutException; * } * @Override * protected Iterable<ByteBuffer> responseContent() { - * return Collections.singleton(ByteBuffer.wrap(new byte[] { 6, 9 })); + * return Set.of(ByteBuffer.wrap(new byte[] { 6, 9 })); * } * }.dispatch(handler); * } @@ -56,7 +55,7 @@ public abstract class ResponseDispatch implements Future<Boolean> { * @return The ByteBuffers to write to the Response's ContentChannel. */ protected Iterable<ByteBuffer> responseContent() { - return Collections.emptyList(); + return List.of(); } /** @@ -130,7 +129,7 @@ public abstract class ResponseDispatch implements Future<Boolean> { * @return The created ResponseDispatch. */ public static ResponseDispatch newInstance(int responseStatus, ByteBuffer... content) { - return newInstance(new Response(responseStatus), Arrays.asList(content)); + return newInstance(new Response(responseStatus), List.of(content)); } /** @@ -155,7 +154,7 @@ public abstract class ResponseDispatch implements Future<Boolean> { * @return The created ResponseDispatch. */ public static ResponseDispatch newInstance(Response response, ByteBuffer... content) { - return newInstance(response, Arrays.asList(content)); + return newInstance(response, List.of(content)); } /** diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/test/NonWorkingOsgiFramework.java b/jdisc_core/src/main/java/com/yahoo/jdisc/test/NonWorkingOsgiFramework.java index 1b90e8adcfe..3565a1ec4c5 100644 --- a/jdisc_core/src/main/java/com/yahoo/jdisc/test/NonWorkingOsgiFramework.java +++ b/jdisc_core/src/main/java/com/yahoo/jdisc/test/NonWorkingOsgiFramework.java @@ -6,7 +6,6 @@ import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; import java.util.Collection; -import java.util.Collections; import java.util.List; /** @@ -36,12 +35,12 @@ public class NonWorkingOsgiFramework implements OsgiFramework { @Override public List<Bundle> bundles() { - return Collections.emptyList(); + return List.of(); } @Override public List<Bundle> getBundles(Bundle requestingBundle) { - return Collections.emptyList(); + return List.of(); } @Override |