diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml
new file mode 100644
index 0000000..ee312ff
--- /dev/null
+++ b/config/checkstyle/checkstyle.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 17dfdd9..cbbab2b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -131,6 +131,37 @@
+
+ org.apache.maven.plugins
+ maven-checkstyle-plugin
+ 3.1.1
+
+
+ com.puppycrawl.tools
+ checkstyle
+ 8.45.1
+
+
+ io.spring.javaformat
+ spring-javaformat-checkstyle
+ 0.0.31
+
+
+
+
+ checkstyle-validation
+ validate
+ true
+
+ config/checkstyle/checkstyle.xml
+ true
+
+
+ check
+
+
+
+
diff --git a/src/main/java/org/springframework/guice/annotation/EnableGuiceModules.java b/src/main/java/org/springframework/guice/annotation/EnableGuiceModules.java
index d5ed78b..1f30e13 100644
--- a/src/main/java/org/springframework/guice/annotation/EnableGuiceModules.java
+++ b/src/main/java/org/springframework/guice/annotation/EnableGuiceModules.java
@@ -1,14 +1,17 @@
/*
* Copyright 2013-2014 the original author or authors.
*
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
- * https://www.apache.org/licenses/LICENSE-2.0
+ * https://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.springframework.guice.annotation;
@@ -19,14 +22,14 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-import org.springframework.context.annotation.Import;
-
import com.google.inject.Module;
+import org.springframework.context.annotation.Import;
+
/**
* Enable spring beans that are themselves a Guice {@link Module} to contribute
* dependencies via the bindings in Guice.
- *
+ *
* @author Dave Syer
*
*/
diff --git a/src/main/java/org/springframework/guice/annotation/GuiceFactoryBean.java b/src/main/java/org/springframework/guice/annotation/GuiceFactoryBean.java
index 4cf1fc2..4474115 100644
--- a/src/main/java/org/springframework/guice/annotation/GuiceFactoryBean.java
+++ b/src/main/java/org/springframework/guice/annotation/GuiceFactoryBean.java
@@ -1,28 +1,33 @@
/*
* Copyright 2013-2014 the original author or authors.
*
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
- * https://www.apache.org/licenses/LICENSE-2.0
+ * https://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
+
package org.springframework.guice.annotation;
import javax.inject.Provider;
-import org.springframework.beans.factory.FactoryBean;
-import org.springframework.beans.factory.annotation.Autowired;
-
import com.google.inject.Injector;
import com.google.inject.Key;
+import org.springframework.beans.factory.FactoryBean;
+import org.springframework.beans.factory.annotation.Autowired;
+
/**
* Convenience class used to map a Guice {@link Provider} to a Spring bean.
*
+ * @param the bean type
* @author Dave Syer
*/
class GuiceFactoryBean implements FactoryBean {
@@ -36,7 +41,7 @@ class GuiceFactoryBean implements FactoryBean {
@Autowired
private Injector injector;
- public GuiceFactoryBean(Class beanType, Key key, boolean isSingleton) {
+ GuiceFactoryBean(Class beanType, Key key, boolean isSingleton) {
this.beanType = beanType;
this.key = key;
this.isSingleton = isSingleton;
@@ -44,12 +49,12 @@ class GuiceFactoryBean implements FactoryBean {
@Override
public T getObject() throws Exception {
- return (T) injector.getInstance(key);
+ return (T) this.injector.getInstance(this.key);
}
@Override
public Class> getObjectType() {
- return beanType;
+ return this.beanType;
}
@Override
@@ -57,4 +62,4 @@ class GuiceFactoryBean implements FactoryBean {
return this.isSingleton;
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/springframework/guice/annotation/GuiceModule.java b/src/main/java/org/springframework/guice/annotation/GuiceModule.java
index 3f718a9..2b8823e 100644
--- a/src/main/java/org/springframework/guice/annotation/GuiceModule.java
+++ b/src/main/java/org/springframework/guice/annotation/GuiceModule.java
@@ -1,14 +1,17 @@
/*
* Copyright 2013-2014 the original author or authors.
*
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
- * https://www.apache.org/licenses/LICENSE-2.0
+ * https://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.springframework.guice.annotation;
@@ -44,7 +47,7 @@ import org.springframework.guice.module.SpringModule;
public @interface GuiceModule {
/**
- * Specifies which types are eligible for inclusion in Guice module
+ * Specifies which types are eligible for inclusion in Guice module.
* @return filters for inclusion
*/
Filter[] includeFilters() default {};
@@ -56,7 +59,7 @@ public @interface GuiceModule {
Filter[] excludeFilters() default {};
/**
- * Specifies which names (by regex) are eligible for inclusion in Guice module
+ * Specifies which names (by regex) are eligible for inclusion in Guice module.
* @return regexes
*/
String[] includePatterns() default {};
@@ -70,7 +73,7 @@ public @interface GuiceModule {
/**
* Specifies which names (by simple wildcard match) are eligible for inclusion in
- * Guice module
+ * Guice module.
* @return bean names
*/
String[] includeNames() default {};
diff --git a/src/main/java/org/springframework/guice/annotation/GuiceModuleRegistrar.java b/src/main/java/org/springframework/guice/annotation/GuiceModuleRegistrar.java
index 5e0475c..b230153 100644
--- a/src/main/java/org/springframework/guice/annotation/GuiceModuleRegistrar.java
+++ b/src/main/java/org/springframework/guice/annotation/GuiceModuleRegistrar.java
@@ -74,66 +74,6 @@ class GuiceModuleRegistrar implements ImportBeanDefinitionRegistrar, ResourceLoa
registry.registerBeanDefinition(name, definition);
}
- protected static class GuiceModuleMetadataFactory implements FactoryBean {
-
- private Collection extends TypeFilter> includeFilters;
-
- private Collection extends TypeFilter> excludeFilters;
-
- private Collection includePatterns;
-
- private Collection excludePatterns;
-
- private Collection includeNames;
-
- private Collection excludeNames;
-
- public void setIncludeFilters(Collection extends TypeFilter> includeFilters) {
- this.includeFilters = includeFilters;
- }
-
- public void setExcludeFilters(Collection extends TypeFilter> excludeFilters) {
- this.excludeFilters = excludeFilters;
- }
-
- public void setIncludePatterns(Collection includePatterns) {
- this.includePatterns = includePatterns;
- }
-
- public void setExcludePatterns(Collection excludePatterns) {
- this.excludePatterns = excludePatterns;
- }
-
- public void setIncludeNames(Collection includeNames) {
- this.includeNames = includeNames;
- }
-
- public void setExcludeNames(Collection excludeNames) {
- this.excludeNames = excludeNames;
- }
-
- @Override
- public GuiceModuleMetadata getObject() throws Exception {
- return new GuiceModuleMetadata().include(includeFilters.toArray(new TypeFilter[includeFilters.size()]))
- .exclude(excludeFilters.toArray(new TypeFilter[excludeFilters.size()]))
- .include(includePatterns.toArray(new Pattern[includePatterns.size()]))
- .exclude(excludePatterns.toArray(new Pattern[excludePatterns.size()]))
- .include(includeNames.toArray(new String[includeNames.size()]))
- .exclude(excludeNames.toArray(new String[excludeNames.size()]));
- }
-
- @Override
- public Class> getObjectType() {
- return GuiceModuleMetadata.class;
- }
-
- @Override
- public boolean isSingleton() {
- return false;
- }
-
- }
-
private Set parsePatterns(AnnotationMetadata annotation, String attributeName) {
Set result = new HashSet();
AnnotationAttributes attributes = new AnnotationAttributes(
@@ -224,9 +164,70 @@ class GuiceModuleRegistrar implements ImportBeanDefinitionRegistrar, ResourceLoa
try {
return filterAttributes.getStringArray("pattern");
}
- catch (IllegalArgumentException o_O) {
+ catch (IllegalArgumentException ex) {
return new String[0];
}
}
+ protected static class GuiceModuleMetadataFactory implements FactoryBean {
+
+ private Collection extends TypeFilter> includeFilters;
+
+ private Collection extends TypeFilter> excludeFilters;
+
+ private Collection includePatterns;
+
+ private Collection excludePatterns;
+
+ private Collection includeNames;
+
+ private Collection excludeNames;
+
+ public void setIncludeFilters(Collection extends TypeFilter> includeFilters) {
+ this.includeFilters = includeFilters;
+ }
+
+ public void setExcludeFilters(Collection extends TypeFilter> excludeFilters) {
+ this.excludeFilters = excludeFilters;
+ }
+
+ public void setIncludePatterns(Collection includePatterns) {
+ this.includePatterns = includePatterns;
+ }
+
+ public void setExcludePatterns(Collection excludePatterns) {
+ this.excludePatterns = excludePatterns;
+ }
+
+ public void setIncludeNames(Collection includeNames) {
+ this.includeNames = includeNames;
+ }
+
+ public void setExcludeNames(Collection excludeNames) {
+ this.excludeNames = excludeNames;
+ }
+
+ @Override
+ public GuiceModuleMetadata getObject() throws Exception {
+ return new GuiceModuleMetadata()
+ .include(this.includeFilters.toArray(new TypeFilter[this.includeFilters.size()]))
+ .exclude(this.excludeFilters.toArray(new TypeFilter[this.excludeFilters.size()]))
+ .include(this.includePatterns.toArray(new Pattern[this.includePatterns.size()]))
+ .exclude(this.excludePatterns.toArray(new Pattern[this.excludePatterns.size()]))
+ .include(this.includeNames.toArray(new String[this.includeNames.size()]))
+ .exclude(this.excludeNames.toArray(new String[this.excludeNames.size()]));
+ }
+
+ @Override
+ public Class> getObjectType() {
+ return GuiceModuleMetadata.class;
+ }
+
+ @Override
+ public boolean isSingleton() {
+ return false;
+ }
+
+ }
+
}
diff --git a/src/main/java/org/springframework/guice/annotation/InjectorFactory.java b/src/main/java/org/springframework/guice/annotation/InjectorFactory.java
index 070952c..018ac8e 100644
--- a/src/main/java/org/springframework/guice/annotation/InjectorFactory.java
+++ b/src/main/java/org/springframework/guice/annotation/InjectorFactory.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2016-2022 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.springframework.guice.annotation;
import java.util.List;
@@ -8,9 +24,12 @@ import com.google.inject.Module;
/***
* Factory which allows for custom creation of the Guice Injector to be used in
* the @{@link EnableGuiceModules} feature.
+ *
+ * @author Dave Syer
+ * @author Taylor Wicksell
*/
public interface InjectorFactory {
- public Injector createInjector(List modules);
+ Injector createInjector(List modules);
}
diff --git a/src/main/java/org/springframework/guice/annotation/ModuleRegistryConfiguration.java b/src/main/java/org/springframework/guice/annotation/ModuleRegistryConfiguration.java
index f4cb8bd..c2ac897 100644
--- a/src/main/java/org/springframework/guice/annotation/ModuleRegistryConfiguration.java
+++ b/src/main/java/org/springframework/guice/annotation/ModuleRegistryConfiguration.java
@@ -1,18 +1,33 @@
/*
* Copyright 2013-2014 the original author or authors.
*
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
- * https://www.apache.org/licenses/LICENSE-2.0
+ * https://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.springframework.guice.annotation;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.stream.Collectors;
+
import com.google.inject.Binding;
import com.google.inject.Guice;
import com.google.inject.Injector;
@@ -21,9 +36,14 @@ 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.*;
+import com.google.inject.spi.Element;
+import com.google.inject.spi.ElementSource;
+import com.google.inject.spi.Elements;
+import com.google.inject.spi.LinkedKeyBinding;
+import com.google.inject.spi.PrivateElements;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.beans.factory.annotation.Qualifier;
@@ -47,18 +67,6 @@ import org.springframework.core.ResolvableType;
import org.springframework.core.annotation.Order;
import org.springframework.guice.module.SpringModule;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.stream.Collectors;
-
/**
* Configuration postprocessor that registers all the bindings in Guice modules as Spring
* beans.
@@ -95,18 +103,18 @@ class ModuleRegistryConfiguration implements BeanDefinitionRegistryPostProcessor
public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException {
List modules = new ArrayList<>(
((ConfigurableListableBeanFactory) registry).getBeansOfType(Module.class).values());
- modules.add(new SpringModule((ConfigurableListableBeanFactory) registry, enableJustInTimeBinding));
+ modules.add(new SpringModule((ConfigurableListableBeanFactory) registry, this.enableJustInTimeBinding));
Map, Binding>> bindings = new HashMap, Binding>>();
List elements = Elements.getElements(Stage.TOOL, modules);
- if (applicationContext.getEnvironment().getProperty(SPRING_GUICE_DEDUPE_BINDINGS_PROPERTY_NAME, Boolean.class,
- false)) {
+ if (this.applicationContext.getEnvironment().getProperty(SPRING_GUICE_DEDUPE_BINDINGS_PROPERTY_NAME,
+ Boolean.class, false)) {
elements = removeDuplicates(elements);
modules = Collections.singletonList(Elements.getModule(elements));
}
- if (applicationContext.getEnvironment().containsProperty("spring.guice.modules.exclude")) {
- String[] modulesToFilter = applicationContext.getEnvironment()
+ if (this.applicationContext.getEnvironment().containsProperty("spring.guice.modules.exclude")) {
+ String[] modulesToFilter = this.applicationContext.getEnvironment()
.getProperty("spring.guice.modules.exclude", "").split(",");
- elements = elements.stream().filter(e -> elementFilter(modulesToFilter, e)).collect(Collectors.toList());
+ elements = elements.stream().filter((e) -> elementFilter(modulesToFilter, e)).collect(Collectors.toList());
modules = Collections.singletonList(Elements.getModule(elements));
}
for (Element e : elements) {
@@ -124,7 +132,7 @@ class ModuleRegistryConfiguration implements BeanDefinitionRegistryPostProcessor
RootBeanDefinition beanDefinition = new RootBeanDefinition(GuiceInjectorInitializer.class);
ConstructorArgumentValues args = new ConstructorArgumentValues();
args.addIndexedArgumentValue(0, modules);
- args.addIndexedArgumentValue(1, applicationContext);
+ args.addIndexedArgumentValue(1, this.applicationContext);
beanDefinition.setConstructorArgumentValues(args);
registry.registerBeanDefinition("guiceInjectorInitializer", beanDefinition);
}
@@ -135,8 +143,8 @@ class ModuleRegistryConfiguration implements BeanDefinitionRegistryPostProcessor
}
private void mapBindings(Map, Binding>> bindings, BeanDefinitionRegistry registry) {
- Stage stage = applicationContext.getEnvironment().getProperty(SPRING_GUICE_STAGE_PROPERTY_NAME, Stage.class,
- Stage.PRODUCTION);
+ Stage stage = this.applicationContext.getEnvironment().getProperty(SPRING_GUICE_STAGE_PROPERTY_NAME,
+ Stage.class, Stage.PRODUCTION);
boolean ifLazyInit = stage.equals(Stage.DEVELOPMENT);
for (Entry, Binding>> entry : bindings.entrySet()) {
if (entry.getKey().getTypeLiteral().getRawType().equals(Injector.class) || SpringModule.SPRING_GUICE_SOURCE
@@ -211,11 +219,11 @@ class ModuleRegistryConfiguration implements BeanDefinitionRegistryPostProcessor
private boolean elementFilter(String[] modulesToFilter, Element element) {
try {
return Arrays.stream(modulesToFilter).noneMatch(
- ex -> Optional.of(element).map(Element::getSource).map(Object::toString).orElse("").contains(ex));
+ (ex) -> Optional.of(element).map(Element::getSource).map(Object::toString).orElse("").contains(ex));
}
- catch (Exception e) {
- logger.error(String.format("Unable fo filter element[%s] with filter [%s]", element,
- Arrays.toString(modulesToFilter)), e);
+ catch (Exception ex) {
+ this.logger.error(String.format("Unable fo filter element[%s] with filter [%s]", element,
+ Arrays.toString(modulesToFilter)), ex);
return false;
}
}
@@ -235,22 +243,25 @@ class ModuleRegistryConfiguration implements BeanDefinitionRegistryPostProcessor
/***
* Remove guice-sourced bindings in favor of spring-sourced bindings, when both exist
- * for a given binding key
+ * for a given binding key.
+ * @param elements list of elements to de-duplicate
+ * @return de-duplicated list of bindings
*/
protected List removeDuplicates(List elements) {
- List duplicateElements = elements.stream().filter(e -> e instanceof Binding).map(e -> (Binding>) e)
+ List duplicateElements = elements.stream().filter((e) -> e instanceof Binding)
+ .map((e) -> (Binding>) e)
.collect(Collectors.groupingBy(ModuleRegistryConfiguration::getLinkedKeyIfRequired)).entrySet().stream()
- .filter(e -> e.getValue().size() > 1 && e.getValue().stream()
- .anyMatch(binding -> binding.getSource() != null
+ .filter((e) -> e.getValue().size() > 1 && e.getValue().stream()
+ .anyMatch((binding) -> binding.getSource() != null
&& binding.getSource().toString().contains(SpringModule.SPRING_GUICE_SOURCE))) // find
// duplicates
- .flatMap(e -> e.getValue().stream())
- .filter(e -> e.getSource() != null
+ .flatMap((e) -> e.getValue().stream())
+ .filter((e) -> e.getSource() != null
&& !e.getSource().toString().contains(SpringModule.SPRING_GUICE_SOURCE))
.collect(Collectors.toList());
@SuppressWarnings("unlikely-arg-type")
- List dedupedElements = elements.stream().filter(e -> {
+ List dedupedElements = elements.stream().filter((e) -> {
if (e instanceof Binding) {
return !duplicateElements.contains(new SourceComparableBinding((Binding>) e));
}
@@ -274,11 +285,12 @@ class ModuleRegistryConfiguration implements BeanDefinitionRegistryPostProcessor
return binding.getKey();
}
+ @SuppressWarnings("checkstyle:EqualsHashCode")
private static class SourceComparableBinding {
private Binding> binding;
- public SourceComparableBinding(Binding> binding) {
+ SourceComparableBinding(Binding> binding) {
this.binding = binding;
}
@@ -287,10 +299,11 @@ class ModuleRegistryConfiguration implements BeanDefinitionRegistryPostProcessor
if (obj instanceof Binding) {
Binding> compareTo = (Binding>) obj;
if (compareTo.getSource() != null && this.binding != null) {
- return binding.equals(compareTo) && Objects.equals(binding.getSource(), compareTo.getSource());
+ return this.binding.equals(compareTo)
+ && Objects.equals(this.binding.getSource(), compareTo.getSource());
}
else {
- return Objects.equals(binding, compareTo);
+ return Objects.equals(this.binding, compareTo);
}
}
else {
@@ -300,85 +313,87 @@ class ModuleRegistryConfiguration implements BeanDefinitionRegistryPostProcessor
}
-}
+ /**
+ * Creates the Guice injector and registers it.
+ *
+ * The correct time to create the injector is after all Bean Post Processors were
+ * registered (after the registerBeanPostProcessors() phase), but before other beans
+ * get resolved. To achieve this, we create the injector when the first bean gets
+ * resolved - in its post-processing phase. However, this creates a possibility for a
+ * circular initialization error (i.e. if the first bean is also being dependant on by
+ * a Guice provided binding). To resolve this we publish an event that will be
+ * triggered in the registerListeners() phase, and create the injector then. Combining
+ * both initialization mechanisms (post-processor and the event publishing) ensures
+ * the injector will be created no later then the registerListeners() phase, but after
+ * the registerBeanPostProcessors() phase. For application contexts that override
+ * onRefresh() and create beans then (i.e. WebServer based application contexts) the
+ * post-processor initialization will kick-in and create the injector before.
+ */
+ static class GuiceInjectorInitializer
+ implements BeanPostProcessor, ApplicationListener {
-/**
- * Creates the Guice injector and registers it.
- *
- * The correct time to create the injector is after all Bean Post Processors were
- * registered (after the registerBeanPostProcessors() phase), but before other beans get
- * resolved. To achieve this, we create the injector when the first bean gets resolved -
- * in its post-processing phase. However, this creates a possibility for a circular
- * initialization error (i.e. if the first bean is also being dependant on by a Guice
- * provided binding). To resolve this we publish an event that will be triggered in the
- * registerListeners() phase, and create the injector then. Combining both initialization
- * mechanisms (post-processor and the event publishing) ensures the injector will be
- * created no later then the registerListeners() phase, but after the
- * registerBeanPostProcessors() phase. For application contexts that override onRefresh()
- * and create beans then (i.e. WebServer based application contexts) the post-processor
- * initialization will kick-in and create the injector before.
- */
-class GuiceInjectorInitializer
- implements BeanPostProcessor, ApplicationListener {
+ private final AtomicBoolean injectorCreated = new AtomicBoolean(false);
- private final AtomicBoolean injectorCreated = new AtomicBoolean(false);
+ private final List modules;
- private final List modules;
+ private final ConfigurableApplicationContext applicationContext;
- private final ConfigurableApplicationContext applicationContext;
+ GuiceInjectorInitializer(List modules, ConfigurableApplicationContext applicationContext) {
+ this.modules = modules;
+ this.applicationContext = applicationContext;
- public GuiceInjectorInitializer(List modules, ConfigurableApplicationContext applicationContext) {
- this.modules = modules;
- this.applicationContext = applicationContext;
-
- applicationContext.publishEvent(new CreateInjectorEvent());
- }
-
- @Override
- public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
- if (injectorCreated.compareAndSet(false, true)) {
- createInjector();
+ applicationContext.publishEvent(new CreateInjectorEvent());
}
- return bean;
- }
- @Override
- public void onApplicationEvent(CreateInjectorEvent event) {
- if (injectorCreated.compareAndSet(false, true)) {
- createInjector();
- }
- }
-
- private void createInjector() {
- Injector injector = null;
- try {
- Map beansOfType = applicationContext.getBeansOfType(InjectorFactory.class);
- if (beansOfType.size() > 1) {
- throw new ApplicationContextException("Found multiple beans of type " + InjectorFactory.class.getName()
- + " Please ensure that only one InjectorFactory bean is defined. InjectorFactory beans found: "
- + beansOfType.keySet());
+ @Override
+ public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
+ if (this.injectorCreated.compareAndSet(false, true)) {
+ createInjector();
}
- else if (beansOfType.size() == 1) {
- InjectorFactory injectorFactory = beansOfType.values().iterator().next();
- injector = injectorFactory.createInjector(modules);
+ return bean;
+ }
+
+ @Override
+ public void onApplicationEvent(CreateInjectorEvent event) {
+ if (this.injectorCreated.compareAndSet(false, true)) {
+ createInjector();
}
}
- catch (NoSuchBeanDefinitionException e) {
+ private void createInjector() {
+ Injector injector = null;
+ try {
+ Map beansOfType = this.applicationContext
+ .getBeansOfType(InjectorFactory.class);
+ if (beansOfType.size() > 1) {
+ throw new ApplicationContextException("Found multiple beans of type "
+ + InjectorFactory.class.getName()
+ + " Please ensure that only one InjectorFactory bean is defined. InjectorFactory beans found: "
+ + beansOfType.keySet());
+ }
+ else if (beansOfType.size() == 1) {
+ InjectorFactory injectorFactory = beansOfType.values().iterator().next();
+ injector = injectorFactory.createInjector(this.modules);
+ }
+ }
+ catch (NoSuchBeanDefinitionException ex) {
+
+ }
+ if (injector == null) {
+ injector = Guice.createInjector(this.modules);
+ }
+ this.applicationContext.getBeanFactory().registerResolvableDependency(Injector.class, injector);
+ this.applicationContext.getBeanFactory().registerSingleton("injector", injector);
}
- if (injector == null) {
- injector = Guice.createInjector(modules);
- }
- applicationContext.getBeanFactory().registerResolvableDependency(Injector.class, injector);
- applicationContext.getBeanFactory().registerSingleton("injector", injector);
- }
- static class CreateInjectorEvent extends ApplicationEvent {
+ static class CreateInjectorEvent extends ApplicationEvent {
- private static final long serialVersionUID = -6546970378679850504L;
+ private static final long serialVersionUID = -6546970378679850504L;
+
+ CreateInjectorEvent() {
+ super(serialVersionUID);
+ }
- public CreateInjectorEvent() {
- super(serialVersionUID);
}
}
diff --git a/src/main/java/org/springframework/guice/injector/SpringInjector.java b/src/main/java/org/springframework/guice/injector/SpringInjector.java
index 7b42542..e575a55 100644
--- a/src/main/java/org/springframework/guice/injector/SpringInjector.java
+++ b/src/main/java/org/springframework/guice/injector/SpringInjector.java
@@ -1,14 +1,17 @@
/*
* Copyright 2013-2014 the original author or authors.
*
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
- * https://www.apache.org/licenses/LICENSE-2.0
+ * https://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.springframework.guice.injector;
@@ -18,13 +21,6 @@ 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;
-import org.springframework.context.ApplicationContext;
-
import com.google.inject.Binding;
import com.google.inject.Injector;
import com.google.inject.Key;
@@ -34,8 +30,15 @@ import com.google.inject.Provider;
import com.google.inject.Scope;
import com.google.inject.TypeLiteral;
import com.google.inject.name.Named;
+import com.google.inject.spi.Element;
+import com.google.inject.spi.InjectionPoint;
import com.google.inject.spi.TypeConverterBinding;
+import org.springframework.beans.factory.annotation.BeanFactoryAnnotationUtils;
+import org.springframework.beans.factory.support.DefaultListableBeanFactory;
+import org.springframework.beans.factory.support.RootBeanDefinition;
+import org.springframework.context.ApplicationContext;
+
/**
* An {@link Injector} that wraps an {@link ApplicationContext}, and can be used to expose
* the Guice APIs over a Spring application. Does not use Guice at all internally: just
@@ -205,4 +208,4 @@ public class SpringInjector implements Injector {
return null;
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/springframework/guice/module/BeanFactoryProvider.java b/src/main/java/org/springframework/guice/module/BeanFactoryProvider.java
index 57f11d0..9a3c846 100644
--- a/src/main/java/org/springframework/guice/module/BeanFactoryProvider.java
+++ b/src/main/java/org/springframework/guice/module/BeanFactoryProvider.java
@@ -54,6 +54,7 @@ import org.springframework.core.OrderComparator;
* @author Dave Syer
*
*/
+@SuppressWarnings("checkstyle:FinalClass")
public class BeanFactoryProvider implements Provider, Closeable {
private Class>[] config;
@@ -112,16 +113,16 @@ public class BeanFactoryProvider implements Provider 0) {
- context.register(config);
+ if (this.config != null && this.config.length > 0) {
+ context.register(this.config);
}
- if (basePackages != null && basePackages.length > 0) {
- context.scan(basePackages);
+ if (this.basePackages != null && this.basePackages.length > 0) {
+ context.scan(this.basePackages);
}
context.partialRefresh();
- if (initializers != null && !initializers.isEmpty()) {
- OrderComparator.sort(initializers);
- for (ApplicationContextInitializer initializer : initializers) {
+ if (this.initializers != null && !this.initializers.isEmpty()) {
+ OrderComparator.sort(this.initializers);
+ for (ApplicationContextInitializer initializer : this.initializers) {
initializer.initialize(context);
}
}
@@ -129,7 +130,7 @@ public class BeanFactoryProvider implements Provider void onProvision(ProvisionInvocation provision) {
- if (!initialized.getAndSet(true) && !context.isActive()) {
- context.delayedRefresh();
+ if (!this.initialized.getAndSet(true) && !this.context.isActive()) {
+ this.context.delayedRefresh();
}
provision.provision();
}
diff --git a/src/main/java/org/springframework/guice/module/BindingTypeMatcher.java b/src/main/java/org/springframework/guice/module/BindingTypeMatcher.java
index 5d5cce6..b5543ac 100644
--- a/src/main/java/org/springframework/guice/module/BindingTypeMatcher.java
+++ b/src/main/java/org/springframework/guice/module/BindingTypeMatcher.java
@@ -19,6 +19,8 @@ package org.springframework.guice.module;
import java.lang.reflect.Type;
/**
+ * Utility to check whether a binding matches the given name and type.
+ *
* @author Dave Syer
*
*/
diff --git a/src/main/java/org/springframework/guice/module/GuiceAutowireCandidateResolver.java b/src/main/java/org/springframework/guice/module/GuiceAutowireCandidateResolver.java
index f72946d..bd64eff 100644
--- a/src/main/java/org/springframework/guice/module/GuiceAutowireCandidateResolver.java
+++ b/src/main/java/org/springframework/guice/module/GuiceAutowireCandidateResolver.java
@@ -13,13 +13,21 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package org.springframework.guice.module;
+import java.util.Collection;
+import java.util.Map;
+import java.util.Optional;
+
+import javax.inject.Provider;
+
import com.google.inject.BindingAnnotation;
import com.google.inject.Injector;
import com.google.inject.Key;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.springframework.aop.TargetSource;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
@@ -28,14 +36,10 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.context.annotation.ContextAnnotationAutowireCandidateResolver;
import org.springframework.util.Assert;
-import javax.inject.Provider;
-import java.util.Collection;
-import java.util.Map;
-import java.util.Optional;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicReference;
-
/**
+ * Extension of {@link ContextAnnotationAutowireCandidateResolver} providing support for
+ * exposing beans as just in time bindings.
+ *
* @author Dave Syer
* @author Taylor Wicksell
* @author Howard Yuan
@@ -47,7 +51,7 @@ class GuiceAutowireCandidateResolver extends ContextAnnotationAutowireCandidateR
private final Log logger = LogFactory.getLog(getClass());
- public GuiceAutowireCandidateResolver(Provider injectorProvider) {
+ GuiceAutowireCandidateResolver(Provider injectorProvider) {
this.injectorProvider = injectorProvider;
addQualifierType(BindingAnnotation.class);
}
@@ -73,10 +77,10 @@ class GuiceAutowireCandidateResolver extends ContextAnnotationAutowireCandidateR
try {
beanFactory.doResolveDependency(descriptor, beanName, null, null);
}
- catch (NoSuchBeanDefinitionException e) {
- if (e.getResolvableType() != null) {
- logger.info(String.format("Use just in time binding for %s in bean: %s",
- e.getResolvableType().getType().getTypeName(), beanName));
+ catch (NoSuchBeanDefinitionException ex) {
+ if (ex.getResolvableType() != null) {
+ this.logger.info(String.format("Use just in time binding for %s in bean: %s",
+ ex.getResolvableType().getType().getTypeName(), beanName));
}
return true;
}
@@ -104,16 +108,18 @@ class GuiceAutowireCandidateResolver extends ContextAnnotationAutowireCandidateR
@Override
public Object getTarget() {
Object target = null;
- if (isGuiceResolvable.isPresent() && isGuiceResolvable.get()) {
- target = injectorProvider.get().getInstance(Key.get(descriptor.getResolvableType().getType()));
+ if (this.isGuiceResolvable.isPresent() && this.isGuiceResolvable.get()) {
+ target = GuiceAutowireCandidateResolver.this.injectorProvider.get()
+ .getInstance(Key.get(descriptor.getResolvableType().getType()));
}
else {
try {
target = beanFactory.doResolveDependency(descriptor, beanName, null, null);
}
- catch (NoSuchBeanDefinitionException e) {
- target = injectorProvider.get().getInstance(Key.get(descriptor.getResolvableType().getType()));
- isGuiceResolvable = Optional.of(true);
+ catch (NoSuchBeanDefinitionException ex) {
+ target = GuiceAutowireCandidateResolver.this.injectorProvider.get()
+ .getInstance(Key.get(descriptor.getResolvableType().getType()));
+ this.isGuiceResolvable = Optional.of(true);
}
}
if (target == null) {
@@ -136,8 +142,8 @@ class GuiceAutowireCandidateResolver extends ContextAnnotationAutowireCandidateR
}
return pf.getProxy(beanFactory.getBeanClassLoader());
}
- catch (Exception e) {
- logger.debug("Failed to build lazy resolution proxy to Guice", e);
+ catch (Exception ex) {
+ this.logger.debug("Failed to build lazy resolution proxy to Guice", ex);
}
return null;
}
diff --git a/src/main/java/org/springframework/guice/module/GuiceModuleMetadata.java b/src/main/java/org/springframework/guice/module/GuiceModuleMetadata.java
index e4cd735..1a8d297 100644
--- a/src/main/java/org/springframework/guice/module/GuiceModuleMetadata.java
+++ b/src/main/java/org/springframework/guice/module/GuiceModuleMetadata.java
@@ -59,45 +59,45 @@ public class GuiceModuleMetadata implements BindingTypeMatcher {
private Set> infrastructureTypes = new HashSet>();
{
- infrastructureTypes.add(InitializingBean.class);
- infrastructureTypes.add(DisposableBean.class);
+ this.infrastructureTypes.add(InitializingBean.class);
+ this.infrastructureTypes.add(DisposableBean.class);
}
private MetadataReaderFactory metadataReaderFactory = new CachingMetadataReaderFactory();
public GuiceModuleMetadata include(String... filters) {
- includeNames = filters;
+ this.includeNames = filters;
return this;
}
public GuiceModuleMetadata exclude(String... filters) {
- excludeNames = filters;
+ this.excludeNames = filters;
return this;
}
public GuiceModuleMetadata include(Pattern... filters) {
- includePatterns = filters;
+ this.includePatterns = filters;
return this;
}
public GuiceModuleMetadata exclude(Pattern... filters) {
- excludePatterns = filters;
+ this.excludePatterns = filters;
return this;
}
public GuiceModuleMetadata include(TypeFilter... filters) {
- includeFilters = filters;
+ this.includeFilters = filters;
return this;
}
public GuiceModuleMetadata exclude(TypeFilter... filters) {
- excludeFilters = filters;
+ this.excludeFilters = filters;
return this;
}
@Override
public boolean matches(String name, Type type) {
- Type rawType = type instanceof ParameterizedType ? ((ParameterizedType) type).getRawType() : type;
+ Type rawType = (type instanceof ParameterizedType) ? ((ParameterizedType) type).getRawType() : type;
if (!matches(name) || !matches(rawType)) {
return false;
}
@@ -105,27 +105,27 @@ public class GuiceModuleMetadata implements BindingTypeMatcher {
}
private boolean matches(String name) {
- if (includePatterns != null) {
- for (Pattern filter : includePatterns) {
+ if (this.includePatterns != null) {
+ for (Pattern filter : this.includePatterns) {
if (!filter.matcher(name).matches()) {
return false;
}
}
}
- if (excludePatterns != null) {
- for (Pattern filter : excludePatterns) {
+ if (this.excludePatterns != null) {
+ for (Pattern filter : this.excludePatterns) {
if (filter.matcher(name).matches()) {
return false;
}
}
}
- if (includeNames != null && includeNames.length > 0) {
- if (!PatternMatchUtils.simpleMatch(includeNames, name)) {
+ if (this.includeNames != null && this.includeNames.length > 0) {
+ if (!PatternMatchUtils.simpleMatch(this.includeNames, name)) {
return false;
}
}
- if (excludeNames != null && excludeNames.length > 0) {
- if (PatternMatchUtils.simpleMatch(excludeNames, name)) {
+ if (this.excludeNames != null && this.excludeNames.length > 0) {
+ if (PatternMatchUtils.simpleMatch(this.excludeNames, name)) {
return false;
}
}
@@ -133,7 +133,7 @@ public class GuiceModuleMetadata implements BindingTypeMatcher {
}
private boolean matches(Type type) {
- if (infrastructureTypes.contains(type)) {
+ if (this.infrastructureTypes.contains(type)) {
return false;
}
@@ -141,30 +141,30 @@ public class GuiceModuleMetadata implements BindingTypeMatcher {
return false;
}
- if (includeFilters != null) {
+ if (this.includeFilters != null) {
try {
- MetadataReader reader = metadataReaderFactory.getMetadataReader(type.getTypeName());
- for (TypeFilter filter : includeFilters) {
- if (!filter.match(reader, metadataReaderFactory)) {
+ MetadataReader reader = this.metadataReaderFactory.getMetadataReader(type.getTypeName());
+ for (TypeFilter filter : this.includeFilters) {
+ if (!filter.match(reader, this.metadataReaderFactory)) {
return false;
}
}
}
- catch (IOException e) {
- throw new IllegalStateException("Cannot read metadata for class " + type, e);
+ catch (IOException ex) {
+ throw new IllegalStateException("Cannot read metadata for class " + type, ex);
}
}
- if (excludeFilters != null) {
+ if (this.excludeFilters != null) {
try {
- MetadataReader reader = metadataReaderFactory.getMetadataReader(type.getTypeName());
- for (TypeFilter filter : excludeFilters) {
- if (filter.match(reader, metadataReaderFactory)) {
+ MetadataReader reader = this.metadataReaderFactory.getMetadataReader(type.getTypeName());
+ for (TypeFilter filter : this.excludeFilters) {
+ if (filter.match(reader, this.metadataReaderFactory)) {
return false;
}
}
}
- catch (IOException e) {
- throw new IllegalStateException("Cannot read metadata for class " + type, e);
+ catch (IOException ex) {
+ throw new IllegalStateException("Cannot read metadata for class " + type, ex);
}
}
return true;
diff --git a/src/main/java/org/springframework/guice/module/SpringModule.java b/src/main/java/org/springframework/guice/module/SpringModule.java
index 27d5707..73881a4 100644
--- a/src/main/java/org/springframework/guice/module/SpringModule.java
+++ b/src/main/java/org/springframework/guice/module/SpringModule.java
@@ -1,14 +1,17 @@
/*
* Copyright 2013-2014 the original author or authors.
*
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
- * https://www.apache.org/licenses/LICENSE-2.0
+ * https://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.springframework.guice.module;
@@ -43,8 +46,8 @@ import com.google.inject.matcher.Matchers;
import com.google.inject.name.Named;
import com.google.inject.name.Names;
import com.google.inject.spi.ProvisionListener;
-
import com.google.inject.util.Types;
+
import org.springframework.beans.factory.BeanFactoryUtils;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition;
@@ -62,11 +65,16 @@ import org.springframework.util.ClassUtils;
import org.springframework.util.ReflectionUtils;
/**
+ * A Guice module that wraps a Spring {@link ApplicationContext}.
+ *
* @author Dave Syer
*
*/
public class SpringModule extends AbstractModule {
+ /**
+ * Identifier for bindings provided by this module.
+ */
public static final String SPRING_GUICE_SOURCE = "spring-guice";
private BindingTypeMatcher matcher = new GuiceModuleMetadata();
@@ -102,23 +110,24 @@ public class SpringModule extends AbstractModule {
@Override
public void configure() {
- if (beanFactory == null) {
- beanFactory = beanFactoryProvider.get();
+ if (this.beanFactory == null) {
+ this.beanFactory = this.beanFactoryProvider.get();
}
- if (beanFactory.getBeanNamesForType(ProvisionListener.class).length > 0) {
- binder().bindListener(Matchers.any(),
- beanFactory.getBeansOfType(ProvisionListener.class).values().toArray(new ProvisionListener[0]));
+ if (this.beanFactory.getBeanNamesForType(ProvisionListener.class).length > 0) {
+ binder().bindListener(Matchers.any(), this.beanFactory.getBeansOfType(ProvisionListener.class).values()
+ .toArray(new ProvisionListener[0]));
}
- if (enableJustInTimeBinding) {
- if (beanFactory instanceof DefaultListableBeanFactory) {
- ((DefaultListableBeanFactory) beanFactory).setAutowireCandidateResolver(
+ if (this.enableJustInTimeBinding) {
+ if (this.beanFactory instanceof DefaultListableBeanFactory) {
+ ((DefaultListableBeanFactory) this.beanFactory).setAutowireCandidateResolver(
new GuiceAutowireCandidateResolver(binder().getProvider(Injector.class)));
}
}
- if (beanFactory.getBeanNamesForType(GuiceModuleMetadata.class).length > 0) {
- this.matcher = new CompositeTypeMatcher(beanFactory.getBeansOfType(GuiceModuleMetadata.class).values());
+ if (this.beanFactory.getBeanNamesForType(GuiceModuleMetadata.class).length > 0) {
+ this.matcher = new CompositeTypeMatcher(
+ this.beanFactory.getBeansOfType(GuiceModuleMetadata.class).values());
}
- bind(beanFactory);
+ bind(this.beanFactory);
}
private void bind(ConfigurableListableBeanFactory beanFactory) {
@@ -205,9 +214,9 @@ public class SpringModule extends AbstractModule {
try {
Method factoryMethod = getFactoryMethod(beanFactory, definition);
return Arrays.stream(AnnotationUtils.getAnnotations(factoryMethod))
- .filter(a -> Annotations.isBindingAnnotation(a.annotationType())).findFirst();
+ .filter((a) -> Annotations.isBindingAnnotation(a.annotationType())).findFirst();
}
- catch (Exception e) {
+ catch (Exception ex) {
return Optional.empty();
}
}
@@ -307,7 +316,7 @@ public class SpringModule extends AbstractModule {
}
}
}
- Key> key = bindingAnnotation.map(a -> (Key