Skip to content

Commit d9811cc

Browse files
authored
Add missing uses declarations in module descriptor (#3254)
All `ServiceLoader.load()` calls need a `uses` clause in the JPMS module descriptor. This PR: - Adds the missing `@ServiceConsumer` annotation to `CoreDefaultBundle`. - To simplify code review, it places `@ServiceConsumer` on each class that makes a `ServiceLoader.load` call and only those classes. Closes #3250
1 parent 5a881af commit d9811cc

File tree

7 files changed

+23
-2
lines changed

7 files changed

+23
-2
lines changed

log4j-conversant/src/test/java/org/apache/logging/log4j/conversant/test/DisruptorRecyclerFactoryProviderTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
import static org.assertj.core.api.Assertions.assertThat;
2020

21+
import aQute.bnd.annotation.Cardinality;
22+
import aQute.bnd.annotation.spi.ServiceConsumer;
2123
import java.util.Comparator;
2224
import java.util.List;
2325
import java.util.ServiceLoader;
@@ -27,6 +29,7 @@
2729
import org.apache.logging.log4j.util.ServiceLoaderUtil;
2830
import org.junit.jupiter.api.Test;
2931

32+
@ServiceConsumer(value = RecyclerFactoryProvider.class, resolution = Cardinality.MULTIPLE)
3033
class DisruptorRecyclerFactoryProviderTest {
3134

3235
@Test

log4j-core/src/main/java/org/apache/logging/log4j/core/impl/CoreDefaultBundle.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
*/
1717
package org.apache.logging.log4j.core.impl;
1818

19+
import aQute.bnd.annotation.Cardinality;
20+
import aQute.bnd.annotation.spi.ServiceConsumer;
1921
import java.util.Comparator;
2022
import java.util.List;
2123
import java.util.Map;
@@ -83,6 +85,7 @@
8385
* @see LogEventFactory
8486
* @see StrSubstitutor
8587
*/
88+
@ServiceConsumer(value = RecyclerFactoryProvider.class, cardinality = Cardinality.MULTIPLE)
8689
public final class CoreDefaultBundle {
8790

8891
@SingletonFactory

log4j-jctools/src/test/java/org/apache/logging/log4j/jctools/JCToolsRecyclerFactoryProviderTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
import static org.assertj.core.api.Assertions.assertThat;
2020

21+
import aQute.bnd.annotation.Cardinality;
22+
import aQute.bnd.annotation.spi.ServiceConsumer;
2123
import java.util.Comparator;
2224
import java.util.List;
2325
import java.util.ServiceLoader;
@@ -26,6 +28,7 @@
2628
import org.apache.logging.log4j.util.ServiceLoaderUtil;
2729
import org.junit.jupiter.api.Test;
2830

31+
@ServiceConsumer(value = RecyclerFactoryProvider.class, cardinality = Cardinality.MULTIPLE)
2932
class JCToolsRecyclerFactoryProviderTest {
3033

3134
@Test

log4j-kit/src/test/java/org/apache/logging/log4j/kit/recycler/internal/RecyclerFactoryTestUtil.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
*/
1717
package org.apache.logging.log4j.kit.recycler.internal;
1818

19+
import aQute.bnd.annotation.Cardinality;
20+
import aQute.bnd.annotation.spi.ServiceConsumer;
1921
import java.util.HashMap;
2022
import java.util.Map;
2123
import java.util.ServiceLoader;
@@ -27,6 +29,7 @@
2729
import org.apache.logging.log4j.util.ServiceLoaderUtil;
2830
import org.jspecify.annotations.Nullable;
2931

32+
@ServiceConsumer(value = RecyclerFactoryProvider.class, cardinality = Cardinality.MULTIPLE)
3033
final class RecyclerFactoryTestUtil {
3134

3235
private RecyclerFactoryTestUtil() {}

log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/di/DI.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
*/
1717
package org.apache.logging.log4j.plugins.di;
1818

19+
import aQute.bnd.annotation.Cardinality;
20+
import aQute.bnd.annotation.spi.ServiceConsumer;
1921
import java.lang.annotation.Annotation;
2022
import java.util.ArrayList;
2123
import java.util.Comparator;
@@ -36,6 +38,7 @@
3638
* {@link ConfigurableInstanceFactory} using bindings registered before and after standard
3739
* {@link ConfigurableInstanceFactoryPostProcessor} service provider classes are invoked.
3840
*/
41+
@ServiceConsumer(value = ConfigurableInstanceFactoryPostProcessor.class, cardinality = Cardinality.MULTIPLE)
3942
public final class DI {
4043
private DI() {
4144
throw new IllegalStateException("Utility class");

log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/di/spi/ConfigurableInstanceFactoryPostProcessor.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
*/
1717
package org.apache.logging.log4j.plugins.di.spi;
1818

19-
import aQute.bnd.annotation.spi.ServiceConsumer;
2019
import java.util.ServiceLoader;
2120
import org.apache.logging.log4j.plugins.Ordered;
2221
import org.apache.logging.log4j.plugins.di.ConfigurableInstanceFactory;
@@ -27,7 +26,6 @@
2726
* {@link Ordered} annotation on the class for overriding the order it will be invoked.
2827
*/
2928
@FunctionalInterface
30-
@ServiceConsumer(ConfigurableInstanceFactoryPostProcessor.class)
3129
public interface ConfigurableInstanceFactoryPostProcessor {
3230

3331
/**
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<entry xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xmlns="https://logging.apache.org/xml/ns"
4+
xsi:schemaLocation="https://logging.apache.org/xml/ns https://logging.apache.org/xml/ns/log4j-changelog-0.xsd"
5+
type="fixed">
6+
<issue id="3250" link="https://github.com/apache/logging-log4j2/issues/3250"/>
7+
<description format="asciidoc">Add missing `uses` declarations in module descriptor.</description>
8+
</entry>

0 commit comments

Comments
 (0)