This is an automated email from the ASF dual-hosted git repository. ggregory 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 949c911 Sort members. 949c911 is described below commit 949c911a87c598ac694966bddf203eae59f06e76 Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Wed Feb 10 23:03:13 2021 -0500 Sort members. --- .../java/org/apache/commons/lang3/SystemUtils.java | 70 +++++++++++----------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/src/main/java/org/apache/commons/lang3/SystemUtils.java b/src/main/java/org/apache/commons/lang3/SystemUtils.java index 60478b3..6c21321 100644 --- a/src/main/java/org/apache/commons/lang3/SystemUtils.java +++ b/src/main/java/org/apache/commons/lang3/SystemUtils.java @@ -1619,17 +1619,29 @@ public class SystemUtils { /** * <p> - * Gets the Java home directory as a {@code File}. + * Gets an environment variable, defaulting to {@code defaultValue} if the variable cannot be read. + * </p> + * <p> + * If a {@code SecurityException} is caught, the return value is {@code defaultValue} and a message is written to + * {@code System.err}. * </p> * - * @return a directory - * @throws SecurityException if a security manager exists and its {@code checkPropertyAccess} method doesn't allow - * access to the specified system property. - * @see System#getProperty(String) - * @since 2.1 + * @param name + * the environment variable name + * @param defaultValue + * the default value + * @return the environment variable value or {@code defaultValue} if a security problem occurs + * @since 3.8 */ - public static File getJavaHome() { - return new File(System.getProperty(JAVA_HOME_KEY)); + public static String getEnvironmentVariable(final String name, final String defaultValue) { + try { + 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 + "'."); + return defaultValue; + } } /** @@ -1649,6 +1661,21 @@ public class SystemUtils { /** * <p> + * Gets the Java home directory as a {@code File}. + * </p> + * + * @return a directory + * @throws SecurityException if a security manager exists and its {@code checkPropertyAccess} method doesn't allow + * access to the specified system property. + * @see System#getProperty(String) + * @since 2.1 + */ + public static File getJavaHome() { + return new File(System.getProperty(JAVA_HOME_KEY)); + } + + /** + * <p> * Gets the Java IO temporary directory as a {@code File}. * </p> * @@ -1721,33 +1748,6 @@ public class SystemUtils { /** * <p> - * Gets an environment variable, defaulting to {@code defaultValue} if the variable cannot be read. - * </p> - * <p> - * If a {@code SecurityException} is caught, the return value is {@code defaultValue} and a message is written to - * {@code System.err}. - * </p> - * - * @param name - * the environment variable name - * @param defaultValue - * the default value - * @return the environment variable value or {@code defaultValue} if a security problem occurs - * @since 3.8 - */ - public static String getEnvironmentVariable(final String name, final String defaultValue) { - try { - 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 + "'."); - return defaultValue; - } - } - - /** - * <p> * Gets the user directory as a {@code File}. * </p> *