From 36fa915cbcef3f2b67cd77ff9ac3274669c49763 Mon Sep 17 00:00:00 2001 From: Avgustin Marinov Date: Fri, 11 Apr 2025 16:46:34 +0300 Subject: [PATCH] Improve @Value properties (#2352) Implement recommendation from https://docs.spring.io/spring-boot/reference/features/external-config.html to use kebab case for @Values: If you do want to use @Value, we recommend that you refer to property names using their canonical form (kebab-case using only lowercase letters). This will allow Spring Boot to use the same logic as it does when relaxed binding @ConfigurationProperties. Signed-off-by: Avgustin Marinov --- .../autoconfigure/ddi/ControllerSecurityConfiguration.java | 2 +- .../java/org/eclipse/hawkbit/amqp/AmqpConfiguration.java | 2 +- .../eclipse/hawkbit/repository/rsql/RsqlConfigHolder.java | 6 +++--- .../java/org/eclipse/hawkbit/repository/jpa/Statistics.java | 4 ++-- .../eclipse/hawkbit/repository/jpa/JpaConfiguration.java | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/hawkbit-ddi/hawkbit-ddi-starter/src/main/java/org/eclipse/hawkbit/autoconfigure/ddi/ControllerSecurityConfiguration.java b/hawkbit-ddi/hawkbit-ddi-starter/src/main/java/org/eclipse/hawkbit/autoconfigure/ddi/ControllerSecurityConfiguration.java index b75e497ef..336f03ce1 100644 --- a/hawkbit-ddi/hawkbit-ddi-starter/src/main/java/org/eclipse/hawkbit/autoconfigure/ddi/ControllerSecurityConfiguration.java +++ b/hawkbit-ddi/hawkbit-ddi-starter/src/main/java/org/eclipse/hawkbit/autoconfigure/ddi/ControllerSecurityConfiguration.java @@ -94,7 +94,7 @@ class ControllerSecurityConfiguration { @Order(301) protected SecurityFilterChain filterChainDDI( final HttpSecurity http, - @Value("${hawkbit.server.security.cors.disableForDdiApi:false}") final boolean disableCorsForDdiApi) throws Exception { + @Value("${hawkbit.server.security.cors.disable-for-ddi-api:false}") final boolean disableCorsForDdiApi) throws Exception { http .securityMatcher(DDI_ANT_MATCHERS) .csrf(AbstractHttpConfigurer::disable); diff --git a/hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpConfiguration.java b/hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpConfiguration.java index c7485073f..df528940d 100644 --- a/hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpConfiguration.java +++ b/hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpConfiguration.java @@ -99,7 +99,7 @@ public class AmqpConfiguration { @ConditionalOnMissingBean public ErrorHandler errorHandler( final List fatalExceptionStrategies, - @Value("${hawkbit.dmf.rabbitmq.fatalExceptionTypes:}") final List fatalExceptionTypes) { + @Value("${hawkbit.dmf.rabbitmq.fatal-exception-types:}") final List fatalExceptionTypes) { return new ConditionalRejectingErrorHandler(new RequeueExceptionStrategy(fatalExceptionStrategies, fatalExceptionTypes)); } diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/rsql/RsqlConfigHolder.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/rsql/RsqlConfigHolder.java index 4d078b07b..83fff6f7b 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/rsql/RsqlConfigHolder.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/rsql/RsqlConfigHolder.java @@ -29,7 +29,7 @@ public final class RsqlConfigHolder { * If RSQL comparison operators shall ignore the case. If ignore case is true * "x == ax" will match "x == aX" */ - @Value("${hawkbit.rsql.ignoreCase:true}") + @Value("${hawkbit.rsql.ignore-case:true}") private boolean ignoreCase; /** * Declares if the database is case-insensitive, by default assumes false. In case it is case-sensitive and, @@ -38,7 +38,7 @@ public final class RsqlConfigHolder { * If the database is declared as case-sensitive and ignoreCase is set to false the RSQL queries shall use strict * syntax - i.e. 'and' instead of 'AND' / 'aND'. Otherwise, the queries would be case-insensitive regarding operators. */ - @Value("${hawkbit.rsql.caseInsensitiveDB:false}") + @Value("${hawkbit.rsql.case-insensitive-db:false}") private boolean caseInsensitiveDB; private RsqlVisitorFactory rsqlVisitorFactory; @@ -52,7 +52,7 @@ public final class RsqlConfigHolder { * @deprecated in favour of G2 RSQL visitor. since 0.6.0 */ @Deprecated(forRemoval = true, since = "0.6.0") - @Value("${hawkbit.rsql.legacyRsqlVisitor:false}") + @Value("${hawkbit.rsql.legacy-rsql-visitor:false}") private boolean legacyRsqlVisitor; /** diff --git a/hawkbit-repository/hawkbit-repository-jpa-eclipselink/src/main/java/org/eclipse/hawkbit/repository/jpa/Statistics.java b/hawkbit-repository/hawkbit-repository-jpa-eclipselink/src/main/java/org/eclipse/hawkbit/repository/jpa/Statistics.java index fb59e6d6a..28f67b764 100644 --- a/hawkbit-repository/hawkbit-repository-jpa-eclipselink/src/main/java/org/eclipse/hawkbit/repository/jpa/Statistics.java +++ b/hawkbit-repository/hawkbit-repository-jpa-eclipselink/src/main/java/org/eclipse/hawkbit/repository/jpa/Statistics.java @@ -42,7 +42,7 @@ import org.springframework.scheduling.annotation.Scheduled; *
    *
  1. The Spring property spring.jpa.properties.eclipselink.profiler=PerformanceMonitor shall be set - enables Eclipselink statistics * collecting
  2. - *
  3. By default the periodic stdout log is disabled by setting hawkbit.jpa.statistics.dumpPeriodMS=9223372036854775807 (Long.MAX_VALUE) - + *
  4. By default the periodic stdout log is disabled by setting hawkbit.jpa.statistics.dump-period-ms=9223372036854775807 (Long.MAX_VALUE) - * i.e. effectively never. If log is required it should be set to the required period
  5. *
  6. The MeterRegistry shall be registered available - e.g. include org.springframework.boot:spring-boot-actuator-autoconfigure
  7. *
  8. (?) When using in test the metrics MAYBE shall be enabled with @AutoConfigureObservability(tracing = false)
  9. @@ -78,7 +78,7 @@ public class Statistics { @Autowired public void setEntityManagerFactory( final EntityManagerFactory entityManagerFactory, - @Value("${hawkbit.jpa.statistics.dumpPeriodMS:9223372036854775807}") final long dumpPeriod) { + @Value("${hawkbit.jpa.statistics.dump-period-ms:9223372036854775807}") final long dumpPeriod) { this.entityManagerFactory = entityManagerFactory; // set stdout log PerformanceMonitor. By default, it is Long.MAX_VALUE (9223372036854775807) which effectively disable logging getPerformanceMonitor(entityManagerFactory).setDumpTime(dumpPeriod); diff --git a/hawkbit-repository/hawkbit-repository-jpa-hibernate/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaConfiguration.java b/hawkbit-repository/hawkbit-repository-jpa-hibernate/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaConfiguration.java index 3a89a9337..002ecb293 100644 --- a/hawkbit-repository/hawkbit-repository-jpa-hibernate/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaConfiguration.java +++ b/hawkbit-repository/hawkbit-repository-jpa-hibernate/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaConfiguration.java @@ -40,7 +40,7 @@ public class JpaConfiguration { protected JpaConfiguration( final TenantAware.TenantResolver tenantResolver, - @Value("${hibernate.enable_lazy_load_no_trans:true}") final boolean enableLazyLoadNoTrans) { + @Value("${hibernate.enable-lazy-load-no-trans:true}") final boolean enableLazyLoadNoTrans) { tenantIdentifier = new TenantIdentifier(tenantResolver); this.enableLazyLoadNoTrans = enableLazyLoadNoTrans; }