From bfc16a46e3c363d51c7f87a0295b3604ee3b9d8f Mon Sep 17 00:00:00 2001 From: Alex Bogdanovski Date: Sun, 3 Dec 2023 17:55:37 +0200 Subject: [PATCH] fixed bug where new config values don't get saved to application.conf file when set through System.setProperty(), closes Erudika/scoold#423 --- .../src/main/java/com/erudika/para/core/utils/Config.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/para-core/src/main/java/com/erudika/para/core/utils/Config.java b/para-core/src/main/java/com/erudika/para/core/utils/Config.java index b58b0692..c9e937cc 100644 --- a/para-core/src/main/java/com/erudika/para/core/utils/Config.java +++ b/para-core/src/main/java/com/erudika/para/core/utils/Config.java @@ -273,7 +273,10 @@ protected String getConfigParam(String key, String defaultValue) { public Object getConfigValue(String key, String defaultValue) { String valString = getConfigParam(key, defaultValue); try { - if (getConfig().hasPath(key) && getConfig().getValue(key).unwrapped() != null) { + // keep existing values from config file, but if any properties were set through + // System.setProperty() to a new value - skip this step and use the new values + if (getConfig().hasPath(key) && getConfig().getValue(key).unwrapped() != null && + StringUtils.equals(valString, getConfig().getAnyRef(key).toString())) { return getConfig().getValue(key).unwrapped(); } Documented doc = annotatedMethodsMap.get(key);