diff --git a/dubbo-bom/pom.xml b/dubbo-bom/pom.xml
index 3d28b4304652..058a198f204e 100644
--- a/dubbo-bom/pom.xml
+++ b/dubbo-bom/pom.xml
@@ -25,7 +25,6 @@
2.7.2-SNAPSHOT
- org.apache.dubbo
dubbo-bom
2.7.2-SNAPSHOT
pom
diff --git a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/beans/factory/annotation/AnnotationInjectedBeanPostProcessor.java b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/beans/factory/annotation/AnnotationInjectedBeanPostProcessor.java
index 30592a1a7cb9..53ff695da070 100644
--- a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/beans/factory/annotation/AnnotationInjectedBeanPostProcessor.java
+++ b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/beans/factory/annotation/AnnotationInjectedBeanPostProcessor.java
@@ -82,7 +82,7 @@ public abstract class AnnotationInjectedBeanPostProcessor
private final ConcurrentMap injectionMetadataCache =
new ConcurrentHashMap(CACHE_SIZE);
- private final ConcurrentMap injectedObjectsCache = new ConcurrentHashMap(CACHE_SIZE);
+ private final ConcurrentMap injectedObjectsCache = new ConcurrentHashMap<>(CACHE_SIZE);
private ConfigurableListableBeanFactory beanFactory;
@@ -96,8 +96,9 @@ public AnnotationInjectedBeanPostProcessor() {
this.annotationType = resolveGenericType(getClass());
}
+ @SafeVarargs
private static Collection combine(Collection extends T>... elements) {
- List allElements = new ArrayList();
+ List allElements = new ArrayList<>();
for (Collection extends T> e : elements) {
allElements.addAll(e);
}
@@ -147,25 +148,22 @@ private List findFiel
final List elements = new LinkedList();
- ReflectionUtils.doWithFields(beanClass, new ReflectionUtils.FieldCallback() {
- @Override
- public void doWith(Field field) throws IllegalArgumentException, IllegalAccessException {
+ ReflectionUtils.doWithFields(beanClass, field -> {
- A annotation = getAnnotation(field, getAnnotationType());
+ A annotation = getAnnotation(field, getAnnotationType());
- if (annotation != null) {
+ if (annotation != null) {
- if (Modifier.isStatic(field.getModifiers())) {
- if (logger.isWarnEnabled()) {
- logger.warn("@" + getAnnotationType().getName() + " is not supported on static fields: " + field);
- }
- return;
+ if (Modifier.isStatic(field.getModifiers())) {
+ if (logger.isWarnEnabled()) {
+ logger.warn("@" + getAnnotationType().getName() + " is not supported on static fields: " + field);
}
-
- elements.add(new AnnotationInjectedBeanPostProcessor.AnnotatedFieldElement(field, annotation));
+ return;
}
+ elements.add(new AnnotatedFieldElement(field, annotation));
}
+
});
return elements;
@@ -182,34 +180,31 @@ private List findAnn
final List elements = new LinkedList();
- ReflectionUtils.doWithMethods(beanClass, new ReflectionUtils.MethodCallback() {
- @Override
- public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException {
+ ReflectionUtils.doWithMethods(beanClass, method -> {
- Method bridgedMethod = findBridgedMethod(method);
+ Method bridgedMethod = findBridgedMethod(method);
- if (!isVisibilityBridgeMethodPair(method, bridgedMethod)) {
- return;
- }
+ if (!isVisibilityBridgeMethodPair(method, bridgedMethod)) {
+ return;
+ }
- A annotation = findAnnotation(bridgedMethod, getAnnotationType());
+ A annotation = findAnnotation(bridgedMethod, getAnnotationType());
- if (annotation != null && method.equals(ClassUtils.getMostSpecificMethod(method, beanClass))) {
- if (Modifier.isStatic(method.getModifiers())) {
- if (logger.isWarnEnabled()) {
- logger.warn("@" + getAnnotationType().getSimpleName() + " annotation is not supported on static methods: " + method);
- }
- return;
+ if (annotation != null && method.equals(ClassUtils.getMostSpecificMethod(method, beanClass))) {
+ if (Modifier.isStatic(method.getModifiers())) {
+ if (logger.isWarnEnabled()) {
+ logger.warn("@" + getAnnotationType().getSimpleName() + " annotation is not supported on static methods: " + method);
}
- if (method.getParameterTypes().length == 0) {
- if (logger.isWarnEnabled()) {
- logger.warn("@" + getAnnotationType().getSimpleName() + " annotation should only be used on methods with parameters: " +
- method);
- }
+ return;
+ }
+ if (method.getParameterTypes().length == 0) {
+ if (logger.isWarnEnabled()) {
+ logger.warn("@" + getAnnotationType().getSimpleName() + " annotation should only be used on methods with parameters: " +
+ method);
}
- PropertyDescriptor pd = BeanUtils.findPropertyForMethod(bridgedMethod, beanClass);
- elements.add(new AnnotationInjectedBeanPostProcessor.AnnotatedMethodElement(method, pd, annotation));
}
+ PropertyDescriptor pd = BeanUtils.findPropertyForMethod(bridgedMethod, beanClass);
+ elements.add(new AnnotatedMethodElement(method, pd, annotation));
}
});
diff --git a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/beans/factory/annotation/DubboConfigBindingBeanPostProcessor.java b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/beans/factory/annotation/DubboConfigBindingBeanPostProcessor.java
index 4430c9fcd4d2..ad2218fb2975 100644
--- a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/beans/factory/annotation/DubboConfigBindingBeanPostProcessor.java
+++ b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/beans/factory/annotation/DubboConfigBindingBeanPostProcessor.java
@@ -186,7 +186,7 @@ private void initConfigBeanCustomizers() {
Collection configBeanCustomizers =
beansOfTypeIncludingAncestors(applicationContext, DubboConfigBeanCustomizer.class).values();
- this.configBeanCustomizers = new ArrayList(configBeanCustomizers);
+ this.configBeanCustomizers = new ArrayList<>(configBeanCustomizers);
AnnotationAwareOrderComparator.sort(this.configBeanCustomizers);
}
diff --git a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/beans/factory/annotation/ReferenceAnnotationBeanPostProcessor.java b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/beans/factory/annotation/ReferenceAnnotationBeanPostProcessor.java
index 94bf9e800fed..7c3a6b9b87d6 100644
--- a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/beans/factory/annotation/ReferenceAnnotationBeanPostProcessor.java
+++ b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/beans/factory/annotation/ReferenceAnnotationBeanPostProcessor.java
@@ -61,16 +61,16 @@ public class ReferenceAnnotationBeanPostProcessor extends AnnotationInjectedBean
private static final int CACHE_SIZE = Integer.getInteger(BEAN_NAME + ".cache.size", 32);
private final ConcurrentMap> referenceBeanCache =
- new ConcurrentHashMap>(CACHE_SIZE);
+ new ConcurrentHashMap<>(CACHE_SIZE);
private final ConcurrentHashMap localReferenceBeanInvocationHandlerCache =
- new ConcurrentHashMap(CACHE_SIZE);
+ new ConcurrentHashMap<>(CACHE_SIZE);
private final ConcurrentMap> injectedFieldReferenceBeanCache =
- new ConcurrentHashMap>(CACHE_SIZE);
+ new ConcurrentHashMap<>(CACHE_SIZE);
private final ConcurrentMap> injectedMethodReferenceBeanCache =
- new ConcurrentHashMap>(CACHE_SIZE);
+ new ConcurrentHashMap<>(CACHE_SIZE);
private ApplicationContext applicationContext;
@@ -114,15 +114,12 @@ protected Object doGetInjectedBean(Reference reference, Object bean, String bean
cacheInjectedReferenceBean(referenceBean, injectedElement);
- Object proxy = buildProxy(referencedBeanName, referenceBean, injectedType);
-
- return proxy;
+ return buildProxy(referencedBeanName, referenceBean, injectedType);
}
private Object buildProxy(String referencedBeanName, ReferenceBean referenceBean, Class> injectedType) {
InvocationHandler handler = buildInvocationHandler(referencedBeanName, referenceBean);
- Object proxy = Proxy.newProxyInstance(getClassLoader(), new Class[]{injectedType}, handler);
- return proxy;
+ return Proxy.newProxyInstance(getClassLoader(), new Class[]{injectedType}, handler);
}
private InvocationHandler buildInvocationHandler(String referencedBeanName, ReferenceBean referenceBean) {
@@ -156,7 +153,7 @@ private ReferenceBeanInvocationHandler(ReferenceBean referenceBean) {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
- Object result = null;
+ Object result;
try {
if (bean == null) { // If the bean is not initialized, invoke init()
// issue: https://github.com/apache/incubator-dubbo/issues/3429
@@ -179,11 +176,9 @@ private void init() {
protected String buildInjectedObjectCacheKey(Reference reference, Object bean, String beanName,
Class> injectedType, InjectionMetadata.InjectedElement injectedElement) {
- String key = buildReferencedBeanName(reference, injectedType) +
+ return buildReferencedBeanName(reference, injectedType) +
"#source=" + (injectedElement.getMember()) +
"#attributes=" + AnnotationUtils.getAttributes(reference,getEnvironment(),true);
-
- return key;
}
private String buildReferencedBeanName(Reference reference, Class> injectedType) {
diff --git a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/beans/factory/annotation/ServiceAnnotationBeanPostProcessor.java b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/beans/factory/annotation/ServiceAnnotationBeanPostProcessor.java
index 532026de3d15..8a07feed05e9 100644
--- a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/beans/factory/annotation/ServiceAnnotationBeanPostProcessor.java
+++ b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/beans/factory/annotation/ServiceAnnotationBeanPostProcessor.java
@@ -88,7 +88,7 @@ public ServiceAnnotationBeanPostProcessor(String... packagesToScan) {
}
public ServiceAnnotationBeanPostProcessor(Collection packagesToScan) {
- this(new LinkedHashSet(packagesToScan));
+ this(new LinkedHashSet<>(packagesToScan));
}
public ServiceAnnotationBeanPostProcessor(Set packagesToScan) {
@@ -218,7 +218,7 @@ private Set findServiceBeanDefinitionHolders(
Set beanDefinitions = scanner.findCandidateComponents(packageToScan);
- Set beanDefinitionHolders = new LinkedHashSet(beanDefinitions.size());
+ Set beanDefinitionHolders = new LinkedHashSet<>(beanDefinitions.size());
for (BeanDefinition beanDefinition : beanDefinitions) {
@@ -443,7 +443,7 @@ private AbstractBeanDefinition buildServiceBeanDefinition(Service service, Class
private ManagedList toRuntimeBeanReferences(String... beanNames) {
- ManagedList runtimeBeanReferences = new ManagedList();
+ ManagedList runtimeBeanReferences = new ManagedList<>();
if (!ObjectUtils.isEmpty(beanNames)) {
diff --git a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/context/config/NamePropertyDefaultValueDubboConfigBeanCustomizer.java b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/context/config/NamePropertyDefaultValueDubboConfigBeanCustomizer.java
index fcd053d503c5..2f8c44621aad 100644
--- a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/context/config/NamePropertyDefaultValueDubboConfigBeanCustomizer.java
+++ b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/context/config/NamePropertyDefaultValueDubboConfigBeanCustomizer.java
@@ -67,7 +67,7 @@ public void customize(String beanName, AbstractConfig dubboConfigBean) {
}
Method setNameMethod = propertyDescriptor.getWriteMethod();
- if (setNameMethod != null && getNameMethod != null) { // "setName" and "getName" methods are present
+ if (setNameMethod != null) { // "setName" and "getName" methods are present
if (Arrays.equals(of(String.class), setNameMethod.getParameterTypes())) { // the param type is String
// set bean name to the value of the "name" property
ReflectionUtils.invokeMethod(setNameMethod, dubboConfigBean, beanName);
diff --git a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/schema/DubboBeanDefinitionParser.java b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/schema/DubboBeanDefinitionParser.java
index 9272b7f5a1b3..3c69294b5d00 100644
--- a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/schema/DubboBeanDefinitionParser.java
+++ b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/schema/DubboBeanDefinitionParser.java
@@ -125,7 +125,7 @@ private static BeanDefinition parse(Element element, ParserContext parserContext
} else if (ConsumerConfig.class.equals(beanClass)) {
parseNested(element, parserContext, ReferenceBean.class, false, "reference", "consumer", id, beanDefinition);
}
- Set props = new HashSet();
+ Set props = new HashSet<>();
ManagedMap parameters = null;
for (Method setter : beanClass.getMethods()) {
String name = setter.getName();
@@ -143,6 +143,7 @@ private static BeanDefinition parse(Element element, ParserContext parserContext
try {
getter = beanClass.getMethod("is" + name.substring(3), new Class>[0]);
} catch (NoSuchMethodException e2) {
+ logger.error("Method " + name + " parse error, cause: " + e2.getMessage(), e2);
}
}
if (getter == null
diff --git a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/util/PropertySourcesUtils.java b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/util/PropertySourcesUtils.java
index 8a070579b344..119a1f80db22 100644
--- a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/util/PropertySourcesUtils.java
+++ b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/util/PropertySourcesUtils.java
@@ -72,7 +72,7 @@ public static Map getSubProperties(Iterable> p
*/
public static Map getSubProperties(ConfigurableEnvironment environment, String prefix) {
- Map subProperties = new LinkedHashMap();
+ Map subProperties = new LinkedHashMap<>();
MutablePropertySources propertySources = environment.getPropertySources();