Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…mework into 5.1.x

* '5.1.x' of https://github.com/spring-projects/spring-framework: (26 commits)
  Add integration test for spring-projectsgh-24110
  Next Development Version
  Provide default codecs config callback to custom codecs
  Allow ExchangeStrategies customizations in WebClient
  Upgrade to AspectJ 1.9.5 and Checkstyle 8.27
  Revert "Allow ExchangeStrategies customizations in WebClient"
  Polishing
  Polishing
  Backport of recent ExtendedBeanInfo refinements from master
  Allow ExchangeStrategies customizations in WebClient
  Test status quo for @inherited annotations in AnnotationMetadata
  Test status quo for AnnotatedTypeMetadata.getAnnotationAttributes()
  Upgrade to Reactor Californium-SR14
  Remove println
  Fix NullPointerException in Jackson2SmileDecoder
  Upgrade to Tomcat 9.0.29, Jetty 9.4.24, RxJava 2.2.15
  Add missing verify() in Jackson2TokenizerTests
  Extra isReady-onWritePossible after last write
  Restore short-circuiting in equals implementation
  Upgrade to Jetty 9.4.23 and Woodstox 5.3
  ...
  • Loading branch information
gnehcgnaw committed Dec 4, 2019
2 parents 4b192a7 + f049a6e commit 2c36b7b
Show file tree
Hide file tree
Showing 52 changed files with 1,087 additions and 159 deletions.
14 changes: 7 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,24 @@ ext {
!it.name.equals("spring-build-src") && !it.name.equals("spring-framework-bom")
}

aspectjVersion = "1.9.4"
aspectjVersion = "1.9.5"
freemarkerVersion = "2.3.28"
groovyVersion = "2.5.8"
hsqldbVersion = "2.4.1"
jackson2Version = "2.9.9"
jettyVersion = "9.4.21.v20190926"
jettyVersion = "9.4.24.v20191120"
junit5Version = "5.3.2"
kotlinVersion = "1.2.71"
log4jVersion = "2.11.2"
nettyVersion = "4.1.43.Final"
reactorVersion = "Californium-SR13"
reactorVersion = "Californium-SR14"
rxjavaVersion = "1.3.8"
rxjavaAdapterVersion = "1.2.1"
rxjava2Version = "2.2.14"
rxjava2Version = "2.2.15"
slf4jVersion = "1.7.28" // spring-jcl + consistent 3rd party deps
tiles3Version = "3.0.8"
tomcatVersion = "9.0.27"
undertowVersion = "2.0.27.Final"
tomcatVersion = "9.0.29"
undertowVersion = "2.0.28.Final"

