From 16b2e12797a3720f5b075175352d1689bcdb1d4e Mon Sep 17 00:00:00 2001 From: automation Date: Sun, 14 Sep 2025 00:23:28 +0100 Subject: [PATCH] fix: make Configuration load via TCCL and honor system properties; ensures app.properties is found in fat jars --- .../phoenixd/common/rest/util/Configuration.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/phoenixd-base/src/main/java/xyz/tcheeric/phoenixd/common/rest/util/Configuration.java b/phoenixd-base/src/main/java/xyz/tcheeric/phoenixd/common/rest/util/Configuration.java index ff4b2ff..a860638 100644 --- a/phoenixd-base/src/main/java/xyz/tcheeric/phoenixd/common/rest/util/Configuration.java +++ b/phoenixd-base/src/main/java/xyz/tcheeric/phoenixd/common/rest/util/Configuration.java @@ -30,9 +30,9 @@ private String envValue(@NonNull String key) { private String resolve(@NonNull String key) { String env = envValue(key); - if (env != null) { - return env; - } + if (env != null) return env; + String sys = System.getProperty(prefix + "." + key); + if (sys != null && !sys.isEmpty()) return sys; return properties.getProperty(prefix + "." + key); } @@ -51,7 +51,13 @@ public Configuration(@NonNull String prefix, @NonNull URL fileUrl) { public Configuration(@NonNull String prefix) { this.prefix = prefix; this.properties = new Properties(); - URL resource = getClass().getResource("/app.properties"); + // Try thread context classloader first (works well in app servers and Spring Boot) + ClassLoader tccl = Thread.currentThread().getContextClassLoader(); + URL resource = (tccl != null) ? tccl.getResource("app.properties") : null; + if (resource == null) { + // Fallback to this class' loader + resource = getClass().getResource("/app.properties"); + } if (resource != null) { try (InputStream in = resource.openStream()) { if (in != null) {