From 04d69a9e944d77bb729a056839a56a816bfca884 Mon Sep 17 00:00:00 2001 From: Benjamin Graf Date: Thu, 4 Jan 2024 19:32:53 +0100 Subject: [PATCH] Fixes from static code analysis --- .../core/jms/pool/JmsPoolNarayanaConnectionFactory.java | 3 +++ ...yanaRecoveryTerminationControllerAutoConfiguration.java | 7 +++---- .../openshift/recovery/StatefulsetRecoveryController.java | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/narayana-spring-boot-core/src/main/java/dev/snowdrop/boot/narayana/core/jms/pool/JmsPoolNarayanaConnectionFactory.java b/narayana-spring-boot-core/src/main/java/dev/snowdrop/boot/narayana/core/jms/pool/JmsPoolNarayanaConnectionFactory.java index 344339bd..ddd913e0 100644 --- a/narayana-spring-boot-core/src/main/java/dev/snowdrop/boot/narayana/core/jms/pool/JmsPoolNarayanaConnectionFactory.java +++ b/narayana-spring-boot-core/src/main/java/dev/snowdrop/boot/narayana/core/jms/pool/JmsPoolNarayanaConnectionFactory.java @@ -16,12 +16,15 @@ package dev.snowdrop.boot.narayana.core.jms.pool; +import java.io.Serial; + import jakarta.jms.Connection; import org.messaginghub.pooled.jms.JmsPoolXAConnectionFactory; public class JmsPoolNarayanaConnectionFactory extends JmsPoolXAConnectionFactory { + @Serial private static final long serialVersionUID = 1709204966732828338L; private String name; diff --git a/openshift/recovery-controller/src/main/java/dev/snowdrop/boot/narayana/openshift/recovery/NarayanaRecoveryTerminationControllerAutoConfiguration.java b/openshift/recovery-controller/src/main/java/dev/snowdrop/boot/narayana/openshift/recovery/NarayanaRecoveryTerminationControllerAutoConfiguration.java index 459e7cfc..357651eb 100644 --- a/openshift/recovery-controller/src/main/java/dev/snowdrop/boot/narayana/openshift/recovery/NarayanaRecoveryTerminationControllerAutoConfiguration.java +++ b/openshift/recovery-controller/src/main/java/dev/snowdrop/boot/narayana/openshift/recovery/NarayanaRecoveryTerminationControllerAutoConfiguration.java @@ -16,11 +16,10 @@ package dev.snowdrop.boot.narayana.openshift.recovery; -import java.util.Collections; import java.util.List; -import java.util.Optional; import io.fabric8.kubernetes.client.KubernetesClient; +import org.springframework.beans.factory.ObjectProvider; import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; @@ -40,8 +39,8 @@ public class NarayanaRecoveryTerminationControllerAutoConfiguration { @Bean(initMethod = "start", destroyMethod = "stop") @DependsOn("recoveryManagerService") @ConditionalOnMissingBean(NarayanaRecoveryTerminationController.class) - public NarayanaRecoveryTerminationController narayanaRecoveryTerminationController(PodStatusManager podStatusManager, Optional> shutdownControllers, Optional> recoveryErrorDetectors) { - return new NarayanaRecoveryTerminationController(podStatusManager, shutdownControllers.orElse(Collections.emptyList()), recoveryErrorDetectors.orElse(Collections.emptyList())); + public NarayanaRecoveryTerminationController narayanaRecoveryTerminationController(PodStatusManager podStatusManager, ObjectProvider> shutdownControllers, ObjectProvider> recoveryErrorDetectors) { + return new NarayanaRecoveryTerminationController(podStatusManager, shutdownControllers.getIfAvailable(List::of), recoveryErrorDetectors.getIfAvailable(List::of)); } @Bean diff --git a/openshift/recovery-controller/src/main/java/dev/snowdrop/boot/narayana/openshift/recovery/StatefulsetRecoveryController.java b/openshift/recovery-controller/src/main/java/dev/snowdrop/boot/narayana/openshift/recovery/StatefulsetRecoveryController.java index c0194e94..1b96a000 100644 --- a/openshift/recovery-controller/src/main/java/dev/snowdrop/boot/narayana/openshift/recovery/StatefulsetRecoveryController.java +++ b/openshift/recovery-controller/src/main/java/dev/snowdrop/boot/narayana/openshift/recovery/StatefulsetRecoveryController.java @@ -100,7 +100,7 @@ public void periodicCheck() throws Exception { this.kubernetesClient.apps().statefulSets().withName(this.properties.getStatefulset()).scale(minReplicas); LOG.info("Statefulset {} successfully scaled to {} replicas", this.properties.getStatefulset(), minReplicas); } else if (replicas == 0) { - LOG.debug("StatefulSet {} is going to be shut down. Controller will not interfere", this.properties.getStatefulset(), replicas); + LOG.debug("StatefulSet {} is going to be shut down. Controller will not interfere", this.properties.getStatefulset()); } else { LOG.debug("StatefulSet {} has a sufficient number of replicas: {} >= {}", this.properties.getStatefulset(), replicas, minReplicas); }