Skip to content

Commit

Permalink
Log excluded classes once
Browse files Browse the repository at this point in the history
Issue: #3717
Signed-off-by: yongjunhong <[email protected]>
  • Loading branch information
YongGoose committed Nov 30, 2024
1 parent 9daa88a commit f870747
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<Extension> serviceLoader,
Predicate<Class<? extends Extension>> filter) {
List<Class<? extends Extension>> excludeExtensions = new ArrayList<>();
serviceLoader.forEach(extension -> {
if (!filter.test(extension.getClass())) {
excludeExtensions.add(extension.getClass());
}
});

if (!excludeExtensions.isEmpty()) {
// @formatter:off
List<String> excludeExtensionNames = excludeExtensions
.stream()
.map(Class::getName)
.collect(Collectors.toList());
// @formatter:on
logger.config(() -> String.format("Excluded auto-detected extensions: %s", excludeExtensionNames));
}
}

/**
Expand Down

0 comments on commit f870747

Please sign in to comment.