This is an automated email from the ASF dual-hosted git repository.
dongjoon pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/spark-kubernetes-operator.git
The following commit(s) were added to refs/heads/main by this push:
new 88601b7 [SPARK-53814] Use Java `List.of` instead of
`Collections.(empty|singleton)List`
88601b7 is described below
commit 88601b7e78f822f89e23e153f3caf95e9d6a57d3
Author: Dongjoon Hyun <[email protected]>
AuthorDate: Tue Oct 7 08:34:42 2025 -0700
[SPARK-53814] Use Java `List.of` instead of
`Collections.(empty|singleton)List`
### What changes were proposed in this pull request?
This PR aims to use Java `List.of` instead of `Collections.emptyList` or
`Collections.singletonList`.
### Why are the changes needed?
This PR aims to use Java 9+ `List.of` API instead of
`Collections.emptyList` or `Collections.singletonList` because it's more
concise and modern APIs.
```java
- HealthProbe healthyProbe =
- new HealthProbe(Collections.singletonList(operator),
Collections.emptyList());
HealthProbe healthyProbe = new HealthProbe(List.of(operator), List.of());
```
### Does this PR introduce _any_ user-facing change?
No behavior change.
### How was this patch tested?
Pass the CIs.
### Was this patch authored or co-authored using generative AI tooling?
No.
Closes #366 from dongjoon-hyun/SPARK-53814.
Authored-by: Dongjoon Hyun <[email protected]>
Signed-off-by: Dongjoon Hyun <[email protected]>
---
.../operator/metrics/PrometheusPullModelHandler.java | 5 ++---
.../k8s/operator/reconciler/SparkAppReconciler.java | 13 ++++---------
.../reconciler/reconcilesteps/AppRunningStep.java | 5 ++---
.../source/KubernetesMetricsInterceptorTest.java | 5 ++---
.../spark/k8s/operator/probe/HealthProbeTest.java | 9 +++------
.../spark/k8s/operator/probe/ProbeServiceTest.java | 11 +++--------
.../operator/reconciler/SparkAppReconcilerTest.java | 14 +++++++-------
.../reconciler/reconcilesteps/AppCleanUpStepTest.java | 19 ++++++++-----------
.../reconciler/reconcilesteps/AppInitStepTest.java | 15 ++++++---------
.../spark/k8s/operator/SparkAppResourceSpec.java | 3 +--
.../spark/k8s/operator/utils/ConfigMapSpecUtils.java | 3 +--
.../spark/k8s/operator/SparkAppResourceSpecTest.java | 8 +++-----
.../k8s/operator/utils/ConfigMapSpecUtilsTest.java | 9 +++------
13 files changed, 45 insertions(+), 74 deletions(-)
diff --git
a/spark-operator/src/main/java/org/apache/spark/k8s/operator/metrics/PrometheusPullModelHandler.java
b/spark-operator/src/main/java/org/apache/spark/k8s/operator/metrics/PrometheusPullModelHandler.java
index 736a845..b8de8ed 100644
---
a/spark-operator/src/main/java/org/apache/spark/k8s/operator/metrics/PrometheusPullModelHandler.java
+++
b/spark-operator/src/main/java/org/apache/spark/k8s/operator/metrics/PrometheusPullModelHandler.java
@@ -24,7 +24,6 @@ import static
org.apache.spark.k8s.operator.utils.ProbeUtil.sendMessage;
import java.io.IOException;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -94,7 +93,7 @@ public class PrometheusPullModelHandler extends
PrometheusServlet implements Htt
exchange,
HTTP_OK,
formatMetricsSnapshot(),
- Map.of("Content-Type",
Collections.singletonList("text/plain;version=0.0.4")));
+ Map.of("Content-Type", List.of("text/plain;version=0.0.4")));
} else {
HttpServletRequest httpServletRequest = null;
String value = getMetricsSnapshot(httpServletRequest);
@@ -102,7 +101,7 @@ public class PrometheusPullModelHandler extends
PrometheusServlet implements Htt
exchange,
HTTP_OK,
String.join("\n", filterNonEmptyRecords(value)),
- Map.of("Content-Type",
Collections.singletonList("text/plain;version=0.0.4")));
+ Map.of("Content-Type", List.of("text/plain;version=0.0.4")));
}
}
diff --git
a/spark-operator/src/main/java/org/apache/spark/k8s/operator/reconciler/SparkAppReconciler.java
b/spark-operator/src/main/java/org/apache/spark/k8s/operator/reconciler/SparkAppReconciler.java
index e5ab729..99d09ba 100644
---
a/spark-operator/src/main/java/org/apache/spark/k8s/operator/reconciler/SparkAppReconciler.java
+++
b/spark-operator/src/main/java/org/apache/spark/k8s/operator/reconciler/SparkAppReconciler.java
@@ -25,7 +25,6 @@ import static
org.apache.spark.k8s.operator.utils.Utils.basicLabelSecondaryToPri
import static
org.apache.spark.k8s.operator.utils.Utils.commonResourceLabelsStr;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
import io.fabric8.kubernetes.api.model.Pod;
@@ -178,20 +177,16 @@ public class SparkAppReconciler implements
Reconciler<SparkApplication>, Cleaner
steps.add(
new AppResourceObserveStep(
List.of(new AppDriverStartObserver(), new
AppDriverReadyObserver())));
- steps.add(
- new AppResourceObserveStep(Collections.singletonList(new
AppDriverRunningObserver())));
- steps.add(
- new AppResourceObserveStep(Collections.singletonList(new
AppDriverTimeoutObserver())));
+ steps.add(new AppResourceObserveStep(List.of(new
AppDriverRunningObserver())));
+ steps.add(new AppResourceObserveStep(List.of(new
AppDriverTimeoutObserver())));
}
case DriverReady,
InitializedBelowThresholdExecutors,
RunningHealthy,
RunningWithBelowThresholdExecutors -> {
steps.add(new AppRunningStep());
- steps.add(
- new AppResourceObserveStep(Collections.singletonList(new
AppDriverRunningObserver())));
- steps.add(
- new AppResourceObserveStep(Collections.singletonList(new
AppDriverTimeoutObserver())));
+ steps.add(new AppResourceObserveStep(List.of(new
AppDriverRunningObserver())));
+ steps.add(new AppResourceObserveStep(List.of(new
AppDriverTimeoutObserver())));
}
default -> steps.add(new AppUnknownStateStep());
}
diff --git
a/spark-operator/src/main/java/org/apache/spark/k8s/operator/reconciler/reconcilesteps/AppRunningStep.java
b/spark-operator/src/main/java/org/apache/spark/k8s/operator/reconciler/reconcilesteps/AppRunningStep.java
index 897c46e..47a45d6 100644
---
a/spark-operator/src/main/java/org/apache/spark/k8s/operator/reconciler/reconcilesteps/AppRunningStep.java
+++
b/spark-operator/src/main/java/org/apache/spark/k8s/operator/reconciler/reconcilesteps/AppRunningStep.java
@@ -22,7 +22,7 @@ package
org.apache.spark.k8s.operator.reconciler.reconcilesteps;
import static org.apache.spark.k8s.operator.Constants.*;
import static
org.apache.spark.k8s.operator.reconciler.ReconcileProgress.completeAndDefaultRequeue;
-import java.util.Collections;
+import java.util.List;
import java.util.Set;
import io.fabric8.kubernetes.api.model.Pod;
@@ -85,8 +85,7 @@ public class AppRunningStep extends AppReconcileStep {
}
}
if (proposedStateSummary.equals(prevStateSummary)) {
- return observeDriver(
- context, statusRecorder, Collections.singletonList(new
AppDriverRunningObserver()));
+ return observeDriver(context, statusRecorder, List.of(new
AppDriverRunningObserver()));
} else {
ApplicationStatus updatedStatus =
context
diff --git
a/spark-operator/src/test/java/org/apache/spark/k8s/operator/metrics/source/KubernetesMetricsInterceptorTest.java
b/spark-operator/src/test/java/org/apache/spark/k8s/operator/metrics/source/KubernetesMetricsInterceptorTest.java
index 51efcc2..6f71b74 100644
---
a/spark-operator/src/test/java/org/apache/spark/k8s/operator/metrics/source/KubernetesMetricsInterceptorTest.java
+++
b/spark-operator/src/test/java/org/apache/spark/k8s/operator/metrics/source/KubernetesMetricsInterceptorTest.java
@@ -22,7 +22,6 @@ package org.apache.spark.k8s.operator.metrics.source;
import static org.junit.jupiter.api.Assertions.assertThrows;
import java.util.Arrays;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -66,7 +65,7 @@ class KubernetesMetricsInterceptorTest {
@Order(1)
void testMetricsEnabled() {
KubernetesMetricsInterceptor metricsInterceptor = new
KubernetesMetricsInterceptor();
- List<Interceptor> interceptors =
Collections.singletonList(metricsInterceptor);
+ List<Interceptor> interceptors = List.of(metricsInterceptor);
try (KubernetesClient client =
KubernetesClientFactory.buildKubernetesClient(
interceptors, kubernetesClient.getConfiguration())) {
@@ -106,7 +105,7 @@ class KubernetesMetricsInterceptorTest {
@Order(2)
void testWhenKubernetesServerNotWorking() {
KubernetesMetricsInterceptor metricsInterceptor = new
KubernetesMetricsInterceptor();
- List<Interceptor> interceptors =
Collections.singletonList(metricsInterceptor);
+ List<Interceptor> interceptors = List.of(metricsInterceptor);
try (KubernetesClient client =
KubernetesClientFactory.buildKubernetesClient(
interceptors, kubernetesClient.getConfiguration())) {
diff --git
a/spark-operator/src/test/java/org/apache/spark/k8s/operator/probe/HealthProbeTest.java
b/spark-operator/src/test/java/org/apache/spark/k8s/operator/probe/HealthProbeTest.java
index 471c27a..0ffe870 100644
---
a/spark-operator/src/test/java/org/apache/spark/k8s/operator/probe/HealthProbeTest.java
+++
b/spark-operator/src/test/java/org/apache/spark/k8s/operator/probe/HealthProbeTest.java
@@ -25,7 +25,6 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.util.Arrays;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -108,7 +107,7 @@ class HealthProbeTest {
@Test
void testHealthProbeWithInformerHealthWithMultiOperators() {
- HealthProbe healthyProbe = new HealthProbe(operators,
Collections.emptyList());
+ HealthProbe healthyProbe = new HealthProbe(operators, List.of());
isRunning.set(true);
assertFalse(
healthyProbe.isHealthy(),
@@ -128,8 +127,7 @@ class HealthProbeTest {
@Test
void testHealthProbeWithInformerHealthWithSingleOperator() {
- HealthProbe healthyProbe =
- new HealthProbe(Collections.singletonList(operator),
Collections.emptyList());
+ HealthProbe healthyProbe = new HealthProbe(List.of(operator), List.of());
assertFalse(healthyProbe.isHealthy(), "Health Probe should fail when
operator is not running");
isRunning.set(true);
unhealthyEventSources.put(
@@ -143,8 +141,7 @@ class HealthProbeTest {
@Test
void testHealthProbeWithSentinelHealthWithMultiOperators() {
var sentinelManager = mock(SentinelManager.class);
- HealthProbe healthyProbe =
- new HealthProbe(operators, Collections.singletonList(sentinelManager));
+ HealthProbe healthyProbe = new HealthProbe(operators,
List.of(sentinelManager));
isRunning.set(true);
isRunning2.set(true);
when(sentinelManager.allSentinelsAreHealthy()).thenReturn(false);
diff --git
a/spark-operator/src/test/java/org/apache/spark/k8s/operator/probe/ProbeServiceTest.java
b/spark-operator/src/test/java/org/apache/spark/k8s/operator/probe/ProbeServiceTest.java
index da221c3..8afd5ea 100644
---
a/spark-operator/src/test/java/org/apache/spark/k8s/operator/probe/ProbeServiceTest.java
+++
b/spark-operator/src/test/java/org/apache/spark/k8s/operator/probe/ProbeServiceTest.java
@@ -31,7 +31,6 @@ import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -56,9 +55,7 @@ class ProbeServiceTest {
when(runtimeInfo.unhealthyInformerWrappingEventSourceHealthIndicator())
.thenReturn(new HashMap<>());
when(sentinelManager.allSentinelsAreHealthy()).thenReturn(true);
- ProbeService probeService =
- new ProbeService(
- Collections.singletonList(operator),
Collections.singletonList(sentinelManager), null);
+ ProbeService probeService = new ProbeService(List.of(operator),
List.of(sentinelManager), null);
probeService.start();
hitHealthyEndpoint();
probeService.stop();
@@ -83,8 +80,7 @@ class ProbeServiceTest {
.thenReturn(new HashMap<>());
when(sentinelManager.allSentinelsAreHealthy()).thenReturn(true);
ProbeService probeService =
- new ProbeService(
- List.of(operator, operator1),
Collections.singletonList(sentinelManager), null);
+ new ProbeService(List.of(operator, operator1),
List.of(sentinelManager), null);
probeService.start();
hitHealthyEndpoint();
probeService.stop();
@@ -110,8 +106,7 @@ class ProbeServiceTest {
.thenReturn(new HashMap<>());
when(operator1.getKubernetesClient()).thenReturn(client);
ProbeService probeService =
- new ProbeService(
- List.of(operator, operator1),
Collections.singletonList(sentinelManager), null);
+ new ProbeService(List.of(operator, operator1),
List.of(sentinelManager), null);
probeService.start();
hitStartedUpEndpoint();
probeService.stop();
diff --git
a/spark-operator/src/test/java/org/apache/spark/k8s/operator/reconciler/SparkAppReconcilerTest.java
b/spark-operator/src/test/java/org/apache/spark/k8s/operator/reconciler/SparkAppReconcilerTest.java
index ff7f371..3f327e5 100644
---
a/spark-operator/src/test/java/org/apache/spark/k8s/operator/reconciler/SparkAppReconcilerTest.java
+++
b/spark-operator/src/test/java/org/apache/spark/k8s/operator/reconciler/SparkAppReconcilerTest.java
@@ -29,7 +29,7 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.mockConstruction;
import static org.mockito.Mockito.when;
-import java.util.Collections;
+import java.util.List;
import java.util.Optional;
import io.fabric8.kubernetes.api.model.Pod;
@@ -96,8 +96,8 @@ class SparkAppReconcilerTest {
when(mock.getClient()).thenReturn(mockClient);
when(mock.getDriverPod()).thenReturn(Optional.of(mockDriver));
when(mock.getDriverPodSpec()).thenReturn(mockDriver);
-
when(mock.getDriverPreResourcesSpec()).thenReturn(Collections.emptyList());
-
when(mock.getDriverResourcesSpec()).thenReturn(Collections.emptyList());
+ when(mock.getDriverPreResourcesSpec()).thenReturn(List.of());
+ when(mock.getDriverResourcesSpec()).thenReturn(List.of());
});
MockedStatic<ReconcilerUtils> utils =
Mockito.mockStatic(ReconcilerUtils.class)) {
// delete running app
@@ -128,8 +128,8 @@ class SparkAppReconcilerTest {
when(mock.getClient()).thenReturn(mockClient);
when(mock.getDriverPod()).thenReturn(Optional.of(mockDriver));
when(mock.getDriverPodSpec()).thenReturn(mockDriver);
-
when(mock.getDriverPreResourcesSpec()).thenReturn(Collections.emptyList());
-
when(mock.getDriverResourcesSpec()).thenReturn(Collections.emptyList());
+ when(mock.getDriverPreResourcesSpec()).thenReturn(List.of());
+ when(mock.getDriverResourcesSpec()).thenReturn(List.of());
});
MockedStatic<ReconcilerUtils> utils =
Mockito.mockStatic(ReconcilerUtils.class)) {
// delete app
@@ -160,8 +160,8 @@ class SparkAppReconcilerTest {
(mock, context) -> {
when(mock.getResource()).thenReturn(app);
when(mock.getClient()).thenReturn(mockClient);
-
when(mock.getDriverPreResourcesSpec()).thenReturn(Collections.emptyList());
-
when(mock.getDriverResourcesSpec()).thenReturn(Collections.emptyList());
+ when(mock.getDriverPreResourcesSpec()).thenReturn(List.of());
+ when(mock.getDriverResourcesSpec()).thenReturn(List.of());
});
MockedStatic<ReconcilerUtils> utils =
Mockito.mockStatic(ReconcilerUtils.class)) {
// delete app
diff --git
a/spark-operator/src/test/java/org/apache/spark/k8s/operator/reconciler/reconcilesteps/AppCleanUpStepTest.java
b/spark-operator/src/test/java/org/apache/spark/k8s/operator/reconciler/reconcilesteps/AppCleanUpStepTest.java
index 1ff19fd..86f3086 100644
---
a/spark-operator/src/test/java/org/apache/spark/k8s/operator/reconciler/reconcilesteps/AppCleanUpStepTest.java
+++
b/spark-operator/src/test/java/org/apache/spark/k8s/operator/reconciler/reconcilesteps/AppCleanUpStepTest.java
@@ -31,7 +31,6 @@ import static org.mockito.Mockito.when;
import java.time.Duration;
import java.time.Instant;
-import java.util.Collections;
import java.util.List;
import java.util.Optional;
@@ -170,8 +169,8 @@ class AppCleanUpStepTest {
when(mockAppContext.getClient()).thenReturn(mockClient);
Pod driverPod = mock(Pod.class);
when(mockAppContext.getDriverPod()).thenReturn(Optional.of(driverPod));
-
when(mockAppContext.getDriverPreResourcesSpec()).thenReturn(Collections.emptyList());
-
when(mockAppContext.getDriverResourcesSpec()).thenReturn(Collections.emptyList());
+ when(mockAppContext.getDriverPreResourcesSpec()).thenReturn(List.of());
+ when(mockAppContext.getDriverResourcesSpec()).thenReturn(List.of());
when(mockRecorder.persistStatus(eq(mockAppContext),
any())).thenReturn(true);
when(mockRecorder.appendNewStateAndPersist(eq(mockAppContext),
any())).thenReturn(true);
@@ -260,8 +259,8 @@ class AppCleanUpStepTest {
when(mockAppContext.getClient()).thenReturn(mockClient);
Pod driverPod = mock(Pod.class);
when(mockAppContext.getDriverPod()).thenReturn(Optional.of(driverPod));
-
when(mockAppContext.getDriverPreResourcesSpec()).thenReturn(Collections.emptyList());
-
when(mockAppContext.getDriverResourcesSpec()).thenReturn(Collections.emptyList());
+ when(mockAppContext.getDriverPreResourcesSpec()).thenReturn(List.of());
+ when(mockAppContext.getDriverResourcesSpec()).thenReturn(List.of());
when(mockRecorder.persistStatus(eq(mockAppContext),
any())).thenReturn(true);
when(mockRecorder.appendNewStateAndPersist(eq(mockAppContext),
any())).thenReturn(true);
@@ -314,14 +313,12 @@ class AppCleanUpStepTest {
ConfigMap resource2 = mock(ConfigMap.class);
when(mockAppContext1.getDriverPod()).thenReturn(Optional.of(driverPod));
when(mockAppContext1.getDriverPodSpec()).thenReturn(driverPodSpec);
- when(mockAppContext1.getDriverPreResourcesSpec())
- .thenReturn(Collections.singletonList(resource1));
-
when(mockAppContext1.getDriverResourcesSpec()).thenReturn(Collections.singletonList(resource2));
+
when(mockAppContext1.getDriverPreResourcesSpec()).thenReturn(List.of(resource1));
+
when(mockAppContext1.getDriverResourcesSpec()).thenReturn(List.of(resource2));
when(mockAppContext2.getDriverPod()).thenReturn(Optional.of(driverPod));
when(mockAppContext2.getDriverPodSpec()).thenReturn(driverPodSpec);
- when(mockAppContext2.getDriverPreResourcesSpec())
- .thenReturn(Collections.singletonList(resource1));
-
when(mockAppContext2.getDriverResourcesSpec()).thenReturn(Collections.singletonList(resource2));
+
when(mockAppContext2.getDriverPreResourcesSpec()).thenReturn(List.of(resource1));
+
when(mockAppContext2.getDriverResourcesSpec()).thenReturn(List.of(resource2));
when(mockRecorder.persistStatus(any(), any())).thenReturn(true);
when(mockRecorder.appendNewStateAndPersist(any(), any())).thenReturn(true);
diff --git
a/spark-operator/src/test/java/org/apache/spark/k8s/operator/reconciler/reconcilesteps/AppInitStepTest.java
b/spark-operator/src/test/java/org/apache/spark/k8s/operator/reconciler/reconcilesteps/AppInitStepTest.java
index 0131025..6d6a362 100644
---
a/spark-operator/src/test/java/org/apache/spark/k8s/operator/reconciler/reconcilesteps/AppInitStepTest.java
+++
b/spark-operator/src/test/java/org/apache/spark/k8s/operator/reconciler/reconcilesteps/AppInitStepTest.java
@@ -25,7 +25,6 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import java.util.Collections;
import java.util.List;
import java.util.Map;
@@ -103,10 +102,9 @@ class AppInitStepTest {
SparkApplication application = new SparkApplication();
application.setMetadata(applicationMetadata);
when(mocksparkAppContext.getResource()).thenReturn(application);
-
when(mocksparkAppContext.getDriverPreResourcesSpec()).thenReturn(Collections.emptyList());
+
when(mocksparkAppContext.getDriverPreResourcesSpec()).thenReturn(List.of());
when(mocksparkAppContext.getDriverPodSpec()).thenReturn(driverPodSpec);
- when(mocksparkAppContext.getDriverResourcesSpec())
- .thenReturn(Collections.singletonList(resourceConfigMapSpec));
+
when(mocksparkAppContext.getDriverResourcesSpec()).thenReturn(List.of(resourceConfigMapSpec));
when(mocksparkAppContext.getClient()).thenReturn(kubernetesClient);
when(recorder.appendNewStateAndPersist(any(), any())).thenReturn(true);
when(recorder.persistStatus(any(), any())).thenReturn(true);
@@ -137,9 +135,9 @@ class AppInitStepTest {
application.setMetadata(applicationMetadata);
when(mocksparkAppContext.getResource()).thenReturn(application);
when(mocksparkAppContext.getDriverPreResourcesSpec())
- .thenReturn(Collections.singletonList(preResourceConfigMapSpec));
+ .thenReturn(List.of(preResourceConfigMapSpec));
when(mocksparkAppContext.getDriverPodSpec()).thenReturn(driverPodSpec);
-
when(mocksparkAppContext.getDriverResourcesSpec()).thenReturn(Collections.emptyList());
+ when(mocksparkAppContext.getDriverResourcesSpec()).thenReturn(List.of());
when(recorder.appendNewStateAndPersist(any(), any())).thenReturn(true);
when(recorder.persistStatus(any(), any())).thenReturn(true);
@@ -201,10 +199,9 @@ class AppInitStepTest {
SparkApplication application = new SparkApplication();
application.setMetadata(applicationMetadata);
when(mocksparkAppContext.getResource()).thenReturn(application);
-
when(mocksparkAppContext.getDriverPreResourcesSpec()).thenReturn(Collections.emptyList());
+
when(mocksparkAppContext.getDriverPreResourcesSpec()).thenReturn(List.of());
when(mocksparkAppContext.getDriverPodSpec()).thenReturn(driverPodSpec);
- when(mocksparkAppContext.getDriverResourcesSpec())
- .thenReturn(Collections.singletonList(resourceConfigMapSpec));
+
when(mocksparkAppContext.getDriverResourcesSpec()).thenReturn(List.of(resourceConfigMapSpec));
when(mocksparkAppContext.getClient()).thenReturn(kubernetesClient);
when(recorder.appendNewStateAndPersist(any(), any())).thenReturn(false,
true);
when(recorder.persistStatus(any(), any())).thenReturn(false, true);
diff --git
a/spark-submission-worker/src/main/java/org/apache/spark/k8s/operator/SparkAppResourceSpec.java
b/spark-submission-worker/src/main/java/org/apache/spark/k8s/operator/SparkAppResourceSpec.java
index 8fb5be2..031884b 100644
---
a/spark-submission-worker/src/main/java/org/apache/spark/k8s/operator/SparkAppResourceSpec.java
+++
b/spark-submission-worker/src/main/java/org/apache/spark/k8s/operator/SparkAppResourceSpec.java
@@ -21,7 +21,6 @@ package org.apache.spark.k8s.operator;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
@@ -170,7 +169,7 @@ public class SparkAppResourceSpec {
private List<HasMetadata> configureDriverServerIngress(
SparkPod pod, List<DriverServiceIngressSpec> driverServiceIngressList) {
if (driverServiceIngressList == null ||
driverServiceIngressList.isEmpty()) {
- return Collections.emptyList();
+ return List.of();
}
return driverServiceIngressList.stream()
.map(spec -> DriverServiceIngressUtils.buildIngressService(spec,
pod.pod().getMetadata()))
diff --git
a/spark-submission-worker/src/main/java/org/apache/spark/k8s/operator/utils/ConfigMapSpecUtils.java
b/spark-submission-worker/src/main/java/org/apache/spark/k8s/operator/utils/ConfigMapSpecUtils.java
index 49496c2..6a32afd 100644
---
a/spark-submission-worker/src/main/java/org/apache/spark/k8s/operator/utils/ConfigMapSpecUtils.java
+++
b/spark-submission-worker/src/main/java/org/apache/spark/k8s/operator/utils/ConfigMapSpecUtils.java
@@ -19,7 +19,6 @@
package org.apache.spark.k8s.operator.utils;
-import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
@@ -40,7 +39,7 @@ public final class ConfigMapSpecUtils {
*/
public static List<ConfigMap> buildConfigMaps(List<ConfigMapSpec>
configMapMountList) {
if (configMapMountList == null || configMapMountList.isEmpty()) {
- return Collections.emptyList();
+ return List.of();
}
return configMapMountList.stream()
.map(
diff --git
a/spark-submission-worker/src/test/java/org/apache/spark/k8s/operator/SparkAppResourceSpecTest.java
b/spark-submission-worker/src/test/java/org/apache/spark/k8s/operator/SparkAppResourceSpecTest.java
index e6a50a0..0dfc019 100644
---
a/spark-submission-worker/src/test/java/org/apache/spark/k8s/operator/SparkAppResourceSpecTest.java
+++
b/spark-submission-worker/src/test/java/org/apache/spark/k8s/operator/SparkAppResourceSpecTest.java
@@ -22,7 +22,6 @@ package org.apache.spark.k8s.operator;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-import java.util.Collections;
import java.util.List;
import scala.collection.immutable.HashMap;
@@ -60,8 +59,8 @@ class SparkAppResourceSpecTest {
// Add some mock resources and pre-resources
Pod pod1 = buildBasicPod("pod-1");
Pod pod2 = buildBasicPod("pod-2");
- List<HasMetadata> preResourceList = Collections.singletonList(pod1);
- List<HasMetadata> resourceList = Collections.singletonList(pod2);
+ List<HasMetadata> preResourceList = List.of(pod1);
+ List<HasMetadata> resourceList = List.of(pod2);
Seq<HasMetadata> preResourceSeq =
CollectionConverters.asScala(preResourceList).toList();
Seq<HasMetadata> resourceSeq =
CollectionConverters.asScala(resourceList).toList();
when(mockSpec.driverKubernetesResources()).thenReturn(resourceSeq);
@@ -70,8 +69,7 @@ class SparkAppResourceSpecTest {
when(mockSpec.systemProperties()).thenReturn(new HashMap<>());
SparkAppResourceSpec appResourceSpec =
- new SparkAppResourceSpec(
- mockConf, mockSpec, Collections.emptyList(),
Collections.emptyList());
+ new SparkAppResourceSpec(mockConf, mockSpec, List.of(), List.of());
Assertions.assertEquals(2, appResourceSpec.getDriverResources().size());
Assertions.assertEquals(1, appResourceSpec.getDriverPreResources().size());
diff --git
a/spark-submission-worker/src/test/java/org/apache/spark/k8s/operator/utils/ConfigMapSpecUtilsTest.java
b/spark-submission-worker/src/test/java/org/apache/spark/k8s/operator/utils/ConfigMapSpecUtilsTest.java
index deb1aa7..93f373a 100644
---
a/spark-submission-worker/src/test/java/org/apache/spark/k8s/operator/utils/ConfigMapSpecUtilsTest.java
+++
b/spark-submission-worker/src/test/java/org/apache/spark/k8s/operator/utils/ConfigMapSpecUtilsTest.java
@@ -21,7 +21,6 @@ package org.apache.spark.k8s.operator.utils;
import static org.junit.jupiter.api.Assertions.assertEquals;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -36,9 +35,8 @@ class ConfigMapSpecUtilsTest {
@Test
void buildConfigMaps() {
- assertEquals(Collections.emptyList(),
ConfigMapSpecUtils.buildConfigMaps(null));
- assertEquals(
- Collections.emptyList(),
ConfigMapSpecUtils.buildConfigMaps(Collections.emptyList()));
+ assertEquals(List.of(), ConfigMapSpecUtils.buildConfigMaps(null));
+ assertEquals(List.of(), ConfigMapSpecUtils.buildConfigMaps(List.of()));
Map<String, String> labels = Map.of("foo-label-key", "foo-label-value");
Map<String, String> annotations = Map.of("foo-annotation-key",
"foo-annotation-value");
@@ -57,8 +55,7 @@ class ConfigMapSpecUtilsTest {
.annotations(annotations)
.data(configMapData)
.build();
- List<ConfigMap> configMaps =
- ConfigMapSpecUtils.buildConfigMaps(Collections.singletonList(mount));
+ List<ConfigMap> configMaps =
ConfigMapSpecUtils.buildConfigMaps(List.of(mount));
assertEquals(1, configMaps.size());
ConfigMap configMap = configMaps.get(0);
assertEquals("test-config-map", configMap.getMetadata().getName());
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]