|
23 | 23 |
|
24 | 24 | import java.lang.annotation.Annotation;
|
25 | 25 | import java.util.ArrayList;
|
| 26 | +import java.util.Collection; |
26 | 27 | import java.util.Comparator;
|
27 | 28 | import java.util.HashSet;
|
28 | 29 | import java.util.List;
|
29 | 30 | import java.util.Map;
|
| 31 | +import java.util.Optional; |
30 | 32 | import java.util.Set;
|
31 | 33 | import java.util.function.Function;
|
32 | 34 | import java.util.function.Supplier;
|
@@ -150,24 +152,16 @@ public <Q> Supplier<Q> getCompiledBinding(Dependency<Q> dep) {
|
150 | 152 | com.google.inject.Injector injector = guiceInjectorProvider.get();
|
151 | 153 | if (key.getRawType() == List.class) {
|
152 | 154 | Key<Object> elementType = key.getTypeParameter(0);
|
153 |
| - PlexusContainer container = injector.getInstance(PlexusContainer.class); |
154 | 155 | return () -> {
|
155 | 156 | try {
|
156 |
| - var plexus = container.lookupList(elementType.getRawType()); |
| 157 | + // PlexusContainer container = injector.getInstance(PlexusContainer.class); |
| 158 | + // var plexus = container.lookupList(elementType.getRawType()); |
157 | 159 | var guice = injector.findBindingsByType(TypeLiteral.get(elementType.getRawType()));
|
158 | 160 | 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); |
171 | 165 | guice.stream()
|
172 | 166 | .filter(b -> !(b instanceof ProviderInstanceBinding<?> pib
|
173 | 167 | && pib.getUserSuppliedProvider() instanceof BridgeProvider<?>))
|
|
0 commit comments