Merge branch '3.2.x' into master
* 3.2.x: Exclude spring-build-src from maven publish Move spring-build-junit into spring-core Relocate MergePlugin package Develop a gradle plugin to add test dependencies Expose Gradle buildSrc for IDE support Fix [deprecation] compiler warnings Upgrade to xmlunit version 1.3 Improve 'build' folder ignores Fix regression in static setter method support Fix SpEL JavaBean compliance for setters Conflicts: spring-beans/src/test/java/org/springframework/beans/ExtendedBeanInfoTests.java
This commit is contained in:
@@ -42,8 +42,8 @@ import static org.springframework.beans.PropertyDescriptorUtils.*;
|
||||
|
||||
/**
|
||||
* Decorator for a standard {@link BeanInfo} object, e.g. as created by
|
||||
* {@link Introspector#getBeanInfo(Class)}, designed to discover and register non-void
|
||||
* returning setter methods. For example:
|
||||
* {@link Introspector#getBeanInfo(Class)}, designed to discover and register static
|
||||
* and/or non-void returning setter methods. For example:
|
||||
* <pre>{@code
|
||||
* public class Bean {
|
||||
* private Foo foo;
|
||||
@@ -103,17 +103,17 @@ class ExtendedBeanInfo implements BeanInfo {
|
||||
new SimpleNonIndexedPropertyDescriptor(pd));
|
||||
}
|
||||
|
||||
for (Method method : findNonVoidWriteMethods(delegate.getMethodDescriptors())) {
|
||||
handleNonVoidWriteMethod(method);
|
||||
for (Method method : findCandidateWriteMethods(delegate.getMethodDescriptors())) {
|
||||
handleCandidateWriteMethod(method);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private List<Method> findNonVoidWriteMethods(MethodDescriptor[] methodDescriptors) {
|
||||
private List<Method> findCandidateWriteMethods(MethodDescriptor[] methodDescriptors) {
|
||||
List<Method> matches = new ArrayList<Method>();
|
||||
for (MethodDescriptor methodDescriptor : methodDescriptors) {
|
||||
Method method = methodDescriptor.getMethod();
|
||||
if (isNonVoidWriteMethod(method)) {
|
||||
if (isCandidateWriteMethod(method)) {
|
||||
matches.add(method);
|
||||
}
|
||||
}
|
||||
@@ -128,20 +128,23 @@ class ExtendedBeanInfo implements BeanInfo {
|
||||
return matches;
|
||||
}
|
||||
|
||||
public static boolean isNonVoidWriteMethod(Method method) {
|
||||
public static boolean isCandidateWriteMethod(Method method) {
|
||||
String methodName = method.getName();
|
||||
Class<?>[] parameterTypes = method.getParameterTypes();
|
||||
int nParams = parameterTypes.length;
|
||||
if (methodName.length() > 3 && methodName.startsWith("set") &&
|
||||
Modifier.isPublic(method.getModifiers()) &&
|
||||
!void.class.isAssignableFrom(method.getReturnType()) &&
|
||||
(
|
||||
!void.class.isAssignableFrom(method.getReturnType()) ||
|
||||
Modifier.isStatic(method.getModifiers())
|
||||
) &&
|
||||
(nParams == 1 || (nParams == 2 && parameterTypes[0].equals(int.class)))) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void handleNonVoidWriteMethod(Method method) throws IntrospectionException {
|
||||
private void handleCandidateWriteMethod(Method method) throws IntrospectionException {
|
||||
int nParams = method.getParameterTypes().length;
|
||||
String propertyName = propertyNameFor(method);
|
||||
Class<?> propertyType = method.getParameterTypes()[nParams-1];
|
||||
|
||||
@@ -51,7 +51,7 @@ public class ExtendedBeanInfoFactory implements Ordered, BeanInfoFactory {
|
||||
*/
|
||||
private boolean supports(Class<?> beanClass) {
|
||||
for (Method method : beanClass.getMethods()) {
|
||||
if (ExtendedBeanInfo.isNonVoidWriteMethod(method)) {
|
||||
if (ExtendedBeanInfo.isCandidateWriteMethod(method)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -234,6 +234,8 @@ public class CustomEditorConfigurer implements BeanFactoryPostProcessor, BeanCla
|
||||
this.sharedEditor = sharedEditor;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public void registerCustomEditors(PropertyEditorRegistry registry) {
|
||||
if (!(registry instanceof PropertyEditorRegistrySupport)) {
|
||||
throw new IllegalArgumentException("Cannot registered shared editor " +
|
||||
|
||||
@@ -716,6 +716,7 @@ public class BeanDefinitionParserDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public int getAutowireMode(String attValue) {
|
||||
String att = attValue;
|
||||
if (DEFAULT_VALUE.equals(att)) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2007 the original author or authors.
|
||||
* Copyright 2002-2012 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.
|
||||
@@ -77,7 +77,7 @@ public class ResourceEntityResolver extends DelegatingEntityResolver {
|
||||
try {
|
||||
String decodedSystemId = URLDecoder.decode(systemId);
|
||||
String givenUrl = new URL(decodedSystemId).toString();
|
||||
String systemRootUrl = new File("").toURL().toString();
|
||||
String systemRootUrl = new File("").toURI().toURL().toString();
|
||||
// Try relative to resource base if currently in system root.
|
||||
if (givenUrl.startsWith(systemRootUrl)) {
|
||||
resourcePath = givenUrl.substring(systemRootUrl.length());
|
||||
|
||||
Reference in New Issue
Block a user