Upgrade to Guice 4.2.3
This commit is contained in:
8
pom.xml
8
pom.xml
@@ -31,15 +31,9 @@
|
||||
<dependency>
|
||||
<groupId>com.google.inject</groupId>
|
||||
<artifactId>guice</artifactId>
|
||||
<version>4.1.0</version>
|
||||
<version>4.2.3</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.inject.extensions</groupId>
|
||||
<artifactId>guice-multibindings</artifactId>
|
||||
<version>4.1.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-test</artifactId>
|
||||
|
||||
@@ -21,10 +21,7 @@ import com.google.inject.Module;
|
||||
import com.google.inject.Scopes;
|
||||
import com.google.inject.Stage;
|
||||
import com.google.inject.name.Named;
|
||||
import com.google.inject.spi.Element;
|
||||
import com.google.inject.spi.ElementSource;
|
||||
import com.google.inject.spi.Elements;
|
||||
import com.google.inject.spi.PrivateElements;
|
||||
import com.google.inject.spi.*;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.BeansException;
|
||||
@@ -242,11 +239,10 @@ class ModuleRegistryConfiguration implements BeanDefinitionRegistryPostProcessor
|
||||
protected List<Element> removeDuplicates(List<Element> elements) {
|
||||
List<Element> duplicateElements = elements.stream()
|
||||
.filter(e -> e instanceof Binding).map(e -> (Binding<?>) e)
|
||||
.collect(Collectors.groupingBy(Binding::getKey)).entrySet().stream()
|
||||
.collect(Collectors.groupingBy(ModuleRegistryConfiguration::getLinkedKeyIfRequired)).entrySet().stream()
|
||||
.filter(e -> e.getValue().size() > 1 && e.getValue().stream().anyMatch(
|
||||
binding -> binding.getSource() != null && binding.getSource()
|
||||
.toString().contains(SpringModule.SPRING_GUICE_SOURCE))) // find
|
||||
// duplicates
|
||||
.toString().contains(SpringModule.SPRING_GUICE_SOURCE))) // find duplicates
|
||||
.flatMap(e -> e.getValue().stream())
|
||||
.filter(e -> e.getSource() != null && !e.getSource().toString()
|
||||
.contains(SpringModule.SPRING_GUICE_SOURCE))
|
||||
@@ -265,6 +261,19 @@ class ModuleRegistryConfiguration implements BeanDefinitionRegistryPostProcessor
|
||||
return dedupedElements;
|
||||
}
|
||||
|
||||
private static Key<?> getLinkedKeyIfRequired(Binding<?> binding) {
|
||||
if (binding == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (binding instanceof LinkedKeyBinding) {
|
||||
LinkedKeyBinding<?> linkedBinding = (LinkedKeyBinding<?>) binding;
|
||||
return linkedBinding.getLinkedKey();
|
||||
}
|
||||
|
||||
return binding.getKey();
|
||||
}
|
||||
|
||||
private static class SourceComparableBinding {
|
||||
private Binding<?> binding;
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.inject.spi.Element;
|
||||
import com.google.inject.spi.InjectionPoint;
|
||||
import org.springframework.beans.factory.annotation.BeanFactoryAnnotationUtils;
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
import org.springframework.beans.factory.support.RootBeanDefinition;
|
||||
@@ -190,4 +192,14 @@ public class SpringInjector implements Injector {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Element> getElements() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<TypeLiteral<?>, List<InjectionPoint>> getAllMembersInjectorInjectionPoints() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user