[ 
https://issues.apache.org/jira/browse/LOG4J2-3047?focusedWorklogId=858037&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-858037
 ]

ASF GitHub Bot logged work on LOG4J2-3047:
------------------------------------------

                Author: ASF GitHub Bot
            Created on: 19/Apr/23 20:57
            Start Date: 19/Apr/23 20:57
    Worklog Time Spent: 10m 
      Work Description: jglick commented on code in PR #1164:
URL: https://github.com/apache/logging-log4j2/pull/1164#discussion_r1171847447


##########
log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationSource.java:
##########
@@ -367,7 +357,7 @@ private static ConfigurationSource 
getConfigurationSource(URL url) {
             try {
                 if (file != null) {
                     return new 
ConfigurationSource(urlConnection.getInputStream(), 
FileUtils.fileFromUri(url.toURI()));
-                } else if (JAR.equals(url.getProtocol())) {
+                } else if (urlConnection instanceof JarURLConnection) {

Review Comment:
   https://github.com/openjdk/jdk/pull/12871 should fix this.





Issue Time Tracking
-------------------

            Worklog Id:     (was: 858037)
    Remaining Estimate: 0h
            Time Spent: 10m

> Don't assume that jar:-URL yield JarURLConnections
> --------------------------------------------------
>
>                 Key: LOG4J2-3047
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-3047
>             Project: Log4j 2
>          Issue Type: Improvement
>          Components: Configuration
>    Affects Versions: 2.13.1
>            Reporter: Andreas Sewe
>            Priority: Major
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> Hi, I am currently investigating a bug in an *IntelliJ* plug-in which uses 
> Log4J2 internally for its logging needs and the uses an {{Appender}} to 
> reroute log messages to IntelliJ's debug log. This approach works fine.
> Unfortunately, with IntelliJ 2021.1, its developers have decided to swap the 
> default {{JarURLConnection}} for their own implementation, [for "performance 
> reasons"|https://youtrack.jetbrains.com/issue/IDEA-264777#focus=Comments-27-4777159.0-0],
>  as they claim. This leads to the unfortunate situation that a 
> straight-forward 
> {{jar:[file:/some/file.jar!some/package|file:///some/file.jar!some/package]}} 
> URL no longer yields a {{JarURLConnection}} but merely a plain 
> {{URLConnection}}.
> Now I am not 100%-sure whether the rule "{{jar:}}-URL yields 
> {{JarURLConnection}}" is part of the Java API; AFAICT, that is only 
> stipulated in a code example in the Javadoc of {{JarURLConnection}}, not on 
> {{URL}} or {{URLConnection}} themselves:
> {code:java}
>  * <p>Users should cast the generic URLConnection to a
>  * JarURLConnection when they know that the URL they created is a JAR
>  * URL, and they need JAR-specific functionality. For example:
>  *
>  * <pre>
>  * URL url = new URL("jar:file:/home/duke/duke.jar!/");
>  * JarURLConnection jarConnection = (JarURLConnection)url.openConnection();
>  * Manifest manifest = jarConnection.getManifest();
>  * </pre>
> {code}
> But regardless of who is to blame, I think Log4J's {{ResolverUtil}} can 
> safely drop that assumption:
> In {{ResolverUtil.findInPackage}}, {{extractPath}} has already extracted the 
> path to the JAR file in question, so the call to 
> {{loadImplementationsInJar(Test, String, URL}} could IMHO safely be replaced 
> by {{loadImplementationsInJar(Test, String, File)}}, thereby
>  # removing one of the {{else if}} cases in {{findInPackage}}
>  # removing the only use of {{loadImplementationsInJar(Test, String, URL)}}
>  # getting rid of the "{{jar:}}-URL yield {{JarURLConnection}}" assumption, 
> which is at least somewhat contested/implicit in the Java API.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to