This is an automated email from the ASF dual-hosted git repository.

He-Pin pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/pekko-management.git


The following commit(s) were added to refs/heads/main by this push:
     new 5ad08b63 refactor: migrate Collections/Arrays.asList to Java 9+ 
collection factories (#856)
5ad08b63 is described below

commit 5ad08b63099e91fd9c0e9b160b9777859fd0237c
Author: He-Pin(kerr) <[email protected]>
AuthorDate: Fri Jun 26 17:17:19 2026 +0800

    refactor: migrate Collections/Arrays.asList to Java 9+ collection factories 
(#856)
    
    * refactor: migrate Collections/Arrays.asList to Java 9+ factory methods
    
    Motivation:
    Java 9+ provides List.of(), Map.of(), Set.of() factory methods that are
    more concise and return truly immutable collections.
    
    Modification:
    Replace Collections.singletonList() with List.of(),
    Collections.emptyList() with List.of(), and Arrays.asList() with
    List.of() in test code.
    
    Result:
    Cleaner, more idiomatic Java 17 code with immutable collection factories.
    
    Tests:
    Not run - compile-only test file changes
    
    References:
    None - Java 17 API modernization
    
    * fix: revert Collections.emptyList to original API
    
    Motivation:
    Review feedback: prefer Collections.emptyList() over List.of() for empty
    collections since it uses a well-known immutable singleton API.
    
    Modification:
    Revert empty list conversions while keeping non-empty Arrays.asList ->
    List.of conversions.
    
    Result:
    Empty collections use the established Collections.emptyList() API.
    
    * fix: apply javafmt formatting
    
    Motivation:
    CI javafmt check failed after reverting empty collection conversions.
    
    Modification:
    Run sbt javafmtAll to fix formatting in HealthCheckTest.java.
    
    Result:
    javafmt CI check passes.
---
 .../org/apache/pekko/management/HealthCheckTest.java   | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git 
a/management/src/test/java/org/apache/pekko/management/HealthCheckTest.java 
b/management/src/test/java/org/apache/pekko/management/HealthCheckTest.java
index f05fc0c7..179aab24 100644
--- a/management/src/test/java/org/apache/pekko/management/HealthCheckTest.java
+++ b/management/src/test/java/org/apache/pekko/management/HealthCheckTest.java
@@ -16,7 +16,6 @@ package org.apache.pekko.management;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import com.typesafe.config.ConfigFactory;
-import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 import java.util.concurrent.CompletableFuture;
@@ -72,8 +71,7 @@ public class HealthCheckTest {
   @Test
   public void okReturnsTrue() throws Exception {
     List<NamedHealthCheck> healthChecks =
-        Collections.singletonList(
-            new NamedHealthCheck("Ok", 
"org.apache.pekko.management.HealthCheckTest$Ok"));
+        List.of(new NamedHealthCheck("Ok", 
"org.apache.pekko.management.HealthCheckTest$Ok"));
     HealthChecks checks =
         new HealthChecks(
             system,
@@ -96,8 +94,7 @@ public class HealthCheckTest {
   @Test
   public void notOkayReturnsFalse() throws Exception {
     List<NamedHealthCheck> healthChecks =
-        Collections.singletonList(
-            new NamedHealthCheck("Ok", 
"org.apache.pekko.management.HealthCheckTest$Ok"));
+        List.of(new NamedHealthCheck("Ok", 
"org.apache.pekko.management.HealthCheckTest$Ok"));
     HealthChecks checks =
         new HealthChecks(
             system,
@@ -120,8 +117,7 @@ public class HealthCheckTest {
   @Test
   public void creatableThroughLegacyConstructor() throws Exception {
     List<NamedHealthCheck> healthChecks =
-        Collections.singletonList(
-            new NamedHealthCheck("Ok", 
"org.apache.pekko.management.HealthCheckTest$Ok"));
+        List.of(new NamedHealthCheck("Ok", 
"org.apache.pekko.management.HealthCheckTest$Ok"));
     HealthChecks checks =
         new HealthChecks(
             system,
@@ -138,7 +134,7 @@ public class HealthCheckTest {
   @Test
   public void throwsReturnsFailed() throws Exception {
     List<NamedHealthCheck> healthChecks =
-        Collections.singletonList(
+        List.of(
             new NamedHealthCheck("Throws", 
"org.apache.pekko.management.HealthCheckTest$Throws"));
     HealthChecks checks =
         new HealthChecks(
@@ -162,11 +158,11 @@ public class HealthCheckTest {
   @Test
   public void defineViaActorSystemSetup() throws Exception {
     StartupCheckSetup startupCheckSetup =
-        StartupCheckSetup.create(system -> Collections.singletonList(new 
NotOk(system)));
+        StartupCheckSetup.create(system -> List.of(new NotOk(system)));
     ReadinessCheckSetup readinessSetup =
-        ReadinessCheckSetup.create(system -> Arrays.asList(new Ok(), new 
NotOk(system)));
+        ReadinessCheckSetup.create(system -> List.of(new Ok(), new 
NotOk(system)));
     LivenessCheckSetup livenessSetup =
-        LivenessCheckSetup.create(system -> Collections.singletonList(new 
NotOk(system)));
+        LivenessCheckSetup.create(system -> List.of(new NotOk(system)));
     // bootstrapSetup is needed for config (otherwise default config)
     BootstrapSetup bootstrapSetup = 
BootstrapSetup.create(ConfigFactory.parseString("some=thing"));
     ActorSystemSetup actorSystemSetup =


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to