Skip to content

Commit

Permalink
fix plugin service configuration error (#620)
Browse files Browse the repository at this point in the history
  • Loading branch information
SentryMan authored Jun 25, 2024
1 parent fc43216 commit 3add880
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ static void registerModuleProvidedTypes(Set<String> providedTypes) {
return;
}
for (final var module : modules) {
try {
final var name = module.getClass().getTypeName();
final var provides = new ArrayList<String>();
APContext.logNote("Detected Module: " + name);
Expand All @@ -94,9 +93,6 @@ static void registerModuleProvidedTypes(Set<String> providedTypes) {
Arrays.stream(module.autoRequiresAspects()).map(Type::getTypeName).map(Util::wrapAspect).forEach(requires::add);

ProcessingContext.addModule(new ModuleData(name, provides, requires));
} catch (final ServiceConfigurationError expected) {
// ignore expected error reading the module that we are also writing
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ static List<AvajeModule> loadModules(ClassLoader classLoader) {
modules.add((AvajeModule) spi);
}
} catch (final ServiceConfigurationError expected) {
// ignore expected error reading the module that we are also writing
// ignore expected error reading the extensions not compiled yet
}
}
return modules;
Expand All @@ -32,11 +32,18 @@ static List<AvajeModule> loadModules(ClassLoader classLoader) {
static List<InjectPlugin> loadPlugins(ClassLoader classLoader) {
List<InjectPlugin> plugins = new ArrayList<>();
ServiceLoader.load(Plugin.class, classLoader).forEach(plugins::add);
ServiceLoader.load(InjectExtension.class, classLoader).forEach(spi -> {
if (spi instanceof InjectPlugin) {
plugins.add((InjectPlugin) spi);

final var iterator = ServiceLoader.load(InjectExtension.class, classLoader).iterator();
while (iterator.hasNext()) {
try {
final var spi = iterator.next();
if (spi instanceof InjectPlugin) {
plugins.add((InjectPlugin) spi);
}
} catch (final ServiceConfigurationError expected) {
// ignore expected error reading the extensions not compiled yet
}
});
}
return plugins;
}
}

0 comments on commit 3add880

Please sign in to comment.