On Sun, Mar 6, 2022 at 6:23 PM Ralph Goers <[email protected]> wrote:
> I wrote a ServiceLoaderUti. It is in log4j-api in master. However, it has 
> shortcomings.
> ServliceLoader MUST be invoked in the appropriate JPMS module or it won’t find
> the correct declarations in module-info.java. So ServiceLoaderUtil requires a 
> lambda
> where the ServiceLoader call must be performed.

I might have sworn I looked for all references to `ServiceLoader` in
`master` too and I didn't find this one. :-(

Anyway I sent what I need in `release-2.x` as:

https://github.com/apache/logging-log4j2/pull/787

where I concentrated on two shortcomings of a simple `ServiceLoader#load`:

1. Resources found in the parent classloader of a web application
classloader can be useless (they extend a class in the parent
classloader, not the class requested),
2. The order in which services are found is random, so for
applications that require a single service, we need a way to override
the choice provided by `ServiceLoader`.

I'll refactor the PR to use the same method names and expand the
`master` version to provide the two features above.

Piotr

Reply via email to