Skip to content

Commit e0c3f55

Browse files
committed
Use guice
1 parent 10f2165 commit e0c3f55

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

maven-core/src/main/java/org/apache/maven/internal/impl/SisuDiBridgeModule.java

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@
2323

2424
import java.lang.annotation.Annotation;
2525
import java.util.ArrayList;
26+
import java.util.Collection;
2627
import java.util.Comparator;
2728
import java.util.HashSet;
2829
import java.util.List;
2930
import java.util.Map;
31+
import java.util.Optional;
3032
import java.util.Set;
3133
import java.util.function.Function;
3234
import java.util.function.Supplier;
@@ -150,24 +152,16 @@ public <Q> Supplier<Q> getCompiledBinding(Dependency<Q> dep) {
150152
com.google.inject.Injector injector = guiceInjectorProvider.get();
151153
if (key.getRawType() == List.class) {
152154
Key<Object> elementType = key.getTypeParameter(0);
153-
PlexusContainer container = injector.getInstance(PlexusContainer.class);
154155
return () -> {
155156
try {
156-
var plexus = container.lookupList(elementType.getRawType());
157+
// PlexusContainer container = injector.getInstance(PlexusContainer.class);
158+
// var plexus = container.lookupList(elementType.getRawType());
157159
var guice = injector.findBindingsByType(TypeLiteral.get(elementType.getRawType()));
158160
Set<Binding<Object>> di = getBindings(elementType);
159-
if (plexus.size() != guice.size()) {
160-
System.err.println("Suspicious difference: Plexus: " + plexus.size() + " Guice: "
161-
+ guice.size() + " for " + key);
162-
}
163-
if (di == null) {
164-
return (Q) plexus;
165-
}
166-
if (!plexus.isEmpty() && !di.isEmpty() && plexus.size() == di.size()) {
167-
System.err.println("Suspicious same size: Plexus: " + plexus.size() + " DI: " + guice.size()
168-
+ " for " + key);
169-
}
170-
List<Binding<Object>> bindings = new ArrayList<>(di);
161+
List<Binding<Object>> bindings = new ArrayList<>();
162+
Optional.ofNullable(di).stream()
163+
.flatMap(Collection::stream)
164+
.forEach(bindings::add);
171165
guice.stream()
172166
.filter(b -> !(b instanceof ProviderInstanceBinding<?> pib
173167
&& pib.getUserSuppliedProvider() instanceof BridgeProvider<?>))

0 commit comments

Comments
 (0)