Skip to content

Commit a89bfff

Browse files
committed
Merge branch '5.1.x'
2 parents 74d520f + 7dc92aa commit a89bfff

File tree

29 files changed

+98
-70
lines changed

29 files changed

+98
-70
lines changed

spring-beans/src/main/java/org/springframework/beans/PropertyValue.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -169,7 +169,7 @@ public synchronized boolean isConverted() {
169169
}
170170

171171
/**
172-
* Set the converted value of the constructor argument,
172+
* Set the converted value of this property value,
173173
* after processed type conversion.
174174
*/
175175
public synchronized void setConvertedValue(@Nullable Object value) {
@@ -178,7 +178,7 @@ public synchronized void setConvertedValue(@Nullable Object value) {
178178
}
179179

180180
/**
181-
* Return the converted value of the constructor argument,
181+
* Return the converted value of this property value,
182182
* after processed type conversion.
183183
*/
184184
@Nullable

spring-beans/src/main/java/org/springframework/beans/factory/InjectionPoint.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ public boolean equals(@Nullable Object other) {
180180
if (this == other) {
181181
return true;
182182
}
183-
if (getClass() != other.getClass()) {
183+
if (other == null || getClass() != other.getClass()) {
184184
return false;
185185
}
186186
InjectionPoint otherPoint = (InjectionPoint) other;

spring-beans/src/main/java/org/springframework/beans/factory/config/BeanDefinitionVisitor.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ protected void visitArray(Object[] arrayVal) {
234234
}
235235
}
236236

237-
@SuppressWarnings({"unchecked", "rawtypes"})
237+
@SuppressWarnings({"rawtypes", "unchecked"})
238238
protected void visitList(List listVal) {
239239
for (int i = 0; i < listVal.size(); i++) {
240240
Object elem = listVal.get(i);
@@ -245,7 +245,7 @@ protected void visitList(List listVal) {
245245
}
246246
}
247247

248-
@SuppressWarnings({"unchecked", "rawtypes"})
248+
@SuppressWarnings({"rawtypes", "unchecked"})
249249
protected void visitSet(Set setVal) {
250250
Set newContent = new LinkedHashSet();
251251
boolean entriesModified = false;
@@ -262,7 +262,7 @@ protected void visitSet(Set setVal) {
262262
}
263263
}
264264

265-
@SuppressWarnings({"unchecked", "rawtypes"})
265+
@SuppressWarnings({"rawtypes", "unchecked"})
266266
protected void visitMap(Map<?, ?> mapVal) {
267267
Map newContent = new LinkedHashMap();
268268
boolean entriesModified = false;

spring-beans/src/main/java/org/springframework/beans/factory/config/YamlMapFactoryBean.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -117,15 +117,15 @@ public Class<?> getObjectType() {
117117
* case of a shared singleton; else, on each {@link #getObject()} call.
118118
* <p>The default implementation returns the merged {@code Map} instance.
119119
* @return the object returned by this factory
120-
* @see #process(java.util.Map, MatchCallback)
120+
* @see #process(MatchCallback)
121121
*/
122122
protected Map<String, Object> createMap() {
123123
Map<String, Object> result = new LinkedHashMap<>();
124124
process((properties, map) -> merge(result, map));
125125
return result;
126126
}
127127

128-
@SuppressWarnings({"unchecked", "rawtypes"})
128+
@SuppressWarnings({"rawtypes", "unchecked"})
129129
private void merge(Map<String, Object> output, Map<String, Object> map) {
130130
map.forEach((key, value) -> {
131131
Object existing = output.get(key);

spring-beans/src/main/java/org/springframework/beans/factory/config/YamlPropertiesFactoryBean.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -128,7 +128,7 @@ public Class<?> getObjectType() {
128128
* <p>Invoked lazily the first time {@link #getObject()} is invoked in
129129
* case of a shared singleton; else, on each {@link #getObject()} call.
130130
* @return the object returned by this factory
131-
* @see #process(MatchCallback) ()
131+
* @see #process(MatchCallback)
132132
*/
133133
protected Properties createProperties() {
134134
Properties result = CollectionFactory.createStringAdaptingProperties();

spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1873,7 +1873,7 @@ protected void invokeCustomInitMethod(String beanName, final Object bean, RootBe
18731873

18741874
String initMethodName = mbd.getInitMethodName();
18751875
Assert.state(initMethodName != null, "No init method set");
1876-
final Method initMethod = (mbd.isNonPublicAccessAllowed() ?
1876+
Method initMethod = (mbd.isNonPublicAccessAllowed() ?
18771877
BeanUtils.findMethod(bean.getClass(), initMethodName) :
18781878
ClassUtils.getMethodIfAvailable(bean.getClass(), initMethodName));
18791879

@@ -1895,15 +1895,16 @@ protected void invokeCustomInitMethod(String beanName, final Object bean, RootBe
18951895
if (logger.isTraceEnabled()) {
18961896
logger.trace("Invoking init method '" + initMethodName + "' on bean with name '" + beanName + "'");
18971897
}
1898+
Method methodToInvoke = ClassUtils.getInterfaceMethodIfPossible(initMethod);
18981899

18991900
if (System.getSecurityManager() != null) {
19001901
AccessController.doPrivileged((PrivilegedAction<Object>) () -> {
1901-
ReflectionUtils.makeAccessible(initMethod);
1902+
ReflectionUtils.makeAccessible(methodToInvoke);
19021903
return null;
19031904
});
19041905
try {
19051906
AccessController.doPrivileged((PrivilegedExceptionAction<Object>) () ->
1906-
initMethod.invoke(bean), getAccessControlContext());
1907+
methodToInvoke.invoke(bean), getAccessControlContext());
19071908
}
19081909
catch (PrivilegedActionException pae) {
19091910
InvocationTargetException ex = (InvocationTargetException) pae.getException();

spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanDefinition.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
6565
public static final String SCOPE_DEFAULT = "";
6666

6767
/**
68-
* Constant that indicates no autowiring at all.
68+
* Constant that indicates no external autowiring at all.
6969
* @see #setAutowireMode
7070
*/
7171
public static final int AUTOWIRE_NO = AutowireCapableBeanFactory.AUTOWIRE_NO;

spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionBuilder.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -181,6 +181,8 @@ public BeanDefinitionBuilder setFactoryMethod(String factoryMethod) {
181181
/**
182182
* Set the name of a non-static factory method to use for this definition,
183183
* including the bean name of the factory instance to call the method on.
184+
* @param factoryMethod the name of the factory method
185+
* @param factoryBean the name of the bean to call the specified factory method on
184186
* @since 4.3.6
185187
*/
186188
public BeanDefinitionBuilder setFactoryMethodOnBean(String factoryMethod, String factoryBean) {

spring-beans/src/main/java/org/springframework/beans/factory/support/CglibSubclassingInstantiationStrategy.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -176,7 +176,7 @@ public RootBeanDefinition getBeanDefinition() {
176176

177177
@Override
178178
public boolean equals(@Nullable Object other) {
179-
return (getClass() == other.getClass() &&
179+
return (other != null && getClass() == other.getClass() &&
180180
this.beanDefinition.equals(((CglibIdentitySupport) other).beanDefinition));
181181
}
182182

spring-beans/src/main/java/org/springframework/beans/factory/support/DisposableBeanAdapter.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -112,15 +112,15 @@ public DisposableBeanAdapter(Object bean, String beanName, RootBeanDefinition be
112112
if (destroyMethodName != null && !(this.invokeDisposableBean && "destroy".equals(destroyMethodName)) &&
113113
!beanDefinition.isExternallyManagedDestroyMethod(destroyMethodName)) {
114114
this.destroyMethodName = destroyMethodName;
115-
this.destroyMethod = determineDestroyMethod(destroyMethodName);
116-
if (this.destroyMethod == null) {
115+
Method destroyMethod = determineDestroyMethod(destroyMethodName);
116+
if (destroyMethod == null) {
117117
if (beanDefinition.isEnforceDestroyMethod()) {
118118
throw new BeanDefinitionValidationException("Could not find a destroy method named '" +
119119
destroyMethodName + "' on bean with name '" + beanName + "'");
120120
}
121121
}
122122
else {
123-
Class<?>[] paramTypes = this.destroyMethod.getParameterTypes();
123+
Class<?>[] paramTypes = destroyMethod.getParameterTypes();
124124
if (paramTypes.length > 1) {
125125
throw new BeanDefinitionValidationException("Method '" + destroyMethodName + "' of bean '" +
126126
beanName + "' has more than one parameter - not supported as destroy method");
@@ -129,7 +129,9 @@ else if (paramTypes.length == 1 && boolean.class != paramTypes[0]) {
129129
throw new BeanDefinitionValidationException("Method '" + destroyMethodName + "' of bean '" +
130130
beanName + "' has a non-boolean parameter - not supported as destroy method");
131131
}
132+
destroyMethod = ClassUtils.getInterfaceMethodIfPossible(destroyMethod);
132133
}
134+
this.destroyMethod = destroyMethod;
133135
}
134136
this.beanPostProcessors = filterPostProcessors(postProcessors, bean);
135137
}
@@ -271,9 +273,9 @@ public void destroy() {
271273
invokeCustomDestroyMethod(this.destroyMethod);
272274
}
273275
else if (this.destroyMethodName != null) {
274-
Method methodToCall = determineDestroyMethod(this.destroyMethodName);
275-
if (methodToCall != null) {
276-
invokeCustomDestroyMethod(methodToCall);
276+
Method methodToInvoke = determineDestroyMethod(this.destroyMethodName);
277+
if (methodToInvoke != null) {
278+
invokeCustomDestroyMethod(ClassUtils.getInterfaceMethodIfPossible(methodToInvoke));
277279
}
278280
}
279281
}

0 commit comments

Comments
 (0)