Skip to content

Commit

Permalink
Fixes bug telekom#421 by apply a package filter to avoid implementati…
Browse files Browse the repository at this point in the history
…ons of AbstractModule that does not fullfill package class will be instantiated.
  • Loading branch information
erickubenka committed Apr 25, 2024
1 parent 25de421 commit a054b8a
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import org.apache.logging.log4j.core.config.DefaultConfiguration;
import org.reflections.Reflections;
import org.reflections.util.ConfigurationBuilder;
import org.reflections.util.FilterBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -171,7 +172,10 @@ public static BuildInformation getBuildInformation() {
* overwrite custom implementations (of factories, providers etc.) but custom modules can do this to inject their own behaviour.
*/
private static Injector initIoc() {
Reflections reflections = new Reflections(new ConfigurationBuilder().forPackages(TesterraListener.DEFAULT_PACKAGES));
FilterBuilder filterBuilder = new FilterBuilder();
filterBuilder.includePackage(TesterraListener.DEFAULT_PACKAGES);

Reflections reflections = new Reflections(new ConfigurationBuilder().forPackages(TesterraListener.DEFAULT_PACKAGES).filterInputsBy(filterBuilder));
Set<Class<? extends AbstractModule>> classes = reflections.getSubTypesOf(AbstractModule.class);
Iterator<Class<? extends AbstractModule>> iterator = classes.iterator();
TreeMap<String, Module> sortedModules = new TreeMap<>(new ModuleComparator());
Expand Down

0 comments on commit a054b8a

Please sign in to comment.