This is an automated email from the ASF dual-hosted git repository.
garydgregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-lang.git
The following commit(s) were added to refs/heads/master by this push:
new be54e6204 Match Javadoc to code in SystemProperties.getProperty() and
SystemUtils.getEnvironmentVariable() and update inline comments (f016).
be54e6204 is described below
commit be54e6204fb2e6f0d9fcbd76f4c3f568dcc5f65b
Author: Gary Gregory <[email protected]>
AuthorDate: Sat Sep 5 13:50:15 2026 -0400
Match Javadoc to code in SystemProperties.getProperty() and
SystemUtils.getEnvironmentVariable() and update inline comments (f016).
---
src/changes/changes.xml | 1 +
src/main/java/org/apache/commons/lang3/SystemProperties.java | 6 ++----
src/main/java/org/apache/commons/lang3/SystemUtils.java | 11 ++++++-----
3 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 9c072d2af..3059ea139 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -265,6 +265,7 @@ java.lang.NullPointerException: Cannot invoke
<action type="fix" dev="ggregory" due-to="Gary
Gregory">StrSubstitutor (deprecated) recursive expansion has a cycle check but
no fan-out, depth, or size bound (f013).</action>
<action type="fix" dev="ggregory" due-to="Gary
Gregory">DurationFormatUtils.formatPeriod walks the calendar one year per
iteration, Long.MAX_VALUE endMillis forces ~292 million Calendar round trips on
one thread (f014).</action>
<action type="fix" dev="ggregory" due-to="Gary
Gregory">JavaVersion.get() throws NumberFormatException where javadoc promises
null (f015).</action>
+ <action type="fix" dev="ggregory" due-to="Gary
Gregory">Match Javadoc to code in SystemProperties.getProperty() and
SystemUtils.getEnvironmentVariable() and update inline comments (f016).</action>
<!-- ADD -->
<action type="add" dev="ggregory" due-to="Gary
Gregory">Add JavaVersion.JAVA_27.</action>
<action type="add" dev="ggregory" due-to="Gary
Gregory">Add SystemUtils.IS_JAVA_27.</action>
diff --git a/src/main/java/org/apache/commons/lang3/SystemProperties.java
b/src/main/java/org/apache/commons/lang3/SystemProperties.java
index 3f1371487..e889f449f 100644
--- a/src/main/java/org/apache/commons/lang3/SystemProperties.java
+++ b/src/main/java/org/apache/commons/lang3/SystemProperties.java
@@ -3936,10 +3936,8 @@ static String getProperty(final String property, final
Supplier<String> defaultI
}
return StringUtils.getIfEmpty(System.getProperty(property),
defaultIfAbsent);
} catch (final SecurityException ignore) {
- // We are not allowed to look at this property.
- //
- // System.err.println("Caught a SecurityException reading the
system property '" + property
- // + "'; the SystemUtils property value will default to null.");
+ // We are not allowed to look at this property; fall through to
the default silently
+ // (the SecurityManager that raises this is terminally deprecated
as of Java 17 / JEP 411).
return defaultIfAbsent.get();
}
}
diff --git a/src/main/java/org/apache/commons/lang3/SystemUtils.java
b/src/main/java/org/apache/commons/lang3/SystemUtils.java
index 8df3f74ec..d46ecd97f 100644
--- a/src/main/java/org/apache/commons/lang3/SystemUtils.java
+++ b/src/main/java/org/apache/commons/lang3/SystemUtils.java
@@ -24,8 +24,8 @@
* Helpers for {@link System}.
*
* <p>
- * If a system property cannot be read due to security restrictions, the
corresponding field in this class will be set to {@code null} and a message
will be
- * written to {@code System.err}.
+ * If a system property cannot be read due to security restrictions, the
corresponding field in this class will be set to {@code null}; the
+ * {@link SecurityException} is swallowed silently, so a denied read is
indistinguishable from an absent property.
* </p>
* <p>
* #ThreadSafe#
@@ -2117,7 +2117,8 @@ public class SystemUtils {
* Gets an environment variable, defaulting to {@code defaultValue} if the
variable cannot be read.
*
* <p>
- * If a {@link SecurityException} is caught, the return value is {@code
defaultValue} and a message is written to {@code System.err}.
+ * If a {@link SecurityException} is caught, the return value is {@code
defaultValue}; the exception is swallowed silently, so a denied read is
+ * indistinguishable from an unset variable.
* </p>
*
* @param name The environment variable name.
@@ -2130,8 +2131,8 @@ public static String getEnvironmentVariable(final String
name, final String defa
final String value = System.getenv(name);
return value == null ? defaultValue : value;
} catch (final SecurityException ex) {
- // we are not allowed to look at this property
- // System.err.println("Caught a SecurityException reading the
environment variable '" + name + "'.");
+ // We are not allowed to look at this environment variable; fall
through to the default silently
+ // (the SecurityManager that raises this is terminally deprecated
as of Java 17 / JEP 411).
return defaultValue;
}
}