This is an automated email from the ASF dual-hosted git repository.

sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-crypto.git


The following commit(s) were added to refs/heads/master by this push:
     new 9915f50  Move private method to class which uses it
9915f50 is described below

commit 9915f5068dafb9f1d06deb4ae94f119cd53497aa
Author: Sebb <[email protected]>
AuthorDate: Sat Jul 2 00:28:04 2022 +0100

    Move private method to class which uses it
    
    [skip ci]
---
 .../org/apache/commons/crypto/utils/Utils.java     | 73 +++++++++++-----------
 1 file changed, 36 insertions(+), 37 deletions(-)

diff --git a/src/main/java/org/apache/commons/crypto/utils/Utils.java 
b/src/main/java/org/apache/commons/crypto/utils/Utils.java
index fbc1a3f..90bcf48 100644
--- a/src/main/java/org/apache/commons/crypto/utils/Utils.java
+++ b/src/main/java/org/apache/commons/crypto/utils/Utils.java
@@ -38,14 +38,46 @@ public final class Utils {
 
     private static class DefaultPropertiesHolder {
         static final Properties DEFAULT_PROPERTIES = createDefaultProperties();
-     }
+
+        /**
+         * Loads system properties when configuration file of the name
+         * {@link #SYSTEM_PROPERTIES_FILE} is found.
+         *
+         * @return the default properties
+         */
+        private static Properties createDefaultProperties() {
+          // default to system
+          final Properties defaultedProps = new 
Properties(System.getProperties());
+          final URL url = 
Thread.currentThread().getContextClassLoader().getResource(SYSTEM_PROPERTIES_FILE);
+          if (url == null) {
+              // Fail early when the resource is not found which makes 
SpotBugs happy on Java 17.
+              return defaultedProps;
+          }
+          try {
+              final Properties fileProps = new Properties();
+              try (InputStream is = url.openStream()) {
+                  fileProps.load(is);
+              }
+              final Enumeration<?> names = fileProps.propertyNames();
+              while (names.hasMoreElements()) {
+                  final String name = (String) names.nextElement();
+                  // ensure System properties override ones in the file so one 
can override the file on the command line
+                  if (System.getProperty(name) == null) {
+                      defaultedProps.setProperty(name, 
fileProps.getProperty(name));
+                  }
+              }
+          } catch (final Exception ex) {
+              System.err.println("Could not load '" + SYSTEM_PROPERTIES_FILE + 
"' from classpath: " + ex.toString());
+          }
+          return defaultedProps;
+      }
+   }
 
     /**
      * The file name of configuration file.
-     * TODO is there any need for it to have the CONF_PREFIX?
+     *
      */
-    private static final String SYSTEM_PROPERTIES_FILE = Crypto.CONF_PREFIX
-            + "properties";
+    private static final String SYSTEM_PROPERTIES_FILE = Crypto.CONF_PREFIX + 
"properties";
 
     /**
      * The private constructor of {@link Utils}.
@@ -53,39 +85,6 @@ public final class Utils {
     private Utils() {
     }
 
-    /**
-     * Loads system properties when configuration file of the name
-     * {@link #SYSTEM_PROPERTIES_FILE} is found.
-     *
-     * @return the default properties
-     */
-    private static Properties createDefaultProperties() {
-        // default to system
-        final Properties defaultedProps = new 
Properties(System.getProperties());
-        final URL url = 
Thread.currentThread().getContextClassLoader().getResource(SYSTEM_PROPERTIES_FILE);
-        if (url == null) {
-            // Fail early when the resource is not found which makes SpotBugs 
happy on Java 17.
-            return defaultedProps;
-        }
-        try {
-            final Properties fileProps = new Properties();
-            try (InputStream is = url.openStream()) {
-                fileProps.load(is);
-            }
-            final Enumeration<?> names = fileProps.propertyNames();
-            while (names.hasMoreElements()) {
-                final String name = (String) names.nextElement();
-                // ensure System properties override ones in the file so one 
can override the file on the command line
-                if (System.getProperty(name) == null) {
-                    defaultedProps.setProperty(name, 
fileProps.getProperty(name));
-                }
-            }
-        } catch (final Exception ex) {
-            System.err.println("Could not load '" + SYSTEM_PROPERTIES_FILE + 
"' from classpath: " + ex.toString());
-        }
-        return defaultedProps;
-    }
-
     /**
      * Gets a properties instance that defaults to the System Properties
      * plus any other properties found in the file

Reply via email to