gradleScriptDir = "${rootProject.projectDir}/gradle"
withoutJclOverSlf4j = {
Expand Down Expand Up @@ -142,7 +142,7 @@ configure(allprojects) { project ->
}

checkstyle {
toolVersion = "8.26"
toolVersion = "8.27"
configDir = rootProject.file("src/checkstyle")
}

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=5.1.12.BUILD-SNAPSHOT
version=5.1.13.BUILD-SNAPSHOT
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 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.
Expand Down Expand Up @@ -41,8 +41,8 @@

/**
* Decorator for a standard {@link BeanInfo} object, e.g. as created by
* {@link Introspector#getBeanInfo(Class)}, designed to discover and register static
* and/or 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 class="code">
* public class Bean {
Expand Down Expand Up @@ -145,11 +145,10 @@ private List<Method> findCandidateWriteMethods(MethodDescriptor[] methodDescript

public static boolean isCandidateWriteMethod(Method method) {
String methodName = method.getName();
Class<?>[] parameterTypes = method.getParameterTypes();
int nParams = parameterTypes.length;
int nParams = method.getParameterCount();
return (methodName.length() > 3 && methodName.startsWith("set") && Modifier.isPublic(method.getModifiers()) &&
(!void.class.isAssignableFrom(method.getReturnType()) || Modifier.isStatic(method.getModifiers())) &&
(nParams == 1 || (nParams == 2 && int.class == parameterTypes[0])));
(nParams == 1 || (nParams == 2 && int.class == method.getParameterTypes()[0])));
}

private void handleCandidateWriteMethod(Method method) throws IntrospectionException {
Expand Down Expand Up @@ -209,7 +208,7 @@ private PropertyDescriptor findExistingPropertyDescriptor(String propertyName, C
}

private String propertyNameFor(Method method) {
return Introspector.decapitalize(method.getName().substring(3, method.getName().length()));
return Introspector.decapitalize(method.getName().substring(3));
}


Expand Down Expand Up @@ -488,7 +487,7 @@ public void setPropertyEditorClass(@Nullable Class<?> propertyEditorClass) {
}

/*
* See java.beans.IndexedPropertyDescriptor#equals(java.lang.Object)
* See java.beans.IndexedPropertyDescriptor#equals
*/
@Override
public boolean equals(Object other) {
Expand Down Expand Up @@ -535,11 +534,13 @@ static class PropertyDescriptorComparator implements Comparator<PropertyDescript
public int compare(PropertyDescriptor desc1, PropertyDescriptor desc2) {
String left = desc1.getName();
String right = desc2.getName();
byte[] leftBytes = left.getBytes();
byte[] rightBytes = right.getBytes();
for (int i = 0; i < left.length(); i++) {
if (right.length() == i) {
return 1;
}
int result = left.getBytes()[i] - right.getBytes()[i];
int result = leftBytes[i] - rightBytes[i];
if (result != 0) {
return result;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 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.
Expand Down Expand Up @@ -182,10 +182,12 @@ public GroovyBeanDefinitionReader(XmlBeanDefinitionReader xmlBeanDefinitionReade
}


@Override
public void setMetaClass(MetaClass metaClass) {
this.metaClass = metaClass;
}

@Override
public MetaClass getMetaClass() {
return this.metaClass;
}
Expand Down Expand Up @@ -216,6 +218,7 @@ public Binding getBinding() {
* @return the number of bean definitions found
* @throws BeanDefinitionStoreException in case of loading or parsing errors
*/
@Override
public int loadBeanDefinitions(Resource resource) throws BeanDefinitionStoreException {
return loadBeanDefinitions(new EncodedResource(resource));
}
Expand All @@ -240,10 +243,11 @@ public int loadBeanDefinitions(EncodedResource encodedResource) throws BeanDefin
logger.trace("Loading Groovy bean definitions from " + encodedResource);
}

Closure beans = new Closure(this) {
@SuppressWarnings("serial")
Closure<Object> beans = new Closure<Object>(this) {
@Override
public Object call(Object[] args) {
invokeBeanDefiningClosure((Closure) args[0]);
public Object call(Object... args) {
invokeBeanDefiningClosure((Closure<?>) args[0]);
return null;
}
};
Expand Down Expand Up @@ -285,7 +289,7 @@ public void setVariable(String name, Object value) {
* @param closure the block or closure
* @return this {@code GroovyBeanDefinitionReader} instance
*/
public GroovyBeanDefinitionReader beans(Closure closure) {
public GroovyBeanDefinitionReader beans(Closure<?> closure) {
return invokeBeanDefiningClosure(closure);
}

Expand All @@ -309,25 +313,22 @@ public GenericBeanDefinition bean(Class<?> type) {
public AbstractBeanDefinition bean(Class<?> type, Object...args) {
GroovyBeanDefinitionWrapper current = this.currentBeanDefinition;
try {
Closure callable = null;
Collection constructorArgs = null;
Closure<?> callable = null;
Collection<Object> constructorArgs = null;
if (!ObjectUtils.isEmpty(args)) {
int index = args.length;
Object lastArg = args[index - 1];
if (lastArg instanceof Closure) {
callable = (Closure) lastArg;
if (lastArg instanceof Closure<?>) {
callable = (Closure<?>) lastArg;
index--;
}
if (index > -1) {
constructorArgs = resolveConstructorArguments(args, 0, index);
}
constructorArgs = resolveConstructorArguments(args, 0, index);
}
this.currentBeanDefinition = new GroovyBeanDefinitionWrapper(null, type, constructorArgs);
if (callable != null) {
callable.call(this.currentBeanDefinition);
}
return this.currentBeanDefinition.getBeanDefinition();

}
finally {
this.currentBeanDefinition = current;
Expand Down Expand Up @@ -373,10 +374,11 @@ public void importBeans(String resourcePattern) throws IOException {
* This method overrides method invocation to create beans for each method name that
* takes a class argument.
*/
@Override
public Object invokeMethod(String name, Object arg) {
Object[] args = (Object[])arg;
if ("beans".equals(name) && args.length == 1 && args[0] instanceof Closure) {
return beans((Closure) args[0]);
return beans((Closure<?>) args[0]);
}
else if ("ref".equals(name)) {
String refName;
Expand Down Expand Up @@ -429,10 +431,10 @@ private boolean addDeferredProperty(String property, Object newValue) {
private void finalizeDeferredProperties() {
for (DeferredProperty dp : this.deferredProperties.values()) {
if (dp.value instanceof List) {
dp.value = manageListIfNecessary((List) dp.value);
dp.value = manageListIfNecessary((List<?>) dp.value);
}
else if (dp.value instanceof Map) {
dp.value = manageMapIfNecessary((Map) dp.value);
dp.value = manageMapIfNecessary((Map<?, ?>) dp.value);
}
dp.apply();
}
Expand All @@ -444,7 +446,7 @@ else if (dp.value instanceof Map) {
* @param callable the closure argument
* @return this {@code GroovyBeanDefinitionReader} instance
*/
protected GroovyBeanDefinitionReader invokeBeanDefiningClosure(Closure callable) {
protected GroovyBeanDefinitionReader invokeBeanDefiningClosure(Closure<?> callable) {
callable.setDelegate(this);
callable.call();
finalizeDeferredProperties();
Expand Down Expand Up @@ -483,9 +485,10 @@ else if (args[0] instanceof RuntimeBeanReference) {
else if (args[0] instanceof Map) {
// named constructor arguments
if (args.length > 1 && args[1] instanceof Class) {
List constructorArgs = resolveConstructorArguments(args, 2, hasClosureArgument ? args.length - 1 : args.length);
this.currentBeanDefinition = new GroovyBeanDefinitionWrapper(beanName, (Class)args[1], constructorArgs);
Map namedArgs = (Map)args[0];
List<Object> constructorArgs =
resolveConstructorArguments(args, 2, hasClosureArgument ? args.length - 1 : args.length);
this.currentBeanDefinition = new GroovyBeanDefinitionWrapper(beanName, (Class<?>) args[1], constructorArgs);
Map<?, ?> namedArgs = (Map<?, ?>) args[0];
for (Object o : namedArgs.keySet()) {
String propName = (String) o;
setProperty(propName, namedArgs.get(propName));
Expand All @@ -494,8 +497,8 @@ else if (args[0] instanceof Map) {
// factory method syntax
else {
this.currentBeanDefinition = new GroovyBeanDefinitionWrapper(beanName);
//First arg is the map containing factoryBean : factoryMethod
Map.Entry factoryBeanEntry = (Map.Entry) ((Map) args[0]).entrySet().iterator().next();
// First arg is the map containing factoryBean : factoryMethod
Map.Entry<?, ?> factoryBeanEntry = ((Map<?, ?>) args[0]).entrySet().iterator().next();
// If we have a closure body, that will be the last argument.
// In between are the constructor args
int constructorArgsTest = (hasClosureArgument ? 2 : 1);
Expand All @@ -519,12 +522,13 @@ else if (args[0] instanceof Closure) {
this.currentBeanDefinition.getBeanDefinition().setAbstract(true);
}
else {
List constructorArgs = resolveConstructorArguments(args, 0, hasClosureArgument ? args.length - 1 : args.length);
List<Object> constructorArgs =
resolveConstructorArguments(args, 0, hasClosureArgument ? args.length - 1 : args.length);
this.currentBeanDefinition = new GroovyBeanDefinitionWrapper(beanName, null, constructorArgs);
}

if (hasClosureArgument) {
Closure callable = (Closure) args[args.length - 1];
Closure<?> callable = (Closure<?>) args[args.length - 1];
callable.setDelegate(this);
callable.setResolveStrategy(Closure.DELEGATE_FIRST);
callable.call(this.currentBeanDefinition);
Expand All @@ -544,10 +548,10 @@ protected List<Object> resolveConstructorArguments(Object[] args, int start, int
constructorArgs[i] = constructorArgs[i].toString();
}
else if (constructorArgs[i] instanceof List) {
constructorArgs[i] = manageListIfNecessary((List) constructorArgs[i]);
constructorArgs[i] = manageListIfNecessary((List<?>) constructorArgs[i]);
}
else if (constructorArgs[i] instanceof Map){
constructorArgs[i] = manageMapIfNecessary((Map) constructorArgs[i]);
constructorArgs[i] = manageMapIfNecessary((Map<?, ?>) constructorArgs[i]);
}
}
return Arrays.asList(constructorArgs);
Expand Down Expand Up @@ -601,6 +605,7 @@ private Object manageListIfNecessary(List<?> list) {
* This method overrides property setting in the scope of the {@code GroovyBeanDefinitionReader}
* to set properties on the current bean definition.
*/
@Override
public void setProperty(String name, Object value) {
if (this.currentBeanDefinition != null) {
applyPropertyToBeanDefinition(name, value);
Expand All @@ -617,7 +622,7 @@ protected void applyPropertyToBeanDefinition(String name, Object value) {
else if (value instanceof Closure) {
GroovyBeanDefinitionWrapper current = this.currentBeanDefinition;
try {
Closure callable = (Closure) value;
Closure<?> callable = (Closure<?>) value;
Class<?> parameterType = callable.getParameterTypes()[0];
if (Object.class == parameterType) {
this.currentBeanDefinition = new GroovyBeanDefinitionWrapper("");
Expand Down Expand Up @@ -647,6 +652,7 @@ else if (value instanceof Closure) {
* properties from the {@code GroovyBeanDefinitionReader} itself
* </ul>
*/
@Override
public Object getProperty(String name) {
Binding binding = getBinding();
if (binding != null && binding.hasVariable(name)) {
Expand Down Expand Up @@ -690,8 +696,8 @@ else if (this.currentBeanDefinition != null) {
}

private GroovyDynamicElementReader createDynamicElementReader(String namespace) {
XmlReaderContext readerContext = this.groovyDslXmlBeanDefinitionReader.createReaderContext(new DescriptiveResource(
"Groovy"));
XmlReaderContext readerContext = this.groovyDslXmlBeanDefinitionReader.createReaderContext(
new DescriptiveResource("Groovy"));
BeanDefinitionParserDelegate delegate = new BeanDefinitionParserDelegate(readerContext);
boolean decorating = (this.currentBeanDefinition != null);
if (!decorating) {
Expand Down Expand Up @@ -749,10 +755,12 @@ public GroovyRuntimeBeanReference(String beanName, GroovyBeanDefinitionWrapper b
this.metaClass = InvokerHelper.getMetaClass(this);
}

@Override
public MetaClass getMetaClass() {
return this.metaClass;
}

@Override
public Object getProperty(String property) {
if (property.equals("beanName")) {
return getBeanName();
Expand All @@ -769,14 +777,17 @@ else if (this.beanDefinition != null) {
}
}

@Override
public Object invokeMethod(String name, Object args) {
return this.metaClass.invokeMethod(this, name, args);
}

@Override
public void setMetaClass(MetaClass metaClass) {
this.metaClass = metaClass;
}

@Override
public void setProperty(String property, Object newValue) {
if (!addDeferredProperty(property, newValue)) {
this.beanDefinition.getBeanDefinition().getPropertyValues().add(property, newValue);
Expand All @@ -785,7 +796,7 @@ public void setProperty(String property, Object newValue) {


/**
* Wraps a bean definition property an ensures that any RuntimeBeanReference
* Wraps a bean definition property and ensures that any RuntimeBeanReference
* additions to it are deferred for resolution later.
*/
private class GroovyPropertyValue extends GroovyObjectSupport {
Expand All @@ -799,18 +810,21 @@ public GroovyPropertyValue(String propertyName, Object propertyValue) {
this.propertyValue = propertyValue;
}

@SuppressWarnings("unused")
public void leftShift(Object value) {
InvokerHelper.invokeMethod(this.propertyValue, "leftShift", value);
updateDeferredProperties(value);
}

@SuppressWarnings("unused")
public boolean add(Object value) {
boolean retVal = (Boolean) InvokerHelper.invokeMethod(this.propertyValue, "add", value);
updateDeferredProperties(value);
return retVal;
}

public boolean addAll(Collection values) {
@SuppressWarnings("unused")
public boolean addAll(Collection<?> values) {
boolean retVal = (Boolean) InvokerHelper.invokeMethod(this.propertyValue, "addAll", values);
for (Object value : values) {
updateDeferredProperties(value);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 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.
Expand Down Expand Up @@ -196,7 +196,7 @@ else if (Boolean.TRUE.equals(newValue)) {
// constructorArgs
else if (CONSTRUCTOR_ARGS.equals(property) && newValue instanceof List) {
ConstructorArgumentValues cav = new ConstructorArgumentValues();
List args = (List) newValue;
List<?> args = (List<?>) newValue;
for (Object arg : args) {
cav.addGenericArgumentValue(arg);
}
Expand Down
Loading

0 comments on commit 2c36b7b

Please sign in to comment.