You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by GitBox <gi...@apache.org> on 2022/03/04 17:43:34 UTC

[GitHub] [logging-log4j2] ppkarwasz commented on a change in pull request #784: [LOG4J2-3423] Refactoring of URLConnection code

ppkarwasz commented on a change in pull request #784:
URL: https://github.com/apache/logging-log4j2/pull/784#discussion_r819780850



##########
File path: log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationFactory.java
##########
@@ -355,28 +348,9 @@ static String extractClassLoaderUriPath(final URI uri) {
      * @param loader The default ClassLoader to use.
      * @return The InputSource to use to read the configuration.
      */
+    @Deprecated
     protected ConfigurationSource getInputFromString(final String config, final ClassLoader loader) {
-        try {
-            final URL url = new URL(config);
-            URLConnection urlConnection = UrlConnectionFactory.createConnection(url);
-            File file = FileUtils.fileFromUri(url.toURI());
-            if (file != null) {
-                return new ConfigurationSource(urlConnection.getInputStream(), FileUtils.fileFromUri(url.toURI()));
-            }
-            return new ConfigurationSource(urlConnection.getInputStream(), url, urlConnection.getLastModified());
-        } catch (final Exception ex) {
-            final ConfigurationSource source = ConfigurationSource.fromResource(config, loader);
-            if (source == null) {
-                try {
-                    final File file = new File(config);
-                    return new ConfigurationSource(new FileInputStream(file), file);
-                } catch (final FileNotFoundException fnfe) {
-                    // Ignore the exception
-                    LOGGER.catching(Level.DEBUG, fnfe);
-                }
-            }
-            return source;
-        }
+        return ConfigurationSource.fromUri(NetUtils.toURI(config));

Review comment:
       This method has one call site and is called with the context classloader. Ignoring one parameter should be Ok.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org