From f870747d934effc3ab0c05344fb5f751d999f64f Mon Sep 17 00:00:00 2001 From: yongjunhong Date: Sat, 30 Nov 2024 10:19:57 +0900 Subject: [PATCH] Log excluded classes once Issue: #3717 Signed-off-by: yongjunhong --- .../extension/MutableExtensionRegistry.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/extension/MutableExtensionRegistry.java b/junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/extension/MutableExtensionRegistry.java index 3bf250b48b8e..ebf8f308ad36 100644 --- a/junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/extension/MutableExtensionRegistry.java +++ b/junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/extension/MutableExtensionRegistry.java @@ -29,6 +29,7 @@ import java.util.Set; import java.util.function.Function; import java.util.function.Predicate; +import java.util.stream.Collectors; import java.util.stream.Stream; import org.apiguardian.api.API; @@ -103,6 +104,28 @@ private static void registerAutoDetectedExtensions(MutableExtensionRegistry exte ClassLoaderUtils.getDefaultClassLoader()); ServiceLoaderUtils.filter(serviceLoader, filter) // .forEach(extensionRegistry::registerAutoDetectedExtension); + + logExcludedExtensions(serviceLoader, filter); + } + + private static void logExcludedExtensions(ServiceLoader serviceLoader, + Predicate> filter) { + List> excludeExtensions = new ArrayList<>(); + serviceLoader.forEach(extension -> { + if (!filter.test(extension.getClass())) { + excludeExtensions.add(extension.getClass()); + } + }); + + if (!excludeExtensions.isEmpty()) { + // @formatter:off + List excludeExtensionNames = excludeExtensions + .stream() + .map(Class::getName) + .collect(Collectors.toList()); + // @formatter:on + logger.config(() -> String.format("Excluded auto-detected extensions: %s", excludeExtensionNames)); + } } /**