This is an automated email from the ASF dual-hosted git repository. reschke pushed a commit to branch OAK-12255 in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
commit 98c774cfa3ca2bdedebad6849eb30adfdbb3562b Author: Julian Reschke <[email protected]> AuthorDate: Fri Jul 3 12:13:11 2026 +0100 OAK-12255: SystemPropertySupplier logSuccessAs can throw IAE --- .../oak/commons/properties/SystemPropertySupplier.java | 10 +++++----- .../oak/commons/properties/SystemPropertySupplierTest.java | 10 ++++++++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/properties/SystemPropertySupplier.java b/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/properties/SystemPropertySupplier.java index 0521172842..3d6f81ae32 100644 --- a/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/properties/SystemPropertySupplier.java +++ b/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/properties/SystemPropertySupplier.java @@ -99,18 +99,18 @@ public class SystemPropertySupplier<T> implements Supplier<T> { /** * Specify logging level to use for "success" message (defaults to "INFO") */ - public SystemPropertySupplier<T> logSuccessAs(String successLogLevel) { - String newLevel; - switch (Objects.requireNonNull(successLogLevel)) { + public SystemPropertySupplier<T> logSuccessAs(String desiredLogLevel) { + String newLevel = this.successLogLevel; + switch (Objects.requireNonNull(desiredLogLevel)) { case "DEBUG": case "ERROR": case "INFO": case "TRACE": case "WARN": - newLevel = successLogLevel; + newLevel = desiredLogLevel; break; default: - throw new IllegalArgumentException("unsupported log level: " + successLogLevel); + LOG.error("for {}: invalid log level '{}', keeping previous value of '{}'.", propName, desiredLogLevel, successLogLevel); } this.successLogLevel = newLevel; return this; diff --git a/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/properties/SystemPropertySupplierTest.java b/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/properties/SystemPropertySupplierTest.java index 69ed32d9d4..9e0175d5fa 100755 --- a/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/properties/SystemPropertySupplierTest.java +++ b/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/properties/SystemPropertySupplierTest.java @@ -137,4 +137,14 @@ public class SystemPropertySupplierTest { } catch (IllegalArgumentException expected) { } } + + @Test + public void testUnsupportedLogLevel() { + // should not throw: + int x = SystemPropertySupplier. + create("foo", 0). + usingSystemPropertyReader(y -> "2"). + logSuccessAs("AWESOME").get(); + assertEquals(2 , x); + } }
