[ 
https://issues.apache.org/jira/browse/LOG4J2-3427?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17526024#comment-17526024
 ] 

ASF subversion and git services commented on LOG4J2-3427:
---------------------------------------------------------

Commit 262828b193da7c63dd0b45509faaa0fb6e0bf16e in logging-log4j2's branch 
refs/heads/dependabot/maven/org.apache.felix-maven-bundle-plugin-5.1.4 from 
Piotr P. Karwasz
[ https://gitbox.apache.org/repos/asf?p=logging-log4j2.git;h=262828b193 ]

[LOG4J2-3427] Replace ServiceLoader calls with ServiceLoaderUtil

In an attempt to uniformize the calls to `ServiceLoader` and work around
its limitations, this replaces the `ServiceLoader#load` call sites with
`ServiceLoaderUtil#loadServices`.

`ServiceLoaderUtil` is also modified to return `Stream` instead of a
`List`, hence allowing for a more comfortable filtering and sorting of
the results.

> ServiceLoader usage in a servlet environment
> --------------------------------------------
>
>                 Key: LOG4J2-3427
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-3427
>             Project: Log4j 2
>          Issue Type: Improvement
>            Reporter: Piotr Karwasz
>            Assignee: Piotr Karwasz
>            Priority: Major
>             Fix For: 2.17.3
>
>
> It is fair to assume that a servlet container like Tomcat might contain 
> multiple copies of Log4j 2.x:
>  * a copy of Log4j 2.x can be used as logging provider for the entire server,
>  * each web application can contain another copy of Log4j 2.x
> One of the shortcomings of {{ServiceLoader}} is that it detects services in 
> both the web application's and server's classloader, but only those in the 
> web application are usable: those in the server's classloader can not extend 
> the service class contained in the application's classloader.
> A typical usage of {{ServiceLoader}} to find all instances of a certain 
> service can therefore end up in a {{{}ServiceConfigurationError{}}}. Those 
> are caught in Log4j 2.x, but usually end up in all services (also the viable 
> ones) being {*}discarded{*}.
> Hence a tool is necessary to only discard those services, which are contained 
> in the server's classloader.



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

Reply via email to