Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion dubbo-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
<version>2.7.2-SNAPSHOT</version>
</parent>

<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-bom</artifactId>
<version>2.7.2-SNAPSHOT</version>
<packaging>pom</packaging>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public abstract class AnnotationInjectedBeanPostProcessor<A extends Annotation>
private final ConcurrentMap<String, AnnotationInjectedBeanPostProcessor.AnnotatedInjectionMetadata> injectionMetadataCache =
new ConcurrentHashMap<String, AnnotationInjectedBeanPostProcessor.AnnotatedInjectionMetadata>(CACHE_SIZE);

private final ConcurrentMap<String, Object> injectedObjectsCache = new ConcurrentHashMap<String, Object>(CACHE_SIZE);
private final ConcurrentMap<String, Object> injectedObjectsCache = new ConcurrentHashMap<>(CACHE_SIZE);

private ConfigurableListableBeanFactory beanFactory;

Expand All @@ -96,8 +96,9 @@ public AnnotationInjectedBeanPostProcessor() {
this.annotationType = resolveGenericType(getClass());
}

@SafeVarargs
private static <T> Collection<T> combine(Collection<? extends T>... elements) {
List<T> allElements = new ArrayList<T>();
List<T> allElements = new ArrayList<>();
for (Collection<? extends T> e : elements) {
allElements.addAll(e);
}
Expand Down Expand Up @@ -147,25 +148,22 @@ private List<AnnotationInjectedBeanPostProcessor.AnnotatedFieldElement> findFiel

final List<AnnotationInjectedBeanPostProcessor.AnnotatedFieldElement> elements = new LinkedList<AnnotationInjectedBeanPostProcessor.AnnotatedFieldElement>();

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;
Expand All @@ -182,34 +180,31 @@ private List<AnnotationInjectedBeanPostProcessor.AnnotatedMethodElement> findAnn

final List<AnnotationInjectedBeanPostProcessor.AnnotatedMethodElement> elements = new LinkedList<AnnotationInjectedBeanPostProcessor.AnnotatedMethodElement>();

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));
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ private void initConfigBeanCustomizers() {
Collection<DubboConfigBeanCustomizer> configBeanCustomizers =
beansOfTypeIncludingAncestors(applicationContext, DubboConfigBeanCustomizer.class).values();

this.configBeanCustomizers = new ArrayList<DubboConfigBeanCustomizer>(configBeanCustomizers);
this.configBeanCustomizers = new ArrayList<>(configBeanCustomizers);

AnnotationAwareOrderComparator.sort(this.configBeanCustomizers);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, ReferenceBean<?>> referenceBeanCache =
new ConcurrentHashMap<String, ReferenceBean<?>>(CACHE_SIZE);
new ConcurrentHashMap<>(CACHE_SIZE);

private final ConcurrentHashMap<String, ReferenceBeanInvocationHandler> localReferenceBeanInvocationHandlerCache =
new ConcurrentHashMap<String, ReferenceBeanInvocationHandler>(CACHE_SIZE);
new ConcurrentHashMap<>(CACHE_SIZE);

private final ConcurrentMap<InjectionMetadata.InjectedElement, ReferenceBean<?>> injectedFieldReferenceBeanCache =
new ConcurrentHashMap<InjectionMetadata.InjectedElement, ReferenceBean<?>>(CACHE_SIZE);
new ConcurrentHashMap<>(CACHE_SIZE);

private final ConcurrentMap<InjectionMetadata.InjectedElement, ReferenceBean<?>> injectedMethodReferenceBeanCache =
new ConcurrentHashMap<InjectionMetadata.InjectedElement, ReferenceBean<?>>(CACHE_SIZE);
new ConcurrentHashMap<>(CACHE_SIZE);

private ApplicationContext applicationContext;

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public ServiceAnnotationBeanPostProcessor(String... packagesToScan) {
}

public ServiceAnnotationBeanPostProcessor(Collection<String> packagesToScan) {
this(new LinkedHashSet<String>(packagesToScan));
this(new LinkedHashSet<>(packagesToScan));
}

public ServiceAnnotationBeanPostProcessor(Set<String> packagesToScan) {
Expand Down Expand Up @@ -218,7 +218,7 @@ private Set<BeanDefinitionHolder> findServiceBeanDefinitionHolders(

Set<BeanDefinition> beanDefinitions = scanner.findCandidateComponents(packageToScan);

Set<BeanDefinitionHolder> beanDefinitionHolders = new LinkedHashSet<BeanDefinitionHolder>(beanDefinitions.size());
Set<BeanDefinitionHolder> beanDefinitionHolders = new LinkedHashSet<>(beanDefinitions.size());

for (BeanDefinition beanDefinition : beanDefinitions) {

Expand Down Expand Up @@ -443,7 +443,7 @@ private AbstractBeanDefinition buildServiceBeanDefinition(Service service, Class

private ManagedList<RuntimeBeanReference> toRuntimeBeanReferences(String... beanNames) {

ManagedList<RuntimeBeanReference> runtimeBeanReferences = new ManagedList<RuntimeBeanReference>();
ManagedList<RuntimeBeanReference> runtimeBeanReferences = new ManagedList<>();

if (!ObjectUtils.isEmpty(beanNames)) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> props = new HashSet<String>();
Set<String> props = new HashSet<>();
ManagedMap parameters = null;
for (Method setter : beanClass.getMethods()) {
String name = setter.getName();
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public static Map<String, Object> getSubProperties(Iterable<PropertySource<?>> p
*/
public static Map<String, Object> getSubProperties(ConfigurableEnvironment environment, String prefix) {

Map<String, Object> subProperties = new LinkedHashMap<String, Object>();
Map<String, Object> subProperties = new LinkedHashMap<>();

MutablePropertySources propertySources = environment.getPropertySources();

Expand Down