This is an automated email from the ASF dual-hosted git repository. xxyu pushed a commit to branch kylin5 in repository https://gitbox.apache.org/repos/asf/kylin.git
commit 97f3b8f27466e6a9e557572e24f1fe7108c5cc3b Author: fanfanAlice <41991994+fanfanal...@users.noreply.github.com> AuthorDate: Thu Apr 6 17:04:28 2023 +0800 KYLIN-5600 buf fix for ldap case insensitive (#30227) (#30261) * KYLIN-5600 buf fix for ldap case insensitive (#30227) * code smell for ut --- .../kylin/rest/config/KylinPropertySourceConfiguration.java | 13 +++++++++++++ .../org/apache/kylin/rest/KylinPrepareEnvListenerTest.java | 11 +++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/common-service/src/main/java/org/apache/kylin/rest/config/KylinPropertySourceConfiguration.java b/src/common-service/src/main/java/org/apache/kylin/rest/config/KylinPropertySourceConfiguration.java index 8f2da01468..cd4ee4134b 100644 --- a/src/common-service/src/main/java/org/apache/kylin/rest/config/KylinPropertySourceConfiguration.java +++ b/src/common-service/src/main/java/org/apache/kylin/rest/config/KylinPropertySourceConfiguration.java @@ -34,6 +34,8 @@ import lombok.extern.slf4j.Slf4j; @Slf4j public class KylinPropertySourceConfiguration implements EnvironmentPostProcessor, Ordered { + private static final String SYSTEM_PROPERTY_PREFIX = "kylin.system.property."; + @Override public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) { @@ -57,9 +59,20 @@ public class KylinPropertySourceConfiguration implements EnvironmentPostProcesso return properties.getProperty(name); } }; + + setSystemProperty(kylinConfig.exportToProperties()); propertySources.addAfter("systemProperties", source); } + public void setSystemProperty(Properties properties) { + for (String propertyName : properties.stringPropertyNames()) { + if (propertyName.startsWith(SYSTEM_PROPERTY_PREFIX)) { + String propertyValue = properties.getProperty(propertyName); + System.setProperty(propertyName.replaceFirst(SYSTEM_PROPERTY_PREFIX, ""), propertyValue); + } + } + } + @Override public int getOrder() { return ConfigDataEnvironmentPostProcessor.ORDER + 1020; diff --git a/src/server/src/test/java/org/apache/kylin/rest/KylinPrepareEnvListenerTest.java b/src/server/src/test/java/org/apache/kylin/rest/KylinPrepareEnvListenerTest.java index 1f736ac196..6c923420ce 100644 --- a/src/server/src/test/java/org/apache/kylin/rest/KylinPrepareEnvListenerTest.java +++ b/src/server/src/test/java/org/apache/kylin/rest/KylinPrepareEnvListenerTest.java @@ -19,6 +19,7 @@ package org.apache.kylin.rest; import java.util.List; import java.util.Map; +import java.util.Properties; import java.util.stream.Collectors; import org.apache.kylin.rest.config.KylinPropertySourceConfiguration; @@ -75,6 +76,16 @@ class KylinPrepareEnvListenerTest { } } + @Test + void testSystemProperty() { + KylinPropertySourceConfiguration configuration = new KylinPropertySourceConfiguration(); + Properties properties = new Properties(); + properties.setProperty("kylin.system.property.org.springframework.ldap.core.keyCaseFold", "none"); + configuration.setSystemProperty(properties); + String property = System.getProperty("org.springframework.ldap.core.keyCaseFold"); + Assertions.assertEquals("none", property); + } + @Configuration static class Config {