private static Properties createDefaultProperties()

in src/main/java/org/apache/commons/crypto/utils/Utils.java [55:80]


        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);
          }
          return defaultedProps;
      }