mirror of
https://github.com/spring-projects/spring-framework
synced 2026-06-08 17:33:33 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d51d8aeaf6 |
+1
-1
@@ -72,7 +72,7 @@ to start a discussion first or have already created an issue, once a pull reques
|
||||
created, we will close the issue as superseded by the pull request, and the discussion
|
||||
about the issue will continue under the pull request.
|
||||
|
||||
1. Always check out the `main` branch and submit pull requests against it
|
||||
1. Always check out the `master` branch and submit pull requests against it
|
||||
(for target version see [settings.gradle](settings.gradle)).
|
||||
Backports to prior versions will be considered on a case-by-case basis and reflected as
|
||||
the fix version in the issue tracker.
|
||||
|
||||
+22
-22
@@ -1,7 +1,7 @@
|
||||
plugins {
|
||||
id 'io.spring.dependency-management' version '1.0.9.RELEASE' apply false
|
||||
id 'io.spring.nohttp' version '0.0.5.RELEASE'
|
||||
id 'org.jetbrains.kotlin.jvm' version '1.5.21' apply false
|
||||
id 'org.jetbrains.kotlin.jvm' version '1.5.10' apply false
|
||||
id 'org.jetbrains.dokka' version '0.10.1' apply false
|
||||
id 'org.asciidoctor.jvm.convert' version '3.1.0'
|
||||
id 'org.asciidoctor.jvm.pdf' version '3.1.0'
|
||||
@@ -10,7 +10,7 @@ plugins {
|
||||
id "com.github.ben-manes.versions" version '0.28.0'
|
||||
id "com.github.johnrengelman.shadow" version "6.1.0" apply false
|
||||
id "me.champeau.jmh" version "0.6.4" apply false
|
||||
id "org.jetbrains.kotlin.plugin.serialization" version "1.5.21" apply false
|
||||
id "org.jetbrains.kotlin.plugin.serialization" version "1.5.10" apply false
|
||||
id "org.unbroken-dome.xjc" version '2.0.0' apply false
|
||||
}
|
||||
|
||||
@@ -27,14 +27,14 @@ configure(allprojects) { project ->
|
||||
|
||||
dependencyManagement {
|
||||
imports {
|
||||
mavenBom "com.fasterxml.jackson:jackson-bom:2.12.4"
|
||||
mavenBom "com.fasterxml.jackson:jackson-bom:2.12.3"
|
||||
mavenBom "io.netty:netty-bom:4.1.65.Final"
|
||||
mavenBom "io.projectreactor:reactor-bom:2020.0.9"
|
||||
mavenBom "io.projectreactor:reactor-bom:2020.0.7"
|
||||
mavenBom "io.r2dbc:r2dbc-bom:Arabba-SR10"
|
||||
mavenBom "io.rsocket:rsocket-bom:1.1.1"
|
||||
mavenBom "org.eclipse.jetty:jetty-bom:9.4.43.v20210629"
|
||||
mavenBom "org.jetbrains.kotlin:kotlin-bom:1.5.21"
|
||||
mavenBom "org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.5.1"
|
||||
mavenBom "io.rsocket:rsocket-bom:1.1.0"
|
||||
mavenBom "org.eclipse.jetty:jetty-bom:9.4.41.v20210516"
|
||||
mavenBom "org.jetbrains.kotlin:kotlin-bom:1.5.10"
|
||||
mavenBom "org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.5.0"
|
||||
mavenBom "org.jetbrains.kotlinx:kotlinx-serialization-bom:1.2.1"
|
||||
mavenBom "org.junit:junit-bom:5.7.2"
|
||||
}
|
||||
@@ -51,7 +51,7 @@ configure(allprojects) { project ->
|
||||
}
|
||||
dependency "com.google.code.findbugs:jsr305:3.0.2"
|
||||
|
||||
dependencySet(group: 'org.aspectj', version: '1.9.7') {
|
||||
dependencySet(group: 'org.aspectj', version: '1.9.6') {
|
||||
entry 'aspectjrt'
|
||||
entry 'aspectjtools'
|
||||
entry 'aspectjweaver'
|
||||
@@ -76,7 +76,7 @@ configure(allprojects) { project ->
|
||||
exclude group: "stax", name: "stax-api"
|
||||
}
|
||||
dependency "com.google.code.gson:gson:2.8.7"
|
||||
dependency "com.google.protobuf:protobuf-java-util:3.17.3"
|
||||
dependency "com.google.protobuf:protobuf-java-util:3.17.2"
|
||||
dependency "com.googlecode.protobuf-java-format:protobuf-java-format:1.4"
|
||||
dependency("com.thoughtworks.xstream:xstream:1.4.17") {
|
||||
exclude group: "xpp3", name: "xpp3_min"
|
||||
@@ -91,7 +91,7 @@ configure(allprojects) { project ->
|
||||
entry 'jibx-run'
|
||||
}
|
||||
dependency "org.ogce:xpp3:1.1.6"
|
||||
dependency "org.yaml:snakeyaml:1.29"
|
||||
dependency "org.yaml:snakeyaml:1.28"
|
||||
|
||||
dependency "com.h2database:h2:1.4.200"
|
||||
dependency "com.github.ben-manes.caffeine:caffeine:2.9.1"
|
||||
@@ -124,17 +124,17 @@ configure(allprojects) { project ->
|
||||
dependency "org.ehcache:ehcache:3.4.0"
|
||||
dependency "org.hibernate:hibernate-core:5.4.32.Final"
|
||||
dependency "org.hibernate:hibernate-validator:6.2.0.Final"
|
||||
dependency "org.webjars:webjars-locator-core:0.47"
|
||||
dependency "org.webjars:webjars-locator-core:0.46"
|
||||
dependency "org.webjars:underscorejs:1.8.3"
|
||||
|
||||
dependencySet(group: 'org.apache.tomcat', version: '9.0.50') {
|
||||
dependencySet(group: 'org.apache.tomcat', version: '9.0.45') {
|
||||
entry 'tomcat-util'
|
||||
entry('tomcat-websocket') {
|
||||
exclude group: "org.apache.tomcat", name: "tomcat-websocket-api"
|
||||
exclude group: "org.apache.tomcat", name: "tomcat-servlet-api"
|
||||
}
|
||||
}
|
||||
dependencySet(group: 'org.apache.tomcat.embed', version: '9.0.50') {
|
||||
dependencySet(group: 'org.apache.tomcat.embed', version: '9.0.45') {
|
||||
entry 'tomcat-embed-core'
|
||||
entry 'tomcat-embed-websocket'
|
||||
}
|
||||
@@ -161,9 +161,9 @@ configure(allprojects) { project ->
|
||||
}
|
||||
dependency 'org.apache.httpcomponents.client5:httpclient5:5.1'
|
||||
dependency 'org.apache.httpcomponents.core5:httpcore5-reactive:5.1.1'
|
||||
dependency "org.eclipse.jetty:jetty-reactive-httpclient:1.1.9"
|
||||
dependency "org.eclipse.jetty:jetty-reactive-httpclient:1.1.8"
|
||||
|
||||
dependency "org.jruby:jruby:9.2.19.0"
|
||||
dependency "org.jruby:jruby:9.2.17.0"
|
||||
dependency "org.python:jython-standalone:2.7.1"
|
||||
dependency "org.mozilla:rhino:1.7.11"
|
||||
|
||||
@@ -189,7 +189,7 @@ configure(allprojects) { project ->
|
||||
dependency "org.testng:testng:7.4.0"
|
||||
dependency "org.hamcrest:hamcrest:2.1"
|
||||
dependency "org.awaitility:awaitility:3.1.6"
|
||||
dependency "org.assertj:assertj-core:3.20.2"
|
||||
dependency "org.assertj:assertj-core:3.19.0"
|
||||
dependencySet(group: 'org.xmlunit', version: '2.8.2') {
|
||||
entry 'xmlunit-assertj'
|
||||
entry('xmlunit-matchers') {
|
||||
@@ -202,12 +202,12 @@ configure(allprojects) { project ->
|
||||
}
|
||||
entry 'mockito-junit-jupiter'
|
||||
}
|
||||
dependency "io.mockk:mockk:1.11.0"
|
||||
dependency "io.mockk:mockk:1.10.2"
|
||||
|
||||
dependency("net.sourceforge.htmlunit:htmlunit:2.51.0") {
|
||||
dependency("net.sourceforge.htmlunit:htmlunit:2.50.0") {
|
||||
exclude group: "commons-logging", name: "commons-logging"
|
||||
}
|
||||
dependency("org.seleniumhq.selenium:htmlunit-driver:2.51.0") {
|
||||
dependency("org.seleniumhq.selenium:htmlunit-driver:2.50.0") {
|
||||
exclude group: "commons-logging", name: "commons-logging"
|
||||
}
|
||||
dependency("org.seleniumhq.selenium:selenium-java:3.141.59") {
|
||||
@@ -236,7 +236,7 @@ configure(allprojects) { project ->
|
||||
dependency "com.ibm.websphere:uow:6.0.2.17"
|
||||
dependency "com.jamonapi:jamon:2.82"
|
||||
dependency "joda-time:joda-time:2.10.10"
|
||||
dependency "org.eclipse.persistence:org.eclipse.persistence.jpa:2.7.9"
|
||||
dependency "org.eclipse.persistence:org.eclipse.persistence.jpa:2.7.8"
|
||||
dependency "org.javamoney:moneta:1.3"
|
||||
|
||||
dependency "com.sun.activation:javax.activation:1.2.0"
|
||||
@@ -336,7 +336,7 @@ configure([rootProject] + javaProjects) { project ->
|
||||
}
|
||||
|
||||
checkstyle {
|
||||
toolVersion = "8.44"
|
||||
toolVersion = "8.43"
|
||||
configDirectory.set(rootProject.file("src/checkstyle"))
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
version=5.3.9
|
||||
version=5.3.8
|
||||
org.gradle.jvmargs=-Xmx1536M
|
||||
org.gradle.caching=true
|
||||
org.gradle.parallel=true
|
||||
|
||||
+1
-12
@@ -103,12 +103,9 @@ dokka {
|
||||
externalDocumentationLink {
|
||||
url = new URL("https://www.reactive-streams.org/reactive-streams-1.0.1-javadoc/")
|
||||
}
|
||||
/*
|
||||
This link causes errors, removing to fix the build.
|
||||
externalDocumentationLink {
|
||||
url = new URL("https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/")
|
||||
}
|
||||
*/
|
||||
externalDocumentationLink {
|
||||
url = new URL("https://r2dbc.io/spec/0.8.3.RELEASE/api/")
|
||||
}
|
||||
@@ -130,8 +127,6 @@ task extractDocResources(type: Copy, dependsOn: downloadResources) {
|
||||
}
|
||||
|
||||
asciidoctorj {
|
||||
def docRoot = 'https://docs.spring.io'
|
||||
def docsSpringFramework = "${docRoot}/spring-framework/docs/${project.version}"
|
||||
version = '2.4.1'
|
||||
fatalWarnings ".*"
|
||||
options doctype: 'book', eruby: 'erubis'
|
||||
@@ -149,10 +144,7 @@ asciidoctorj {
|
||||
stylesdir: 'css/',
|
||||
stylesheet: 'stylesheet.css',
|
||||
'spring-version': project.version,
|
||||
'spring-framework-main-code': 'https://github.com/spring-projects/spring-framework/tree/main',
|
||||
'doc-root': docRoot,
|
||||
'docs-spring-framework': docsSpringFramework,
|
||||
'api-spring-framework': "${docsSpringFramework}/javadoc-api/org/springframework"
|
||||
'spring-framework-main-code': 'https://github.com/spring-projects/spring-framework/tree/main'
|
||||
])
|
||||
}
|
||||
|
||||
@@ -163,9 +155,6 @@ asciidoctorj {
|
||||
asciidoctor {
|
||||
baseDirFollowsSourceDir()
|
||||
configurations 'asciidoctorExt'
|
||||
attributes([
|
||||
noheader: '' // custom header in docinfo-header.html
|
||||
])
|
||||
sources {
|
||||
include '*.adoc'
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2020 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.
|
||||
@@ -625,7 +625,7 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (bodyStart >= 0 && bodyStart != (currentToken.length() - 1)) {
|
||||
sb.append(currentToken.substring(bodyStart + 1));
|
||||
sb.append(' ');
|
||||
sb.append(" ");
|
||||
}
|
||||
numTokensConsumed++;
|
||||
int currentIndex = startIndex + numTokensConsumed;
|
||||
@@ -645,7 +645,7 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov
|
||||
toAppend = toAppend.substring(1);
|
||||
}
|
||||
sb.append(toAppend);
|
||||
sb.append(' ');
|
||||
sb.append(" ");
|
||||
currentIndex++;
|
||||
numTokensConsumed++;
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -547,7 +547,7 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut
|
||||
StringBuilder sb = new StringBuilder("AspectJExpressionPointcut: (");
|
||||
for (int i = 0; i < this.pointcutParameterTypes.length; i++) {
|
||||
sb.append(this.pointcutParameterTypes[i].getName());
|
||||
sb.append(' ');
|
||||
sb.append(" ");
|
||||
sb.append(this.pointcutParameterNames[i]);
|
||||
if ((i+1) < this.pointcutParameterTypes.length) {
|
||||
sb.append(", ");
|
||||
|
||||
+7
-7
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2020 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.
|
||||
@@ -255,19 +255,19 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint,
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (includeModifier) {
|
||||
sb.append(Modifier.toString(getModifiers()));
|
||||
sb.append(' ');
|
||||
sb.append(" ");
|
||||
}
|
||||
if (includeReturnTypeAndArgs) {
|
||||
appendType(sb, getReturnType(), useLongReturnAndArgumentTypeName);
|
||||
sb.append(' ');
|
||||
sb.append(" ");
|
||||
}
|
||||
appendType(sb, getDeclaringType(), useLongTypeName);
|
||||
sb.append('.');
|
||||
sb.append(".");
|
||||
sb.append(getMethod().getName());
|
||||
sb.append('(');
|
||||
sb.append("(");
|
||||
Class<?>[] parametersTypes = getParameterTypes();
|
||||
appendTypes(sb, parametersTypes, includeReturnTypeAndArgs, useLongReturnAndArgumentTypeName);
|
||||
sb.append(')');
|
||||
sb.append(")");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@@ -278,7 +278,7 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint,
|
||||
for (int size = types.length, i = 0; i < size; i++) {
|
||||
appendType(sb, types[i], useLongReturnAndArgumentTypeName);
|
||||
if (i < size - 1) {
|
||||
sb.append(',');
|
||||
sb.append(",");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2020 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.
|
||||
@@ -19,9 +19,7 @@ package org.springframework.aop.framework;
|
||||
import java.lang.reflect.Array;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Proxy;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.aop.SpringProxy;
|
||||
import org.springframework.aop.TargetClassAware;
|
||||
@@ -31,9 +29,7 @@ import org.springframework.aop.target.SingletonTargetSource;
|
||||
import org.springframework.core.DecoratingProxy;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
/**
|
||||
* Utility methods for AOP proxy factories.
|
||||
@@ -48,11 +44,6 @@ import org.springframework.util.ReflectionUtils;
|
||||
*/
|
||||
public abstract class AopProxyUtils {
|
||||
|
||||
// JDK 17 Class.isSealed() method available?
|
||||
@Nullable
|
||||
private static final Method isSealedMethod = ClassUtils.getMethodIfAvailable(Class.class, "isSealed");
|
||||
|
||||
|
||||
/**
|
||||
* Obtain the singleton target object behind the given proxy, if any.
|
||||
* @param candidate the (potential) proxy to check
|
||||
@@ -139,23 +130,34 @@ public abstract class AopProxyUtils {
|
||||
specifiedInterfaces = advised.getProxiedInterfaces();
|
||||
}
|
||||
}
|
||||
List<Class<?>> proxiedInterfaces = new ArrayList<>(specifiedInterfaces.length + 3);
|
||||
for (Class<?> ifc : specifiedInterfaces) {
|
||||
// Only non-sealed interfaces are actually eligible for JDK proxying (on JDK 17)
|
||||
if (isSealedMethod == null || Boolean.FALSE.equals(ReflectionUtils.invokeMethod(isSealedMethod, ifc))) {
|
||||
proxiedInterfaces.add(ifc);
|
||||
}
|
||||
boolean addSpringProxy = !advised.isInterfaceProxied(SpringProxy.class);
|
||||
boolean addAdvised = !advised.isOpaque() && !advised.isInterfaceProxied(Advised.class);
|
||||
boolean addDecoratingProxy = (decoratingProxy && !advised.isInterfaceProxied(DecoratingProxy.class));
|
||||
int nonUserIfcCount = 0;
|
||||
if (addSpringProxy) {
|
||||
nonUserIfcCount++;
|
||||
}
|
||||
if (!advised.isInterfaceProxied(SpringProxy.class)) {
|
||||
proxiedInterfaces.add(SpringProxy.class);
|
||||
if (addAdvised) {
|
||||
nonUserIfcCount++;
|
||||
}
|
||||
if (!advised.isOpaque() && !advised.isInterfaceProxied(Advised.class)) {
|
||||
proxiedInterfaces.add(Advised.class);
|
||||
if (addDecoratingProxy) {
|
||||
nonUserIfcCount++;
|
||||
}
|
||||
if (decoratingProxy && !advised.isInterfaceProxied(DecoratingProxy.class)) {
|
||||
proxiedInterfaces.add(DecoratingProxy.class);
|
||||
Class<?>[] proxiedInterfaces = new Class<?>[specifiedInterfaces.length + nonUserIfcCount];
|
||||
System.arraycopy(specifiedInterfaces, 0, proxiedInterfaces, 0, specifiedInterfaces.length);
|
||||
int index = specifiedInterfaces.length;
|
||||
if (addSpringProxy) {
|
||||
proxiedInterfaces[index] = SpringProxy.class;
|
||||
index++;
|
||||
}
|
||||
return ClassUtils.toClassArray(proxiedInterfaces);
|
||||
if (addAdvised) {
|
||||
proxiedInterfaces[index] = Advised.class;
|
||||
index++;
|
||||
}
|
||||
if (addDecoratingProxy) {
|
||||
proxiedInterfaces[index] = DecoratingProxy.class;
|
||||
}
|
||||
return proxiedInterfaces;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+1
-12
@@ -17,7 +17,6 @@
|
||||
package org.springframework.aop.framework.autoproxy;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Proxy;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
@@ -441,17 +440,7 @@ public abstract class AbstractAutoProxyCreator extends ProxyProcessorSupport
|
||||
ProxyFactory proxyFactory = new ProxyFactory();
|
||||
proxyFactory.copyFrom(this);
|
||||
|
||||
if (proxyFactory.isProxyTargetClass()) {
|
||||
// Explicit handling of JDK proxy targets (for introduction advice scenarios)
|
||||
if (Proxy.isProxyClass(beanClass)) {
|
||||
// Must allow for introductions; can't just set interfaces to the proxy's interfaces only.
|
||||
for (Class<?> ifc : beanClass.getInterfaces()) {
|
||||
proxyFactory.addInterface(ifc);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// No proxyTargetClass flag enforced, let's apply our default checks...
|
||||
if (!proxyFactory.isProxyTargetClass()) {
|
||||
if (shouldProxyTargetClass(beanClass, beanName)) {
|
||||
proxyFactory.setProxyTargetClass(true);
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -137,7 +137,7 @@ public abstract class AbstractBeanFactoryPointcutAdvisor extends AbstractPointcu
|
||||
StringBuilder sb = new StringBuilder(getClass().getName());
|
||||
sb.append(": advice ");
|
||||
if (this.adviceBeanName != null) {
|
||||
sb.append("bean '").append(this.adviceBeanName).append('\'');
|
||||
sb.append("bean '").append(this.adviceBeanName).append("'");
|
||||
}
|
||||
else {
|
||||
sb.append(this.advice);
|
||||
|
||||
+2
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -71,8 +71,7 @@ public class DefaultIntroductionAdvisor implements IntroductionAdvisor, ClassFil
|
||||
if (introductionInfo != null) {
|
||||
Class<?>[] introducedInterfaces = introductionInfo.getInterfaces();
|
||||
if (introducedInterfaces.length == 0) {
|
||||
throw new IllegalArgumentException(
|
||||
"IntroductionInfo defines no interfaces to introduce: " + introductionInfo);
|
||||
throw new IllegalArgumentException("IntroductionAdviceSupport implements no interfaces");
|
||||
}
|
||||
for (Class<?> ifc : introducedInterfaces) {
|
||||
addInterface(ifc);
|
||||
|
||||
+2
-2
@@ -191,9 +191,9 @@ public abstract class AbstractBeanFactoryBasedTargetSource implements TargetSour
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder(getClass().getSimpleName());
|
||||
sb.append(" for target bean '").append(this.targetBeanName).append('\'');
|
||||
sb.append(" for target bean '").append(this.targetBeanName).append("'");
|
||||
if (this.targetClass != null) {
|
||||
sb.append(" of type [").append(this.targetClass.getName()).append(']');
|
||||
sb.append(" of type [").append(this.targetClass.getName()).append("]");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
+3
-3
@@ -276,14 +276,14 @@ public class AspectJAdviceParameterNameDiscovererTests {
|
||||
|
||||
private static String format(String[] names) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append('(');
|
||||
sb.append("(");
|
||||
for (int i = 0; i < names.length; i++) {
|
||||
sb.append(names[i]);
|
||||
if ((i + 1) < names.length) {
|
||||
sb.append(',');
|
||||
sb.append(",");
|
||||
}
|
||||
}
|
||||
sb.append(')');
|
||||
sb.append(")");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -183,7 +183,7 @@ public class ProxyFactoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetsAllInterfaces() {
|
||||
public void testGetsAllInterfaces() throws Exception {
|
||||
// Extend to get new interface
|
||||
class TestBeanSubclass extends TestBean implements Comparable<Object> {
|
||||
@Override
|
||||
@@ -240,16 +240,6 @@ public class ProxyFactoryTests {
|
||||
assertThat(factory.countAdvicesOfType(NopInterceptor.class) == 2).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSealedInterfaceExclusion() {
|
||||
// String implements ConstantDesc on JDK 12+, sealed as of JDK 17
|
||||
ProxyFactory factory = new ProxyFactory(new String());
|
||||
NopInterceptor di = new NopInterceptor();
|
||||
factory.addAdvice(0, di);
|
||||
Object proxy = factory.getProxy();
|
||||
assertThat(proxy).isInstanceOf(CharSequence.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Should see effect immediately on behavior.
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2020 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.
|
||||
@@ -41,6 +41,8 @@ import kotlin.reflect.KParameter;
|
||||
import kotlin.reflect.full.KClasses;
|
||||
import kotlin.reflect.jvm.KCallablesJvm;
|
||||
import kotlin.reflect.jvm.ReflectJvmMapping;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.core.DefaultParameterNameDiscoverer;
|
||||
import org.springframework.core.KotlinDetector;
|
||||
@@ -73,6 +75,8 @@ import org.springframework.util.StringUtils;
|
||||
*/
|
||||
public abstract class BeanUtils {
|
||||
|
||||
private static final Log logger = LogFactory.getLog(BeanUtils.class);
|
||||
|
||||
private static final ParameterNameDiscoverer parameterNameDiscoverer =
|
||||
new DefaultParameterNameDiscoverer();
|
||||
|
||||
@@ -547,6 +551,9 @@ public abstract class BeanUtils {
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
// e.g. AccessControlException on Google App Engine
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Could not access system ClassLoader: " + ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -557,6 +564,10 @@ public abstract class BeanUtils {
|
||||
Class<?> editorClass = cl.loadClass(editorName);
|
||||
if (editorClass != null) {
|
||||
if (!PropertyEditor.class.isAssignableFrom(editorClass)) {
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Editor class [" + editorName +
|
||||
"] does not implement [java.beans.PropertyEditor] interface");
|
||||
}
|
||||
unknownEditorTypes.add(targetType);
|
||||
return null;
|
||||
}
|
||||
@@ -568,6 +579,10 @@ public abstract class BeanUtils {
|
||||
catch (ClassNotFoundException ex) {
|
||||
// Ignore - fall back to unknown editor type registration below
|
||||
}
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("No property editor [" + editorName + "] found for type " +
|
||||
targetTypeName + " according to 'Editor' suffix convention");
|
||||
}
|
||||
unknownEditorTypes.add(targetType);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -247,14 +247,14 @@ class TypeConverterDelegate {
|
||||
// Definitely doesn't match: throw IllegalArgumentException/IllegalStateException
|
||||
StringBuilder msg = new StringBuilder();
|
||||
msg.append("Cannot convert value of type '").append(ClassUtils.getDescriptiveType(newValue));
|
||||
msg.append("' to required type '").append(ClassUtils.getQualifiedName(requiredType)).append('\'');
|
||||
msg.append("' to required type '").append(ClassUtils.getQualifiedName(requiredType)).append("'");
|
||||
if (propertyName != null) {
|
||||
msg.append(" for property '").append(propertyName).append('\'');
|
||||
msg.append(" for property '").append(propertyName).append("'");
|
||||
}
|
||||
if (editor != null) {
|
||||
msg.append(": PropertyEditor [").append(editor.getClass().getName()).append(
|
||||
"] returned inappropriate value of type '").append(
|
||||
ClassUtils.getDescriptiveType(convertedValue)).append('\'');
|
||||
ClassUtils.getDescriptiveType(convertedValue)).append("'");
|
||||
throw new IllegalArgumentException(msg.toString());
|
||||
}
|
||||
else {
|
||||
|
||||
+4
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2020 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.
|
||||
@@ -217,13 +217,13 @@ public class RequiredAnnotationBeanPostProcessor implements SmartInstantiationAw
|
||||
sb.append(" and");
|
||||
}
|
||||
else {
|
||||
sb.append(',');
|
||||
sb.append(",");
|
||||
}
|
||||
}
|
||||
sb.append(" '").append(propertyName).append('\'');
|
||||
sb.append(" '").append(propertyName).append("'");
|
||||
}
|
||||
sb.append(size == 1 ? " is" : " are");
|
||||
sb.append(" required for bean '").append(beanName).append('\'');
|
||||
sb.append(" required for bean '").append(beanName).append("'");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -489,9 +489,9 @@ public class GroovyBeanDefinitionReader extends AbstractBeanDefinitionReader imp
|
||||
resolveConstructorArguments(args, 2, hasClosureArgument ? args.length - 1 : args.length);
|
||||
this.currentBeanDefinition = new GroovyBeanDefinitionWrapper(beanName, (Class<?>) args[1], constructorArgs);
|
||||
Map<?, ?> namedArgs = (Map<?, ?>) args[0];
|
||||
for (Map.Entry<?, ?> entity : namedArgs.entrySet()) {
|
||||
String propName = (String) entity.getKey();
|
||||
setProperty(propName, entity.getValue());
|
||||
for (Object key : namedArgs.keySet()) {
|
||||
String propName = (String) key;
|
||||
setProperty(propName, namedArgs.get(propName));
|
||||
}
|
||||
}
|
||||
// factory method syntax
|
||||
|
||||
+1
-1
@@ -1241,7 +1241,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder("class [");
|
||||
sb.append(getBeanClassName()).append(']');
|
||||
sb.append(getBeanClassName()).append("]");
|
||||
sb.append("; scope=").append(this.scope);
|
||||
sb.append("; abstract=").append(this.abstractFlag);
|
||||
sb.append("; lazyInit=").append(this.lazyInit);
|
||||
|
||||
+2
-37
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -21,7 +21,6 @@ import java.util.function.Supplier;
|
||||
import org.springframework.beans.factory.config.AutowiredPropertyMarker;
|
||||
import org.springframework.beans.factory.config.BeanDefinitionCustomizer;
|
||||
import org.springframework.beans.factory.config.RuntimeBeanReference;
|
||||
import org.springframework.core.ResolvableType;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
@@ -103,7 +102,7 @@ public final class BeanDefinitionBuilder {
|
||||
* @param beanClass the {@code Class} of the bean that the definition is being created for
|
||||
*/
|
||||
public static BeanDefinitionBuilder rootBeanDefinition(Class<?> beanClass) {
|
||||
return rootBeanDefinition(beanClass, (String) null);
|
||||
return rootBeanDefinition(beanClass, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -118,30 +117,6 @@ public final class BeanDefinitionBuilder {
|
||||
return builder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@code BeanDefinitionBuilder} used to construct a {@link RootBeanDefinition}.
|
||||
* @param beanType the {@link ResolvableType type} of the bean that the definition is being created for
|
||||
* @param instanceSupplier a callback for creating an instance of the bean
|
||||
* @since 5.3.9
|
||||
*/
|
||||
public static <T> BeanDefinitionBuilder rootBeanDefinition(ResolvableType beanType, Supplier<T> instanceSupplier) {
|
||||
RootBeanDefinition beanDefinition = new RootBeanDefinition();
|
||||
beanDefinition.setTargetType(beanType);
|
||||
beanDefinition.setInstanceSupplier(instanceSupplier);
|
||||
return new BeanDefinitionBuilder(beanDefinition);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@code BeanDefinitionBuilder} used to construct a {@link RootBeanDefinition}.
|
||||
* @param beanClass the {@code Class} of the bean that the definition is being created for
|
||||
* @param instanceSupplier a callback for creating an instance of the bean
|
||||
* @since 5.3.9
|
||||
* @see #rootBeanDefinition(ResolvableType, Supplier)
|
||||
*/
|
||||
public static <T> BeanDefinitionBuilder rootBeanDefinition(Class<T> beanClass, Supplier<T> instanceSupplier) {
|
||||
return rootBeanDefinition(ResolvableType.forClass(beanClass), instanceSupplier);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@code BeanDefinitionBuilder} used to construct a {@link ChildBeanDefinition}.
|
||||
* @param parentName the name of the parent bean
|
||||
@@ -356,16 +331,6 @@ public final class BeanDefinitionBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether this bean is 'synthetic', that is, not defined by
|
||||
* the application itself.
|
||||
* @since 5.3.9
|
||||
*/
|
||||
public BeanDefinitionBuilder setSynthetic(boolean synthetic) {
|
||||
this.beanDefinition.setSynthetic(synthetic);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply the given customizers to the underlying bean definition.
|
||||
* @since 5.0
|
||||
|
||||
+7
-7
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2020 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.
|
||||
@@ -277,12 +277,12 @@ class ConstructorResolver {
|
||||
throw ex;
|
||||
}
|
||||
throw new BeanCreationException(mbd.getResourceDescription(), beanName,
|
||||
"Could not resolve matching constructor on bean class [" + mbd.getBeanClassName() + "] " +
|
||||
"Could not resolve matching constructor " +
|
||||
"(hint: specify index/type/name arguments for simple parameters to avoid type ambiguities)");
|
||||
}
|
||||
else if (ambiguousConstructors != null && !mbd.isLenientConstructorResolution()) {
|
||||
throw new BeanCreationException(mbd.getResourceDescription(), beanName,
|
||||
"Ambiguous constructor matches found on bean class [" + mbd.getBeanClassName() + "] " +
|
||||
"Ambiguous constructor matches found in bean '" + beanName + "' " +
|
||||
"(hint: specify index/type/name arguments for simple parameters to avoid type ambiguities): " +
|
||||
ambiguousConstructors);
|
||||
}
|
||||
@@ -608,7 +608,7 @@ class ConstructorResolver {
|
||||
}
|
||||
String argDesc = StringUtils.collectionToCommaDelimitedString(argTypes);
|
||||
throw new BeanCreationException(mbd.getResourceDescription(), beanName,
|
||||
"No matching factory method found on class [" + factoryClass.getName() + "]: " +
|
||||
"No matching factory method found: " +
|
||||
(mbd.getFactoryBeanName() != null ?
|
||||
"factory bean '" + mbd.getFactoryBeanName() + "'; " : "") +
|
||||
"factory method '" + mbd.getFactoryMethodName() + "(" + argDesc + ")'. " +
|
||||
@@ -619,12 +619,12 @@ class ConstructorResolver {
|
||||
}
|
||||
else if (void.class == factoryMethodToUse.getReturnType()) {
|
||||
throw new BeanCreationException(mbd.getResourceDescription(), beanName,
|
||||
"Invalid factory method '" + mbd.getFactoryMethodName() + "' on class [" +
|
||||
factoryClass.getName() + "]: needs to have a non-void return type!");
|
||||
"Invalid factory method '" + mbd.getFactoryMethodName() +
|
||||
"': needs to have a non-void return type!");
|
||||
}
|
||||
else if (ambiguousFactoryMethods != null) {
|
||||
throw new BeanCreationException(mbd.getResourceDescription(), beanName,
|
||||
"Ambiguous factory method matches found on class [" + factoryClass.getName() + "] " +
|
||||
"Ambiguous factory method matches found in bean '" + beanName + "' " +
|
||||
"(hint: specify index/type/name arguments for simple parameters to avoid type ambiguities): " +
|
||||
ambiguousFactoryMethods);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -31,7 +31,6 @@ import static org.springframework.beans.factory.support.BeanDefinitionBuilder.ro
|
||||
* invoking a factory method is not instructive to the user and rather misleading.
|
||||
*
|
||||
* @author Chris Beams
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
public class Spr5475Tests {
|
||||
|
||||
@@ -41,8 +40,7 @@ public class Spr5475Tests {
|
||||
rootBeanDefinition(Foo.class)
|
||||
.setFactoryMethod("noArgFactory")
|
||||
.addConstructorArgValue("bogusArg").getBeanDefinition(),
|
||||
"Error creating bean with name 'foo': No matching factory method found on class " +
|
||||
"[org.springframework.beans.factory.Spr5475Tests$Foo]: factory method 'noArgFactory(String)'. " +
|
||||
"Error creating bean with name 'foo': No matching factory method found: factory method 'noArgFactory(String)'. " +
|
||||
"Check that a method with the specified name and arguments exists and that it is static.");
|
||||
}
|
||||
|
||||
@@ -53,8 +51,7 @@ public class Spr5475Tests {
|
||||
.setFactoryMethod("noArgFactory")
|
||||
.addConstructorArgValue("bogusArg1")
|
||||
.addConstructorArgValue("bogusArg2".getBytes()).getBeanDefinition(),
|
||||
"Error creating bean with name 'foo': No matching factory method found on class " +
|
||||
"[org.springframework.beans.factory.Spr5475Tests$Foo]: factory method 'noArgFactory(String,byte[])'. " +
|
||||
"Error creating bean with name 'foo': No matching factory method found: factory method 'noArgFactory(String,byte[])'. " +
|
||||
"Check that a method with the specified name and arguments exists and that it is static.");
|
||||
}
|
||||
|
||||
@@ -68,8 +65,7 @@ public class Spr5475Tests {
|
||||
def.setConstructorArgumentValues(cav);
|
||||
|
||||
assertExceptionMessageForMisconfiguredFactoryMethod(def,
|
||||
"Error creating bean with name 'foo': No matching factory method found on class " +
|
||||
"[org.springframework.beans.factory.Spr5475Tests$Foo]: factory method 'noArgFactory(CharSequence,byte[])'. " +
|
||||
"Error creating bean with name 'foo': No matching factory method found: factory method 'noArgFactory(CharSequence,byte[])'. " +
|
||||
"Check that a method with the specified name and arguments exists and that it is static.");
|
||||
}
|
||||
|
||||
|
||||
+5
-82
@@ -17,25 +17,22 @@
|
||||
package org.springframework.beans.factory.support;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.testfixture.beans.TestBean;
|
||||
import org.springframework.core.ResolvableType;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* @author Rod Johnson
|
||||
* @author Juergen Hoeller
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
class BeanDefinitionBuilderTests {
|
||||
public class BeanDefinitionBuilderTests {
|
||||
|
||||
@Test
|
||||
void builderWithBeanClassWithSimpleProperty() {
|
||||
public void beanClassWithSimpleProperty() {
|
||||
String[] dependsOn = new String[] { "A", "B", "C" };
|
||||
BeanDefinitionBuilder bdb = BeanDefinitionBuilder.rootBeanDefinition(TestBean.class);
|
||||
bdb.setScope(BeanDefinition.SCOPE_PROTOTYPE);
|
||||
@@ -52,7 +49,7 @@ class BeanDefinitionBuilderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void builderWithBeanClassAndFactoryMethod() {
|
||||
public void beanClassWithFactoryMethod() {
|
||||
BeanDefinitionBuilder bdb = BeanDefinitionBuilder.rootBeanDefinition(TestBean.class, "create");
|
||||
RootBeanDefinition rbd = (RootBeanDefinition) bdb.getBeanDefinition();
|
||||
assertThat(rbd.hasBeanClass()).isTrue();
|
||||
@@ -61,7 +58,7 @@ class BeanDefinitionBuilderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void builderWithBeanClassName() {
|
||||
public void beanClassName() {
|
||||
BeanDefinitionBuilder bdb = BeanDefinitionBuilder.rootBeanDefinition(TestBean.class.getName());
|
||||
RootBeanDefinition rbd = (RootBeanDefinition) bdb.getBeanDefinition();
|
||||
assertThat(rbd.hasBeanClass()).isFalse();
|
||||
@@ -69,7 +66,7 @@ class BeanDefinitionBuilderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void builderWithBeanClassNameAndFactoryMethod() {
|
||||
public void beanClassNameWithFactoryMethod() {
|
||||
BeanDefinitionBuilder bdb = BeanDefinitionBuilder.rootBeanDefinition(TestBean.class.getName(), "create");
|
||||
RootBeanDefinition rbd = (RootBeanDefinition) bdb.getBeanDefinition();
|
||||
assertThat(rbd.hasBeanClass()).isFalse();
|
||||
@@ -77,78 +74,4 @@ class BeanDefinitionBuilderTests {
|
||||
assertThat(rbd.getFactoryMethodName()).isEqualTo("create");
|
||||
}
|
||||
|
||||
@Test
|
||||
void builderWithResolvableTypeAndInstanceSupplier() {
|
||||
ResolvableType type = ResolvableType.forClassWithGenerics(Function.class, Integer.class, String.class);
|
||||
Function<Integer, String> function = i -> "value " + i;
|
||||
RootBeanDefinition rbd = (RootBeanDefinition) BeanDefinitionBuilder
|
||||
.rootBeanDefinition(type, () -> function).getBeanDefinition();
|
||||
assertThat(rbd.getResolvableType()).isEqualTo(type);
|
||||
assertThat(rbd.getInstanceSupplier()).isNotNull();
|
||||
assertThat(rbd.getInstanceSupplier().get()).isInstanceOf(Function.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
void builderWithBeanClassAndInstanceSupplier() {
|
||||
RootBeanDefinition rbd = (RootBeanDefinition) BeanDefinitionBuilder
|
||||
.rootBeanDefinition(String.class, () -> "test").getBeanDefinition();
|
||||
assertThat(rbd.getResolvableType().resolve()).isEqualTo(String.class);
|
||||
assertThat(rbd.getInstanceSupplier()).isNotNull();
|
||||
assertThat(rbd.getInstanceSupplier().get()).isEqualTo("test");
|
||||
}
|
||||
|
||||
@Test
|
||||
void builderWithAutowireMode() {
|
||||
assertThat(BeanDefinitionBuilder.rootBeanDefinition(TestBean.class)
|
||||
.setAutowireMode(RootBeanDefinition.AUTOWIRE_BY_TYPE).getBeanDefinition().getAutowireMode())
|
||||
.isEqualTo(RootBeanDefinition.AUTOWIRE_BY_TYPE);
|
||||
}
|
||||
|
||||
@Test
|
||||
void builderWithDependencyCheck() {
|
||||
assertThat(BeanDefinitionBuilder.rootBeanDefinition(TestBean.class)
|
||||
.setDependencyCheck(RootBeanDefinition.DEPENDENCY_CHECK_ALL)
|
||||
.getBeanDefinition().getDependencyCheck())
|
||||
.isEqualTo(RootBeanDefinition.DEPENDENCY_CHECK_ALL);
|
||||
}
|
||||
|
||||
@Test
|
||||
void builderWithDependsOn() {
|
||||
assertThat(BeanDefinitionBuilder.rootBeanDefinition(TestBean.class).addDependsOn("test")
|
||||
.addDependsOn("test2").getBeanDefinition().getDependsOn())
|
||||
.containsExactly("test", "test2");
|
||||
}
|
||||
|
||||
@Test
|
||||
void builderWithPrimary() {
|
||||
assertThat(BeanDefinitionBuilder.rootBeanDefinition(TestBean.class)
|
||||
.setPrimary(true).getBeanDefinition().isPrimary()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void builderWithRole() {
|
||||
assertThat(BeanDefinitionBuilder.rootBeanDefinition(TestBean.class)
|
||||
.setRole(BeanDefinition.ROLE_INFRASTRUCTURE).getBeanDefinition().getRole())
|
||||
.isEqualTo(BeanDefinition.ROLE_INFRASTRUCTURE);
|
||||
}
|
||||
|
||||
@Test
|
||||
void builderWithSynthetic() {
|
||||
assertThat(BeanDefinitionBuilder.rootBeanDefinition(TestBean.class)
|
||||
.setSynthetic(true).getBeanDefinition().isSynthetic()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void builderWithCustomizers() {
|
||||
BeanDefinition beanDefinition = BeanDefinitionBuilder.rootBeanDefinition(TestBean.class)
|
||||
.applyCustomizers(builder -> {
|
||||
builder.setFactoryMethodName("create");
|
||||
builder.setRole(BeanDefinition.ROLE_SUPPORT);
|
||||
})
|
||||
.applyCustomizers(builder -> builder.setRole(BeanDefinition.ROLE_INFRASTRUCTURE))
|
||||
.getBeanDefinition();
|
||||
assertThat(beanDefinition.getFactoryMethodName()).isEqualTo("create");
|
||||
assertThat(beanDefinition.getRole()).isEqualTo(BeanDefinition.ROLE_INFRASTRUCTURE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -244,7 +244,7 @@ public class QualifierAnnotationAutowireBeanFactoryTests {
|
||||
@Target({ElementType.FIELD, ElementType.PARAMETER})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Qualifier
|
||||
private @interface TestQualifier {
|
||||
private static @interface TestQualifier {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -138,7 +138,7 @@ abstract class AbstractJCacheOperation<A extends Annotation> implements JCacheOp
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getOperationDescription().append(']').toString();
|
||||
return getOperationDescription().append("]").toString();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -148,7 +148,7 @@ abstract class AbstractJCacheOperation<A extends Annotation> implements JCacheOp
|
||||
protected StringBuilder getOperationDescription() {
|
||||
StringBuilder result = new StringBuilder();
|
||||
result.append(getClass().getSimpleName());
|
||||
result.append('[');
|
||||
result.append("[");
|
||||
result.append(this.methodDetails);
|
||||
return result;
|
||||
}
|
||||
|
||||
Vendored
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -71,9 +71,9 @@ public class CacheEvictOperation extends CacheOperation {
|
||||
@Override
|
||||
protected StringBuilder getOperationDescription() {
|
||||
StringBuilder sb = super.getOperationDescription();
|
||||
sb.append(',');
|
||||
sb.append(",");
|
||||
sb.append(this.cacheWide);
|
||||
sb.append(',');
|
||||
sb.append(",");
|
||||
sb.append(this.beforeInvocation);
|
||||
return sb;
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -216,13 +216,13 @@ public abstract class CacheOperation implements BasicOperation {
|
||||
*/
|
||||
protected StringBuilder getOperationDescription() {
|
||||
StringBuilder result = new StringBuilder(getClass().getSimpleName());
|
||||
result.append('[').append(this.name);
|
||||
result.append("[").append(this.name);
|
||||
result.append("] caches=").append(this.cacheNames);
|
||||
result.append(" | key='").append(this.key);
|
||||
result.append("' | keyGenerator='").append(this.keyGenerator);
|
||||
result.append("' | cacheManager='").append(this.cacheManager);
|
||||
result.append("' | cacheResolver='").append(this.cacheResolver);
|
||||
result.append("' | condition='").append(this.condition).append('\'');
|
||||
result.append("' | condition='").append(this.condition).append("'");
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -66,7 +66,7 @@ public class CachePutOperation extends CacheOperation {
|
||||
StringBuilder sb = super.getOperationDescription();
|
||||
sb.append(" | unless='");
|
||||
sb.append(this.unless);
|
||||
sb.append('\'');
|
||||
sb.append("'");
|
||||
return sb;
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -79,10 +79,10 @@ public class CacheableOperation extends CacheOperation {
|
||||
StringBuilder sb = super.getOperationDescription();
|
||||
sb.append(" | unless='");
|
||||
sb.append(this.unless);
|
||||
sb.append('\'');
|
||||
sb.append("'");
|
||||
sb.append(" | sync='");
|
||||
sb.append(this.sync);
|
||||
sb.append('\'');
|
||||
sb.append("'");
|
||||
return sb;
|
||||
}
|
||||
|
||||
|
||||
+5
-23
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -19,15 +19,13 @@ package org.springframework.context.annotation;
|
||||
import org.springframework.beans.factory.parsing.Problem;
|
||||
import org.springframework.beans.factory.parsing.ProblemReporter;
|
||||
import org.springframework.core.type.MethodMetadata;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Represents a {@link Configuration @Configuration} class method annotated with
|
||||
* {@link Bean @Bean}.
|
||||
* Represents a {@link Configuration @Configuration} class method marked with the
|
||||
* {@link Bean @Bean} annotation.
|
||||
*
|
||||
* @author Chris Beams
|
||||
* @author Juergen Hoeller
|
||||
* @author Sam Brannen
|
||||
* @since 3.0
|
||||
* @see ConfigurationClass
|
||||
* @see ConfigurationClassParser
|
||||
@@ -35,7 +33,7 @@ import org.springframework.lang.Nullable;
|
||||
*/
|
||||
final class BeanMethod extends ConfigurationMethod {
|
||||
|
||||
BeanMethod(MethodMetadata metadata, ConfigurationClass configurationClass) {
|
||||
public BeanMethod(MethodMetadata metadata, ConfigurationClass configurationClass) {
|
||||
super(metadata, configurationClass);
|
||||
}
|
||||
|
||||
@@ -54,28 +52,12 @@ final class BeanMethod extends ConfigurationMethod {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object obj) {
|
||||
return ((this == obj) || ((obj instanceof BeanMethod) &&
|
||||
this.metadata.equals(((BeanMethod) obj).metadata)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.metadata.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "BeanMethod: " + this.metadata;
|
||||
}
|
||||
|
||||
private class NonOverridableMethodError extends Problem {
|
||||
|
||||
NonOverridableMethodError() {
|
||||
public NonOverridableMethodError() {
|
||||
super(String.format("@Bean method '%s' must not be private or final; change the method's modifiers to continue",
|
||||
getMetadata().getMethodName()), getResourceLocation());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+21
-21
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -36,7 +36,7 @@ import org.springframework.util.ClassUtils;
|
||||
|
||||
/**
|
||||
* Represents a user-defined {@link Configuration @Configuration} class.
|
||||
* <p>Includes a set of {@link Bean} methods, including all such methods
|
||||
* Includes a set of {@link Bean} methods, including all such methods
|
||||
* defined in the ancestry of the class, in a 'flattened-out' manner.
|
||||
*
|
||||
* @author Chris Beams
|
||||
@@ -74,7 +74,7 @@ final class ConfigurationClass {
|
||||
* @param beanName must not be {@code null}
|
||||
* @see ConfigurationClass#ConfigurationClass(Class, ConfigurationClass)
|
||||
*/
|
||||
ConfigurationClass(MetadataReader metadataReader, String beanName) {
|
||||
public ConfigurationClass(MetadataReader metadataReader, String beanName) {
|
||||
Assert.notNull(beanName, "Bean name must not be null");
|
||||
this.metadata = metadataReader.getAnnotationMetadata();
|
||||
this.resource = metadataReader.getResource();
|
||||
@@ -89,7 +89,7 @@ final class ConfigurationClass {
|
||||
* @param importedBy the configuration class importing this one or {@code null}
|
||||
* @since 3.1.1
|
||||
*/
|
||||
ConfigurationClass(MetadataReader metadataReader, @Nullable ConfigurationClass importedBy) {
|
||||
public ConfigurationClass(MetadataReader metadataReader, @Nullable ConfigurationClass importedBy) {
|
||||
this.metadata = metadataReader.getAnnotationMetadata();
|
||||
this.resource = metadataReader.getResource();
|
||||
this.importedBy.add(importedBy);
|
||||
@@ -101,7 +101,7 @@ final class ConfigurationClass {
|
||||
* @param beanName name of the {@code @Configuration} class bean
|
||||
* @see ConfigurationClass#ConfigurationClass(Class, ConfigurationClass)
|
||||
*/
|
||||
ConfigurationClass(Class<?> clazz, String beanName) {
|
||||
public ConfigurationClass(Class<?> clazz, String beanName) {
|
||||
Assert.notNull(beanName, "Bean name must not be null");
|
||||
this.metadata = AnnotationMetadata.introspect(clazz);
|
||||
this.resource = new DescriptiveResource(clazz.getName());
|
||||
@@ -116,7 +116,7 @@ final class ConfigurationClass {
|
||||
* @param importedBy the configuration class importing this one (or {@code null})
|
||||
* @since 3.1.1
|
||||
*/
|
||||
ConfigurationClass(Class<?> clazz, @Nullable ConfigurationClass importedBy) {
|
||||
public ConfigurationClass(Class<?> clazz, @Nullable ConfigurationClass importedBy) {
|
||||
this.metadata = AnnotationMetadata.introspect(clazz);
|
||||
this.resource = new DescriptiveResource(clazz.getName());
|
||||
this.importedBy.add(importedBy);
|
||||
@@ -128,7 +128,7 @@ final class ConfigurationClass {
|
||||
* @param beanName name of the {@code @Configuration} class bean
|
||||
* @see ConfigurationClass#ConfigurationClass(Class, ConfigurationClass)
|
||||
*/
|
||||
ConfigurationClass(AnnotationMetadata metadata, String beanName) {
|
||||
public ConfigurationClass(AnnotationMetadata metadata, String beanName) {
|
||||
Assert.notNull(beanName, "Bean name must not be null");
|
||||
this.metadata = metadata;
|
||||
this.resource = new DescriptiveResource(metadata.getClassName());
|
||||
@@ -136,19 +136,19 @@ final class ConfigurationClass {
|
||||
}
|
||||
|
||||
|
||||
AnnotationMetadata getMetadata() {
|
||||
public AnnotationMetadata getMetadata() {
|
||||
return this.metadata;
|
||||
}
|
||||
|
||||
Resource getResource() {
|
||||
public Resource getResource() {
|
||||
return this.resource;
|
||||
}
|
||||
|
||||
String getSimpleName() {
|
||||
public String getSimpleName() {
|
||||
return ClassUtils.getShortName(getMetadata().getClassName());
|
||||
}
|
||||
|
||||
void setBeanName(String beanName) {
|
||||
public void setBeanName(String beanName) {
|
||||
this.beanName = beanName;
|
||||
}
|
||||
|
||||
@@ -171,7 +171,7 @@ final class ConfigurationClass {
|
||||
* Merge the imported-by declarations from the given configuration class into this one.
|
||||
* @since 4.0.5
|
||||
*/
|
||||
void mergeImportedBy(ConfigurationClass otherConfigClass) {
|
||||
public void mergeImportedBy(ConfigurationClass otherConfigClass) {
|
||||
this.importedBy.addAll(otherConfigClass.importedBy);
|
||||
}
|
||||
|
||||
@@ -181,35 +181,35 @@ final class ConfigurationClass {
|
||||
* @since 4.0.5
|
||||
* @see #isImported()
|
||||
*/
|
||||
Set<ConfigurationClass> getImportedBy() {
|
||||
public Set<ConfigurationClass> getImportedBy() {
|
||||
return this.importedBy;
|
||||
}
|
||||
|
||||
void addBeanMethod(BeanMethod method) {
|
||||
public void addBeanMethod(BeanMethod method) {
|
||||
this.beanMethods.add(method);
|
||||
}
|
||||
|
||||
Set<BeanMethod> getBeanMethods() {
|
||||
public Set<BeanMethod> getBeanMethods() {
|
||||
return this.beanMethods;
|
||||
}
|
||||
|
||||
void addImportedResource(String importedResource, Class<? extends BeanDefinitionReader> readerClass) {
|
||||
public void addImportedResource(String importedResource, Class<? extends BeanDefinitionReader> readerClass) {
|
||||
this.importedResources.put(importedResource, readerClass);
|
||||
}
|
||||
|
||||
void addImportBeanDefinitionRegistrar(ImportBeanDefinitionRegistrar registrar, AnnotationMetadata importingClassMetadata) {
|
||||
public void addImportBeanDefinitionRegistrar(ImportBeanDefinitionRegistrar registrar, AnnotationMetadata importingClassMetadata) {
|
||||
this.importBeanDefinitionRegistrars.put(registrar, importingClassMetadata);
|
||||
}
|
||||
|
||||
Map<ImportBeanDefinitionRegistrar, AnnotationMetadata> getImportBeanDefinitionRegistrars() {
|
||||
public Map<ImportBeanDefinitionRegistrar, AnnotationMetadata> getImportBeanDefinitionRegistrars() {
|
||||
return this.importBeanDefinitionRegistrars;
|
||||
}
|
||||
|
||||
Map<String, Class<? extends BeanDefinitionReader>> getImportedResources() {
|
||||
public Map<String, Class<? extends BeanDefinitionReader>> getImportedResources() {
|
||||
return this.importedResources;
|
||||
}
|
||||
|
||||
void validate(ProblemReporter problemReporter) {
|
||||
public void validate(ProblemReporter problemReporter) {
|
||||
// A configuration class may not be final (CGLIB limitation) unless it declares proxyBeanMethods=false
|
||||
Map<String, Object> attributes = this.metadata.getAnnotationAttributes(Configuration.class.getName());
|
||||
if (attributes != null && (Boolean) attributes.get("proxyBeanMethods")) {
|
||||
@@ -244,7 +244,7 @@ final class ConfigurationClass {
|
||||
*/
|
||||
private class FinalConfigurationProblem extends Problem {
|
||||
|
||||
FinalConfigurationProblem() {
|
||||
public FinalConfigurationProblem() {
|
||||
super(String.format("@Configuration class '%s' may not be final. Remove the final modifier to continue.",
|
||||
getSimpleName()), new Location(getResource(), getMetadata()));
|
||||
}
|
||||
|
||||
+11
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -51,9 +51,18 @@ abstract class ConfigurationMethod {
|
||||
return new Location(this.configurationClass.getResource(), this.metadata);
|
||||
}
|
||||
|
||||
void validate(ProblemReporter problemReporter) {
|
||||
String getFullyQualifiedMethodName() {
|
||||
return this.metadata.getDeclaringClassName() + "#" + this.metadata.getMethodName();
|
||||
}
|
||||
|
||||
static String getShortMethodName(String fullyQualifiedMethodName) {
|
||||
return fullyQualifiedMethodName.substring(fullyQualifiedMethodName.indexOf('#') + 1);
|
||||
}
|
||||
|
||||
public void validate(ProblemReporter problemReporter) {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("[%s:name=%s,declaringClass=%s]",
|
||||
|
||||
+2
-2
@@ -396,7 +396,7 @@ public class ApplicationListenerMethodAdapter implements GenericApplicationListe
|
||||
* @param message error message to append the HandlerMethod details to
|
||||
*/
|
||||
protected String getDetailedErrorMessage(Object bean, String message) {
|
||||
StringBuilder sb = new StringBuilder(message).append('\n');
|
||||
StringBuilder sb = new StringBuilder(message).append("\n");
|
||||
sb.append("HandlerMethod details: \n");
|
||||
sb.append("Bean [").append(bean.getClass().getName()).append("]\n");
|
||||
sb.append("Method [").append(this.method.toGenericString()).append("]\n");
|
||||
@@ -426,7 +426,7 @@ public class ApplicationListenerMethodAdapter implements GenericApplicationListe
|
||||
StringBuilder sb = new StringBuilder(getDetailedErrorMessage(bean, message));
|
||||
sb.append("Resolved arguments: \n");
|
||||
for (int i = 0; i < resolvedArgs.length; i++) {
|
||||
sb.append('[').append(i).append("] ");
|
||||
sb.append("[").append(i).append("] ");
|
||||
if (resolvedArgs[i] == null) {
|
||||
sb.append("[null] \n");
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2020 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.
|
||||
@@ -205,12 +205,12 @@ public class LiveBeansView implements LiveBeansViewMBean, ApplicationContextAwar
|
||||
}
|
||||
}
|
||||
result.append("]\n");
|
||||
result.append('}');
|
||||
result.append("}");
|
||||
if (it.hasNext()) {
|
||||
result.append(",\n");
|
||||
}
|
||||
}
|
||||
result.append(']');
|
||||
result.append("]");
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -112,10 +112,10 @@ public class ThreadPoolTaskExecutor extends ExecutorConfigurationSupport
|
||||
*/
|
||||
public void setCorePoolSize(int corePoolSize) {
|
||||
synchronized (this.poolSizeMonitor) {
|
||||
this.corePoolSize = corePoolSize;
|
||||
if (this.threadPoolExecutor != null) {
|
||||
this.threadPoolExecutor.setCorePoolSize(corePoolSize);
|
||||
}
|
||||
this.corePoolSize = corePoolSize;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,10 +135,10 @@ public class ThreadPoolTaskExecutor extends ExecutorConfigurationSupport
|
||||
*/
|
||||
public void setMaxPoolSize(int maxPoolSize) {
|
||||
synchronized (this.poolSizeMonitor) {
|
||||
this.maxPoolSize = maxPoolSize;
|
||||
if (this.threadPoolExecutor != null) {
|
||||
this.threadPoolExecutor.setMaximumPoolSize(maxPoolSize);
|
||||
}
|
||||
this.maxPoolSize = maxPoolSize;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,10 +158,10 @@ public class ThreadPoolTaskExecutor extends ExecutorConfigurationSupport
|
||||
*/
|
||||
public void setKeepAliveSeconds(int keepAliveSeconds) {
|
||||
synchronized (this.poolSizeMonitor) {
|
||||
this.keepAliveSeconds = keepAliveSeconds;
|
||||
if (this.threadPoolExecutor != null) {
|
||||
this.threadPoolExecutor.setKeepAliveTime(keepAliveSeconds, TimeUnit.SECONDS);
|
||||
}
|
||||
this.keepAliveSeconds = keepAliveSeconds;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+25
-66
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2020 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.
|
||||
@@ -53,8 +53,6 @@ import org.springframework.util.concurrent.ListenableFutureTask;
|
||||
* @since 3.0
|
||||
* @see #setPoolSize
|
||||
* @see #setRemoveOnCancelPolicy
|
||||
* @see #setContinueExistingPeriodicTasksAfterShutdownPolicy
|
||||
* @see #setExecuteExistingDelayedTasksAfterShutdownPolicy
|
||||
* @see #setThreadFactory
|
||||
* @see #setErrorHandler
|
||||
*/
|
||||
@@ -66,10 +64,6 @@ public class ThreadPoolTaskScheduler extends ExecutorConfigurationSupport
|
||||
|
||||
private volatile boolean removeOnCancelPolicy;
|
||||
|
||||
private volatile boolean continueExistingPeriodicTasksAfterShutdownPolicy;
|
||||
|
||||
private volatile boolean executeExistingDelayedTasksAfterShutdownPolicy = true;
|
||||
|
||||
@Nullable
|
||||
private volatile ErrorHandler errorHandler;
|
||||
|
||||
@@ -90,54 +84,26 @@ public class ThreadPoolTaskScheduler extends ExecutorConfigurationSupport
|
||||
*/
|
||||
public void setPoolSize(int poolSize) {
|
||||
Assert.isTrue(poolSize > 0, "'poolSize' must be 1 or higher");
|
||||
this.poolSize = poolSize;
|
||||
if (this.scheduledExecutor instanceof ScheduledThreadPoolExecutor) {
|
||||
((ScheduledThreadPoolExecutor) this.scheduledExecutor).setCorePoolSize(poolSize);
|
||||
}
|
||||
this.poolSize = poolSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the remove-on-cancel mode on {@link ScheduledThreadPoolExecutor}.
|
||||
* <p>Default is {@code false}. If set to {@code true}, the target executor will be
|
||||
* switched into remove-on-cancel mode (if possible).
|
||||
* switched into remove-on-cancel mode (if possible, with a soft fallback otherwise).
|
||||
* <p><b>This setting can be modified at runtime, for example through JMX.</b>
|
||||
* @see ScheduledThreadPoolExecutor#setRemoveOnCancelPolicy
|
||||
*/
|
||||
public void setRemoveOnCancelPolicy(boolean flag) {
|
||||
public void setRemoveOnCancelPolicy(boolean removeOnCancelPolicy) {
|
||||
this.removeOnCancelPolicy = removeOnCancelPolicy;
|
||||
if (this.scheduledExecutor instanceof ScheduledThreadPoolExecutor) {
|
||||
((ScheduledThreadPoolExecutor) this.scheduledExecutor).setRemoveOnCancelPolicy(flag);
|
||||
((ScheduledThreadPoolExecutor) this.scheduledExecutor).setRemoveOnCancelPolicy(removeOnCancelPolicy);
|
||||
}
|
||||
this.removeOnCancelPolicy = flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether to continue existing periodic tasks even when this executor has been shutdown.
|
||||
* <p>Default is {@code false}. If set to {@code true}, the target executor will be
|
||||
* switched into continuing periodic tasks (if possible).
|
||||
* <p><b>This setting can be modified at runtime, for example through JMX.</b>
|
||||
* @since 5.3.9
|
||||
* @see ScheduledThreadPoolExecutor#setContinueExistingPeriodicTasksAfterShutdownPolicy
|
||||
*/
|
||||
public void setContinueExistingPeriodicTasksAfterShutdownPolicy(boolean flag) {
|
||||
if (this.scheduledExecutor instanceof ScheduledThreadPoolExecutor) {
|
||||
((ScheduledThreadPoolExecutor) this.scheduledExecutor).setContinueExistingPeriodicTasksAfterShutdownPolicy(flag);
|
||||
else if (removeOnCancelPolicy && this.scheduledExecutor != null) {
|
||||
logger.debug("Could not apply remove-on-cancel policy - not a ScheduledThreadPoolExecutor");
|
||||
}
|
||||
this.continueExistingPeriodicTasksAfterShutdownPolicy = flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether to execute existing delayed tasks even when this executor has been shutdown.
|
||||
* <p>Default is {@code true}. If set to {@code false}, the target executor will be
|
||||
* switched into dropping remaining tasks (if possible).
|
||||
* <p><b>This setting can be modified at runtime, for example through JMX.</b>
|
||||
* @since 5.3.9
|
||||
* @see ScheduledThreadPoolExecutor#setExecuteExistingDelayedTasksAfterShutdownPolicy
|
||||
*/
|
||||
public void setExecuteExistingDelayedTasksAfterShutdownPolicy(boolean flag) {
|
||||
if (this.scheduledExecutor instanceof ScheduledThreadPoolExecutor) {
|
||||
((ScheduledThreadPoolExecutor) this.scheduledExecutor).setExecuteExistingDelayedTasksAfterShutdownPolicy(flag);
|
||||
}
|
||||
this.executeExistingDelayedTasksAfterShutdownPolicy = flag;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -169,16 +135,12 @@ public class ThreadPoolTaskScheduler extends ExecutorConfigurationSupport
|
||||
|
||||
this.scheduledExecutor = createExecutor(this.poolSize, threadFactory, rejectedExecutionHandler);
|
||||
|
||||
if (this.scheduledExecutor instanceof ScheduledThreadPoolExecutor) {
|
||||
ScheduledThreadPoolExecutor scheduledPoolExecutor = (ScheduledThreadPoolExecutor) this.scheduledExecutor;
|
||||
if (this.removeOnCancelPolicy) {
|
||||
scheduledPoolExecutor.setRemoveOnCancelPolicy(true);
|
||||
if (this.removeOnCancelPolicy) {
|
||||
if (this.scheduledExecutor instanceof ScheduledThreadPoolExecutor) {
|
||||
((ScheduledThreadPoolExecutor) this.scheduledExecutor).setRemoveOnCancelPolicy(true);
|
||||
}
|
||||
if (this.continueExistingPeriodicTasksAfterShutdownPolicy) {
|
||||
scheduledPoolExecutor.setContinueExistingPeriodicTasksAfterShutdownPolicy(true);
|
||||
}
|
||||
if (!this.executeExistingDelayedTasksAfterShutdownPolicy) {
|
||||
scheduledPoolExecutor.setExecuteExistingDelayedTasksAfterShutdownPolicy(false);
|
||||
else {
|
||||
logger.debug("Could not apply remove-on-cancel policy - not a ScheduledThreadPoolExecutor");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,6 +201,18 @@ public class ThreadPoolTaskScheduler extends ExecutorConfigurationSupport
|
||||
return getScheduledThreadPoolExecutor().getPoolSize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the current setting for the remove-on-cancel mode.
|
||||
* <p>Requires an underlying {@link ScheduledThreadPoolExecutor}.
|
||||
*/
|
||||
public boolean isRemoveOnCancelPolicy() {
|
||||
if (this.scheduledExecutor == null) {
|
||||
// Not initialized yet: return our setting for the time being.
|
||||
return this.removeOnCancelPolicy;
|
||||
}
|
||||
return getScheduledThreadPoolExecutor().getRemoveOnCancelPolicy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the number of currently active threads.
|
||||
* <p>Requires an underlying {@link ScheduledThreadPoolExecutor}.
|
||||
@@ -253,21 +227,6 @@ public class ThreadPoolTaskScheduler extends ExecutorConfigurationSupport
|
||||
return getScheduledThreadPoolExecutor().getActiveCount();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the current setting for the remove-on-cancel mode.
|
||||
* <p>Requires an underlying {@link ScheduledThreadPoolExecutor}.
|
||||
* @deprecated as of 5.3.9, in favor of direct
|
||||
* {@link #getScheduledThreadPoolExecutor()} access
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isRemoveOnCancelPolicy() {
|
||||
if (this.scheduledExecutor == null) {
|
||||
// Not initialized yet: return our setting for the time being.
|
||||
return this.removeOnCancelPolicy;
|
||||
}
|
||||
return getScheduledThreadPoolExecutor().getRemoveOnCancelPolicy();
|
||||
}
|
||||
|
||||
|
||||
// SchedulingTaskExecutor implementation
|
||||
|
||||
|
||||
+1
-2
@@ -66,9 +66,8 @@ public final class CronExpression {
|
||||
CronField daysOfWeek,
|
||||
String expression) {
|
||||
|
||||
// reverse order, to make big changes first
|
||||
// to make sure we end up at 0 nanos, we add an extra field
|
||||
this.fields = new CronField[]{daysOfWeek, months, daysOfMonth, hours, minutes, seconds, CronField.zeroNanos()};
|
||||
this.fields = new CronField[]{CronField.zeroNanos(), seconds, minutes, hours, daysOfMonth, months, daysOfWeek};
|
||||
this.expression = expression;
|
||||
}
|
||||
|
||||
|
||||
@@ -230,7 +230,9 @@ abstract class CronField {
|
||||
* Elapse the given temporal for the difference between the current
|
||||
* value of this field and the goal value. Typically, the returned
|
||||
* temporal will have the given goal as the current value for this type,
|
||||
* but this is not the case for {@link #DAY_OF_MONTH}.
|
||||
* but this is not the case for {@link #DAY_OF_MONTH}. For instance,
|
||||
* if {@code goal} is 31, and {@code temporal} is April 16th,
|
||||
* this method returns May 1st, because April 31st does not exist.
|
||||
* @param temporal the temporal to elapse
|
||||
* @param goal the goal value
|
||||
* @param <T> the type of temporal
|
||||
@@ -245,9 +247,8 @@ abstract class CronField {
|
||||
return cast(temporal.with(this.field, goal));
|
||||
}
|
||||
else {
|
||||
// goal is invalid, eg. 29th Feb, so roll forward
|
||||
long amount = range.getMaximum() - current + 1;
|
||||
return this.field.getBaseUnit().addTo(temporal, amount);
|
||||
// goal is invalid, eg. 29th Feb, lets try to get as close as possible
|
||||
return this.field.getBaseUnit().addTo(temporal, goal - current);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
-3
@@ -334,9 +334,6 @@ final class QuartzCronField extends CronField {
|
||||
// We ended up before the start, roll forward and try again
|
||||
temporal = this.rollForwardType.rollForward(temporal);
|
||||
result = adjust(temporal);
|
||||
if (result != null) {
|
||||
result = type().reset(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -1110,7 +1110,7 @@ open class BeanDefinitionDsl internal constructor (private val init: BeanDefinit
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a provider for the specified bean, allowing for lazy on-demand retrieval
|
||||
* Return an provider for the specified bean, allowing for lazy on-demand retrieval
|
||||
* of instances, including availability and uniqueness options.
|
||||
* @see org.springframework.beans.factory.BeanFactory.getBeanProvider
|
||||
*/
|
||||
|
||||
+5
-21
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -28,7 +28,6 @@ import org.junit.jupiter.api.Test;
|
||||
import org.springframework.aop.TargetSource;
|
||||
import org.springframework.aop.framework.ProxyFactory;
|
||||
import org.springframework.aop.support.AopUtils;
|
||||
import org.springframework.aop.support.DefaultIntroductionAdvisor;
|
||||
import org.springframework.aop.target.SingletonTargetSource;
|
||||
import org.springframework.beans.MutablePropertyValues;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
@@ -220,7 +219,7 @@ public class AutoProxyCreatorTests {
|
||||
|
||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||
pvs.add("proxyFactoryBean", "false");
|
||||
sac.registerSingleton("testAutoProxyCreator", IntroductionTestAutoProxyCreator.class, pvs);
|
||||
sac.registerSingleton("testAutoProxyCreator", TestAutoProxyCreator.class, pvs);
|
||||
|
||||
sac.registerSingleton("noInterfaces", NoInterfaces.class);
|
||||
sac.registerSingleton("containerCallbackInterfacesOnly", ContainerCallbackInterfacesOnly.class);
|
||||
@@ -249,9 +248,9 @@ public class AutoProxyCreatorTests {
|
||||
singletonNoInterceptor.getName();
|
||||
assertThat(tapc.testInterceptor.nrOfInvocations).isEqualTo(0);
|
||||
singletonToBeProxied.getAge();
|
||||
assertThat(tapc.testInterceptor.nrOfInvocations).isEqualTo(2);
|
||||
assertThat(tapc.testInterceptor.nrOfInvocations).isEqualTo(1);
|
||||
prototypeToBeProxied.getSpouse();
|
||||
assertThat(tapc.testInterceptor.nrOfInvocations).isEqualTo(4);
|
||||
assertThat(tapc.testInterceptor.nrOfInvocations).isEqualTo(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -405,7 +404,7 @@ public class AutoProxyCreatorTests {
|
||||
else if (name.endsWith("ToBeProxied")) {
|
||||
boolean isFactoryBean = FactoryBean.class.isAssignableFrom(beanClass);
|
||||
if ((this.proxyFactoryBean && isFactoryBean) || (this.proxyObject && !isFactoryBean)) {
|
||||
return getAdvicesAndAdvisors();
|
||||
return new Object[] {this.testInterceptor};
|
||||
}
|
||||
else {
|
||||
return DO_NOT_PROXY;
|
||||
@@ -415,10 +414,6 @@ public class AutoProxyCreatorTests {
|
||||
return PROXY_WITHOUT_ADDITIONAL_INTERCEPTORS;
|
||||
}
|
||||
}
|
||||
|
||||
protected Object[] getAdvicesAndAdvisors() {
|
||||
return new Object[] {this.testInterceptor};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -431,17 +426,6 @@ public class AutoProxyCreatorTests {
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public static class IntroductionTestAutoProxyCreator extends TestAutoProxyCreator {
|
||||
|
||||
protected Object[] getAdvicesAndAdvisors() {
|
||||
DefaultIntroductionAdvisor advisor = new DefaultIntroductionAdvisor(this.testInterceptor);
|
||||
advisor.addInterface(Serializable.class);
|
||||
return new Object[] {this.testInterceptor, advisor};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Interceptor that counts the number of non-finalize method calls.
|
||||
*/
|
||||
|
||||
+2
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -47,9 +47,8 @@ import static org.springframework.util.ClassUtils.convertClassNameToResourcePath
|
||||
public class QualifierAnnotationTests {
|
||||
|
||||
private static final String CLASSNAME = QualifierAnnotationTests.class.getName();
|
||||
|
||||
private static final String CONFIG_LOCATION =
|
||||
format("classpath:%s-context.xml", convertClassNameToResourcePath(CLASSNAME));
|
||||
format("classpath:%s-context.xml", convertClassNameToResourcePath(CLASSNAME));
|
||||
|
||||
|
||||
@Test
|
||||
|
||||
+1
-1
@@ -146,7 +146,7 @@ class XmlBeanFactoryTests {
|
||||
assertThat(emmasJenks != georgiasJenks).as("Emma and georgia think they have a different boyfriend").isTrue();
|
||||
assertThat(emmasJenks.getName().equals("Andrew")).as("Emmas jenks has right name").isTrue();
|
||||
assertThat(emmasJenks != xbf.getBean("jenks")).as("Emmas doesn't equal new ref").isTrue();
|
||||
assertThat(georgiasJenks.getName().equals("Andrew")).as("Georgias jenks has right name").isTrue();
|
||||
assertThat(emmasJenks.getName().equals("Andrew")).as("Georgias jenks has right name").isTrue();
|
||||
assertThat(emmasJenks.equals(georgiasJenks)).as("They are object equal").isTrue();
|
||||
assertThat(emmasJenks.equals(xbf.getBean("jenks"))).as("They object equal direct ref").isTrue();
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -29,7 +29,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests regarding overloading and overriding of bean methods.
|
||||
* <p>Related to SPR-6618.
|
||||
* Related to SPR-6618.
|
||||
*
|
||||
* @author Chris Beams
|
||||
* @author Phillip Webb
|
||||
@@ -41,7 +41,7 @@ public class BeanMethodPolymorphismTests {
|
||||
@Test
|
||||
public void beanMethodDetectedOnSuperClass() {
|
||||
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(Config.class);
|
||||
assertThat(ctx.getBean("testBean", TestBean.class)).isNotNull();
|
||||
ctx.getBean("testBean", TestBean.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
-202
@@ -1,202 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-2021 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.context.annotation;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.parsing.FailFastProblemReporter;
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
import org.springframework.core.env.StandardEnvironment;
|
||||
import org.springframework.core.io.DefaultResourceLoader;
|
||||
import org.springframework.core.type.classreading.CachingMetadataReaderFactory;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link ConfigurationClassParser}, {@link ConfigurationClass},
|
||||
* and {@link BeanMethod}.
|
||||
*
|
||||
* @author Sam Brannen
|
||||
* @since 5.3.9
|
||||
*/
|
||||
class ConfigurationClassAndBeanMethodTests {
|
||||
|
||||
@Test
|
||||
void verifyEquals() throws Exception {
|
||||
ConfigurationClass configurationClass1 = newConfigurationClass(Config1.class);
|
||||
ConfigurationClass configurationClass2 = newConfigurationClass(Config1.class);
|
||||
ConfigurationClass configurationClass3 = newConfigurationClass(Config2.class);
|
||||
|
||||
assertThat(configurationClass1.equals(null)).isFalse();
|
||||
assertThat(configurationClass1).isNotSameAs(configurationClass2);
|
||||
|
||||
assertThat(configurationClass1.equals(configurationClass1)).isTrue();
|
||||
assertThat(configurationClass2.equals(configurationClass2)).isTrue();
|
||||
assertThat(configurationClass1.equals(configurationClass2)).isTrue();
|
||||
assertThat(configurationClass2.equals(configurationClass1)).isTrue();
|
||||
|
||||
assertThat(configurationClass1.equals(configurationClass3)).isFalse();
|
||||
assertThat(configurationClass3.equals(configurationClass2)).isFalse();
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
List<BeanMethod> beanMethods1 = getBeanMethods(configurationClass1);
|
||||
BeanMethod beanMethod_1_0 = beanMethods1.get(0);
|
||||
BeanMethod beanMethod_1_1 = beanMethods1.get(1);
|
||||
BeanMethod beanMethod_1_2 = beanMethods1.get(2);
|
||||
|
||||
List<BeanMethod> beanMethods2 = getBeanMethods(configurationClass2);
|
||||
BeanMethod beanMethod_2_0 = beanMethods2.get(0);
|
||||
BeanMethod beanMethod_2_1 = beanMethods2.get(1);
|
||||
BeanMethod beanMethod_2_2 = beanMethods2.get(2);
|
||||
|
||||
List<BeanMethod> beanMethods3 = getBeanMethods(configurationClass3);
|
||||
BeanMethod beanMethod_3_0 = beanMethods3.get(0);
|
||||
BeanMethod beanMethod_3_1 = beanMethods3.get(1);
|
||||
BeanMethod beanMethod_3_2 = beanMethods3.get(2);
|
||||
|
||||
assertThat(beanMethod_1_0.equals(null)).isFalse();
|
||||
assertThat(beanMethod_1_0).isNotSameAs(beanMethod_2_0);
|
||||
|
||||
assertThat(beanMethod_1_0.equals(beanMethod_1_0)).isTrue();
|
||||
assertThat(beanMethod_1_0.equals(beanMethod_2_0)).isTrue();
|
||||
assertThat(beanMethod_1_1.equals(beanMethod_2_1)).isTrue();
|
||||
assertThat(beanMethod_1_2.equals(beanMethod_2_2)).isTrue();
|
||||
|
||||
assertThat(beanMethod_1_0.getMetadata().getMethodName()).isEqualTo(beanMethod_3_0.getMetadata().getMethodName());
|
||||
assertThat(beanMethod_1_0.equals(beanMethod_3_0)).isFalse();
|
||||
assertThat(beanMethod_1_1.equals(beanMethod_3_1)).isFalse();
|
||||
assertThat(beanMethod_1_2.equals(beanMethod_3_2)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
void verifyHashCode() throws Exception {
|
||||
ConfigurationClass configurationClass1 = newConfigurationClass(Config1.class);
|
||||
ConfigurationClass configurationClass2 = newConfigurationClass(Config1.class);
|
||||
ConfigurationClass configurationClass3 = newConfigurationClass(Config2.class);
|
||||
|
||||
assertThat(configurationClass1).hasSameHashCodeAs(configurationClass2);
|
||||
assertThat(configurationClass1).doesNotHaveSameHashCodeAs(configurationClass3);
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
List<BeanMethod> beanMethods1 = getBeanMethods(configurationClass1);
|
||||
BeanMethod beanMethod_1_0 = beanMethods1.get(0);
|
||||
BeanMethod beanMethod_1_1 = beanMethods1.get(1);
|
||||
BeanMethod beanMethod_1_2 = beanMethods1.get(2);
|
||||
|
||||
List<BeanMethod> beanMethods2 = getBeanMethods(configurationClass2);
|
||||
BeanMethod beanMethod_2_0 = beanMethods2.get(0);
|
||||
BeanMethod beanMethod_2_1 = beanMethods2.get(1);
|
||||
BeanMethod beanMethod_2_2 = beanMethods2.get(2);
|
||||
|
||||
List<BeanMethod> beanMethods3 = getBeanMethods(configurationClass3);
|
||||
BeanMethod beanMethod_3_0 = beanMethods3.get(0);
|
||||
BeanMethod beanMethod_3_1 = beanMethods3.get(1);
|
||||
BeanMethod beanMethod_3_2 = beanMethods3.get(2);
|
||||
|
||||
assertThat(beanMethod_1_0).hasSameHashCodeAs(beanMethod_2_0);
|
||||
assertThat(beanMethod_1_1).hasSameHashCodeAs(beanMethod_2_1);
|
||||
assertThat(beanMethod_1_2).hasSameHashCodeAs(beanMethod_2_2);
|
||||
|
||||
assertThat(beanMethod_1_0).doesNotHaveSameHashCodeAs(beanMethod_3_0);
|
||||
assertThat(beanMethod_1_1).doesNotHaveSameHashCodeAs(beanMethod_3_1);
|
||||
assertThat(beanMethod_1_2).doesNotHaveSameHashCodeAs(beanMethod_3_2);
|
||||
}
|
||||
|
||||
@Test
|
||||
void verifyToString() throws Exception {
|
||||
ConfigurationClass configurationClass = newConfigurationClass(Config1.class);
|
||||
assertThat(configurationClass.toString())
|
||||
.startsWith("ConfigurationClass: beanName 'Config1', class path resource");
|
||||
|
||||
List<BeanMethod> beanMethods = getBeanMethods(configurationClass);
|
||||
String prefix = "BeanMethod: " + Config1.class.getName();
|
||||
assertThat(beanMethods.get(0).toString()).isEqualTo(prefix + ".bean0()");
|
||||
assertThat(beanMethods.get(1).toString()).isEqualTo(prefix + ".bean1(java.lang.String)");
|
||||
assertThat(beanMethods.get(2).toString()).isEqualTo(prefix + ".bean2(java.lang.String,java.lang.Integer)");
|
||||
}
|
||||
|
||||
|
||||
private static ConfigurationClass newConfigurationClass(Class<?> clazz) throws Exception {
|
||||
ConfigurationClassParser parser = newParser();
|
||||
parser.parse(clazz.getName(), clazz.getSimpleName());
|
||||
assertThat(parser.getConfigurationClasses()).hasSize(1);
|
||||
return parser.getConfigurationClasses().iterator().next();
|
||||
}
|
||||
|
||||
private static ConfigurationClassParser newParser() {
|
||||
return new ConfigurationClassParser(
|
||||
new CachingMetadataReaderFactory(),
|
||||
new FailFastProblemReporter(),
|
||||
new StandardEnvironment(),
|
||||
new DefaultResourceLoader(),
|
||||
new AnnotationBeanNameGenerator(),
|
||||
new DefaultListableBeanFactory());
|
||||
}
|
||||
|
||||
private static List<BeanMethod> getBeanMethods(ConfigurationClass configurationClass) {
|
||||
List<BeanMethod> beanMethods = configurationClass.getBeanMethods().stream()
|
||||
.sorted(Comparator.comparing(beanMethod -> beanMethod.getMetadata().getMethodName()))
|
||||
.collect(Collectors.toList());
|
||||
assertThat(beanMethods).hasSize(3);
|
||||
return beanMethods;
|
||||
}
|
||||
|
||||
static class Config1 {
|
||||
|
||||
@Bean
|
||||
String bean0() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Bean
|
||||
String bean1(String text) {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Bean
|
||||
String bean2(String text, Integer num) {
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static class Config2 {
|
||||
|
||||
@Bean
|
||||
String bean0() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Bean
|
||||
String bean1(String text) {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Bean
|
||||
String bean2(String text, Integer num) {
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+2
-81
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2020 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.
|
||||
@@ -16,100 +16,21 @@
|
||||
|
||||
package org.springframework.scheduling.concurrent;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.core.task.AsyncListenableTaskExecutor;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
|
||||
/**
|
||||
* @author Juergen Hoeller
|
||||
* @since 5.0.5
|
||||
*/
|
||||
class ThreadPoolTaskExecutorTests extends AbstractSchedulingTaskExecutorTests {
|
||||
|
||||
private final ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
||||
|
||||
|
||||
@Override
|
||||
protected AsyncListenableTaskExecutor buildExecutor() {
|
||||
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
||||
executor.setThreadNamePrefix(this.threadNamePrefix);
|
||||
executor.setMaxPoolSize(1);
|
||||
executor.afterPropertiesSet();
|
||||
return executor;
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void modifyCorePoolSizeWhileRunning() {
|
||||
assertThat(executor.getCorePoolSize()).isEqualTo(1);
|
||||
assertThat(executor.getThreadPoolExecutor().getCorePoolSize()).isEqualTo(1);
|
||||
|
||||
executor.setCorePoolSize(0);
|
||||
|
||||
assertThat(executor.getCorePoolSize()).isEqualTo(0);
|
||||
assertThat(executor.getThreadPoolExecutor().getCorePoolSize()).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
void modifyCorePoolSizeWithInvalidValueWhileRunning() {
|
||||
assertThat(executor.getCorePoolSize()).isEqualTo(1);
|
||||
assertThat(executor.getThreadPoolExecutor().getCorePoolSize()).isEqualTo(1);
|
||||
|
||||
assertThatThrownBy(() -> executor.setCorePoolSize(-1))
|
||||
.isInstanceOf(IllegalArgumentException.class);
|
||||
|
||||
assertThat(executor.getCorePoolSize()).isEqualTo(1);
|
||||
assertThat(executor.getThreadPoolExecutor().getCorePoolSize()).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
void modifyMaxPoolSizeWhileRunning() {
|
||||
assertThat(executor.getMaxPoolSize()).isEqualTo(1);
|
||||
assertThat(executor.getThreadPoolExecutor().getMaximumPoolSize()).isEqualTo(1);
|
||||
|
||||
executor.setMaxPoolSize(5);
|
||||
|
||||
assertThat(executor.getMaxPoolSize()).isEqualTo(5);
|
||||
assertThat(executor.getThreadPoolExecutor().getMaximumPoolSize()).isEqualTo(5);
|
||||
}
|
||||
|
||||
@Test
|
||||
void modifyMaxPoolSizeWithInvalidValueWhileRunning() {
|
||||
assertThat(executor.getMaxPoolSize()).isEqualTo(1);
|
||||
assertThat(executor.getThreadPoolExecutor().getMaximumPoolSize()).isEqualTo(1);
|
||||
|
||||
assertThatThrownBy(() -> executor.setMaxPoolSize(0))
|
||||
.isInstanceOf(IllegalArgumentException.class);
|
||||
|
||||
assertThat(executor.getMaxPoolSize()).isEqualTo(1);
|
||||
assertThat(executor.getThreadPoolExecutor().getMaximumPoolSize()).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
void modifyKeepAliveSecondsWhileRunning() {
|
||||
assertThat(executor.getKeepAliveSeconds()).isEqualTo(60);
|
||||
assertThat(executor.getThreadPoolExecutor().getKeepAliveTime(TimeUnit.SECONDS)).isEqualTo(60);
|
||||
|
||||
executor.setKeepAliveSeconds(10);
|
||||
|
||||
assertThat(executor.getKeepAliveSeconds()).isEqualTo(10);
|
||||
assertThat(executor.getThreadPoolExecutor().getKeepAliveTime(TimeUnit.SECONDS)).isEqualTo(10);
|
||||
}
|
||||
|
||||
@Test
|
||||
void modifyKeepAliveSecondsWithInvalidValueWhileRunning() {
|
||||
assertThat(executor.getKeepAliveSeconds()).isEqualTo(60);
|
||||
assertThat(executor.getThreadPoolExecutor().getKeepAliveTime(TimeUnit.SECONDS)).isEqualTo(60);
|
||||
|
||||
assertThatThrownBy(() -> executor.setKeepAliveSeconds(-10))
|
||||
.isInstanceOf(IllegalArgumentException.class);
|
||||
|
||||
assertThat(executor.getKeepAliveSeconds()).isEqualTo(60);
|
||||
assertThat(executor.getThreadPoolExecutor().getKeepAliveTime(TimeUnit.SECONDS)).isEqualTo(60);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
-15
@@ -1319,21 +1319,6 @@ class CronExpressionTests {
|
||||
assertThat(actual).isEqualTo(expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void various() {
|
||||
CronExpression cronExpression = CronExpression.parse("3-57 13-28 17,18 1,15 3-12 6#1");
|
||||
LocalDateTime last = LocalDateTime.of(2022, 9, 15, 17, 44, 11);
|
||||
LocalDateTime expected = LocalDateTime.of(2022, 10, 1, 17, 13, 3);
|
||||
LocalDateTime actual = cronExpression.next(last);
|
||||
assertThat(actual).isNotNull();
|
||||
assertThat(actual).isEqualTo(expected);
|
||||
|
||||
cronExpression = CronExpression.parse("*/28 56 22 */6 * *");
|
||||
last = LocalDateTime.of(2022, 2, 27, 8, 0, 42);
|
||||
expected = LocalDateTime.of(2022, 3, 1, 22, 56, 0);
|
||||
actual = cronExpression.next(last);
|
||||
assertThat(actual).isNotNull();
|
||||
assertThat(actual).isEqualTo(expected);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -194,7 +194,7 @@ public class ClassReader {
|
||||
this.b = classFileBuffer;
|
||||
// Check the class' major_version. This field is after the magic and minor_version fields, which
|
||||
// use 4 and 2 bytes respectively.
|
||||
if (checkClassVersion && readShort(classFileOffset + 6) > Opcodes.V18) {
|
||||
if (checkClassVersion && readShort(classFileOffset + 6) > Opcodes.V17) {
|
||||
throw new IllegalArgumentException(
|
||||
"Unsupported class file major version " + readShort(classFileOffset + 6));
|
||||
}
|
||||
|
||||
@@ -30,8 +30,8 @@ package org.springframework.asm;
|
||||
/**
|
||||
* A visitor to visit a Java class. The methods of this class must be called in the following order:
|
||||
* {@code visit} [ {@code visitSource} ] [ {@code visitModule} ][ {@code visitNestHost} ][ {@code
|
||||
* visitOuterClass} ] ( {@code visitAnnotation} | {@code visitTypeAnnotation} | {@code
|
||||
* visitAttribute} )* ( {@code visitNestMember} | [ {@code * visitPermittedSubclass} ] | {@code
|
||||
* visitPermittedSubclass} ][ {@code visitOuterClass} ] ( {@code visitAnnotation} | {@code
|
||||
* visitTypeAnnotation} | {@code visitAttribute} )* ( {@code visitNestMember} | {@code
|
||||
* visitInnerClass} | {@code visitRecordComponent} | {@code visitField} | {@code visitMethod} )*
|
||||
* {@code visitEnd}.
|
||||
*
|
||||
|
||||
@@ -282,7 +282,6 @@ public interface Opcodes {
|
||||
int V15 = 0 << 16 | 59;
|
||||
int V16 = 0 << 16 | 60;
|
||||
int V17 = 0 << 16 | 61;
|
||||
int V18 = 0 << 16 | 62;
|
||||
|
||||
/**
|
||||
* Version flag indicating that the class is using 'preview' features.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -324,7 +324,7 @@ public class Constants {
|
||||
for (int i = 0; i < propertyName.length(); i++) {
|
||||
char c = propertyName.charAt(i);
|
||||
if (Character.isUpperCase(c)) {
|
||||
parsedPrefix.append('_');
|
||||
parsedPrefix.append("_");
|
||||
parsedPrefix.append(c);
|
||||
}
|
||||
else {
|
||||
|
||||
+3
-5
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -394,11 +394,9 @@ public class AnnotationAttributes extends LinkedHashMap<String, Object> {
|
||||
sb.append(entry.getKey());
|
||||
sb.append('=');
|
||||
sb.append(valueToString(entry.getValue()));
|
||||
if (entries.hasNext()) {
|
||||
sb.append(", ");
|
||||
}
|
||||
sb.append(entries.hasNext() ? ", " : "");
|
||||
}
|
||||
sb.append('}');
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -177,17 +177,17 @@ final class SynthesizedMergedAnnotationInvocationHandler<A extends Annotation> i
|
||||
private String annotationToString() {
|
||||
String string = this.string;
|
||||
if (string == null) {
|
||||
StringBuilder builder = new StringBuilder("@").append(this.type.getName()).append('(');
|
||||
StringBuilder builder = new StringBuilder("@").append(this.type.getName()).append("(");
|
||||
for (int i = 0; i < this.attributes.size(); i++) {
|
||||
Method attribute = this.attributes.get(i);
|
||||
if (i > 0) {
|
||||
builder.append(", ");
|
||||
}
|
||||
builder.append(attribute.getName());
|
||||
builder.append('=');
|
||||
builder.append("=");
|
||||
builder.append(toString(getAttributeValue(attribute)));
|
||||
}
|
||||
builder.append(')');
|
||||
builder.append(")");
|
||||
string = builder.toString();
|
||||
this.string = string;
|
||||
}
|
||||
@@ -206,7 +206,7 @@ final class SynthesizedMergedAnnotationInvocationHandler<A extends Annotation> i
|
||||
}
|
||||
builder.append(toString(Array.get(value, i)));
|
||||
}
|
||||
builder.append(']');
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
return String.valueOf(value);
|
||||
|
||||
@@ -513,7 +513,7 @@ public class TypeDescriptor implements Serializable {
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (Annotation ann : getAnnotations()) {
|
||||
builder.append('@').append(ann.annotationType().getName()).append(' ');
|
||||
builder.append("@").append(ann.annotationType().getName()).append(' ');
|
||||
}
|
||||
builder.append(getResolvableType());
|
||||
return builder.toString();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2015 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.
|
||||
@@ -18,7 +18,7 @@ package org.springframework.core.type;
|
||||
|
||||
/**
|
||||
* Interface that defines abstract access to the annotations of a specific
|
||||
* method, in a form that does not require that method's class to be loaded yet.
|
||||
* class, in a form that does not require that class to be loaded yet.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @author Mark Pollack
|
||||
@@ -32,42 +32,42 @@ package org.springframework.core.type;
|
||||
public interface MethodMetadata extends AnnotatedTypeMetadata {
|
||||
|
||||
/**
|
||||
* Get the name of the underlying method.
|
||||
* Return the name of the method.
|
||||
*/
|
||||
String getMethodName();
|
||||
|
||||
/**
|
||||
* Get the fully-qualified name of the class that declares the underlying method.
|
||||
* Return the fully-qualified name of the class that declares this method.
|
||||
*/
|
||||
String getDeclaringClassName();
|
||||
|
||||
/**
|
||||
* Get the fully-qualified name of the underlying method's declared return type.
|
||||
* Return the fully-qualified name of this method's declared return type.
|
||||
* @since 4.2
|
||||
*/
|
||||
String getReturnTypeName();
|
||||
|
||||
/**
|
||||
* Determine whether the underlying method is effectively abstract:
|
||||
* i.e. marked as abstract in a class or declared as a regular,
|
||||
* Return whether the underlying method is effectively abstract:
|
||||
* i.e. marked as abstract on a class or declared as a regular,
|
||||
* non-default method in an interface.
|
||||
* @since 4.2
|
||||
*/
|
||||
boolean isAbstract();
|
||||
|
||||
/**
|
||||
* Determine whether the underlying method is declared as 'static'.
|
||||
* Return whether the underlying method is declared as 'static'.
|
||||
*/
|
||||
boolean isStatic();
|
||||
|
||||
/**
|
||||
* Determine whether the underlying method is marked as 'final'.
|
||||
* Return whether the underlying method is marked as 'final'.
|
||||
*/
|
||||
boolean isFinal();
|
||||
|
||||
/**
|
||||
* Determine whether the underlying method is overridable,
|
||||
* i.e. not marked as static, final, or private.
|
||||
* Return whether the underlying method is overridable,
|
||||
* i.e. not marked as static, final or private.
|
||||
*/
|
||||
boolean isOverridable();
|
||||
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2020 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.
|
||||
@@ -165,12 +165,12 @@ public class StandardAnnotationMetadata extends StandardClassMetadata implements
|
||||
return annotatedMethods != null ? annotatedMethods : Collections.emptySet();
|
||||
}
|
||||
|
||||
|
||||
private static boolean isAnnotatedMethod(Method method, String annotationName) {
|
||||
private boolean isAnnotatedMethod(Method method, String annotationName) {
|
||||
return !method.isBridge() && method.getAnnotations().length > 0 &&
|
||||
AnnotatedElementUtils.isAnnotated(method, annotationName);
|
||||
}
|
||||
|
||||
|
||||
static AnnotationMetadata from(Class<?> introspectedClass) {
|
||||
return new StandardAnnotationMetadata(introspectedClass, true);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -28,7 +28,6 @@ import org.springframework.util.StringUtils;
|
||||
* to introspect a given {@code Class}.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @author Sam Brannen
|
||||
* @since 2.5
|
||||
*/
|
||||
public class StandardClassMetadata implements ClassMetadata {
|
||||
@@ -120,20 +119,4 @@ public class StandardClassMetadata implements ClassMetadata {
|
||||
return StringUtils.toStringArray(memberClassNames);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object obj) {
|
||||
return ((this == obj) || ((obj instanceof StandardClassMetadata) &&
|
||||
getIntrospectedClass().equals(((StandardClassMetadata) obj).getIntrospectedClass())));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return getIntrospectedClass().hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClassName();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-18
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -36,7 +36,6 @@ import org.springframework.util.MultiValueMap;
|
||||
* @author Mark Pollack
|
||||
* @author Chris Beams
|
||||
* @author Phillip Webb
|
||||
* @author Sam Brannen
|
||||
* @since 3.0
|
||||
*/
|
||||
public class StandardMethodMetadata implements MethodMetadata {
|
||||
@@ -151,20 +150,4 @@ public class StandardMethodMetadata implements MethodMetadata {
|
||||
annotationName, classValuesAsString, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object obj) {
|
||||
return ((this == obj) || ((obj instanceof StandardMethodMetadata) &&
|
||||
this.introspectedMethod.equals(((StandardMethodMetadata) obj).introspectedMethod)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.introspectedMethod.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.introspectedMethod.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+4
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -23,6 +23,7 @@ import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.springframework.asm.AnnotationVisitor;
|
||||
import org.springframework.asm.SpringAsmInfo;
|
||||
@@ -120,7 +121,7 @@ class MergedAnnotationReadingVisitor<A extends Annotation> extends AnnotationVis
|
||||
@SuppressWarnings("unchecked")
|
||||
@Nullable
|
||||
static <A extends Annotation> AnnotationVisitor get(@Nullable ClassLoader classLoader,
|
||||
@Nullable Object source, String descriptor, boolean visible,
|
||||
@Nullable Supplier<Object> sourceSupplier, String descriptor, boolean visible,
|
||||
Consumer<MergedAnnotation<A>> consumer) {
|
||||
|
||||
if (!visible) {
|
||||
@@ -132,6 +133,7 @@ class MergedAnnotationReadingVisitor<A extends Annotation> extends AnnotationVis
|
||||
return null;
|
||||
}
|
||||
|
||||
Object source = (sourceSupplier != null ? sourceSupplier.get() : null);
|
||||
try {
|
||||
Class<A> annotationType = (Class<A>) ClassUtils.forName(typeName, classLoader);
|
||||
return new MergedAnnotationReadingVisitor<>(classLoader, source, annotationType, consumer);
|
||||
|
||||
+1
-18
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2020 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.
|
||||
@@ -31,7 +31,6 @@ import org.springframework.lang.Nullable;
|
||||
* {@link SimpleAnnotationMetadataReadingVisitor}.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @author Sam Brannen
|
||||
* @since 5.2
|
||||
*/
|
||||
final class SimpleAnnotationMetadata implements AnnotationMetadata {
|
||||
@@ -157,20 +156,4 @@ final class SimpleAnnotationMetadata implements AnnotationMetadata {
|
||||
return this.annotations;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object obj) {
|
||||
return ((this == obj) || ((obj instanceof SimpleAnnotationMetadata) &&
|
||||
this.className.equals(((SimpleAnnotationMetadata) obj).className)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.className.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.className;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -117,7 +117,7 @@ final class SimpleAnnotationMetadataReadingVisitor extends ClassVisitor {
|
||||
@Override
|
||||
@Nullable
|
||||
public AnnotationVisitor visitAnnotation(String descriptor, boolean visible) {
|
||||
return MergedAnnotationReadingVisitor.get(this.classLoader, getSource(),
|
||||
return MergedAnnotationReadingVisitor.get(this.classLoader, this::getSource,
|
||||
descriptor, visible, this.annotations::add);
|
||||
}
|
||||
|
||||
|
||||
+6
-27
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -19,13 +19,12 @@ package org.springframework.core.type.classreading;
|
||||
import org.springframework.asm.Opcodes;
|
||||
import org.springframework.core.annotation.MergedAnnotations;
|
||||
import org.springframework.core.type.MethodMetadata;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* {@link MethodMetadata} created from a {@link SimpleMethodMetadataReadingVisitor}.
|
||||
* {@link MethodMetadata} created from a
|
||||
* {@link SimpleMethodMetadataReadingVisitor}.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @author Sam Brannen
|
||||
* @since 5.2
|
||||
*/
|
||||
final class SimpleMethodMetadata implements MethodMetadata {
|
||||
@@ -38,20 +37,16 @@ final class SimpleMethodMetadata implements MethodMetadata {
|
||||
|
||||
private final String returnTypeName;
|
||||
|
||||
// The source implements equals(), hashCode(), and toString() for the underlying method.
|
||||
private final Object source;
|
||||
|
||||
private final MergedAnnotations annotations;
|
||||
|
||||
|
||||
SimpleMethodMetadata(String methodName, int access, String declaringClassName,
|
||||
String returnTypeName, Object source, MergedAnnotations annotations) {
|
||||
public SimpleMethodMetadata(String methodName, int access, String declaringClassName,
|
||||
String returnTypeName, MergedAnnotations annotations) {
|
||||
|
||||
this.methodName = methodName;
|
||||
this.access = access;
|
||||
this.declaringClassName = declaringClassName;
|
||||
this.returnTypeName = returnTypeName;
|
||||
this.source = source;
|
||||
this.annotations = annotations;
|
||||
}
|
||||
|
||||
@@ -91,7 +86,7 @@ final class SimpleMethodMetadata implements MethodMetadata {
|
||||
return !isStatic() && !isFinal() && !isPrivate();
|
||||
}
|
||||
|
||||
private boolean isPrivate() {
|
||||
public boolean isPrivate() {
|
||||
return (this.access & Opcodes.ACC_PRIVATE) != 0;
|
||||
}
|
||||
|
||||
@@ -100,20 +95,4 @@ final class SimpleMethodMetadata implements MethodMetadata {
|
||||
return this.annotations;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object obj) {
|
||||
return ((this == obj) || ((obj instanceof SimpleMethodMetadata) &&
|
||||
this.source.equals(((SimpleMethodMetadata) obj).source)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.source.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.source.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+19
-23
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -32,7 +32,6 @@ import org.springframework.lang.Nullable;
|
||||
* ASM method visitor that creates {@link SimpleMethodMetadata}.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @author Sam Brannen
|
||||
* @since 5.2
|
||||
*/
|
||||
final class SimpleMethodMetadataReadingVisitor extends MethodVisitor {
|
||||
@@ -44,7 +43,7 @@ final class SimpleMethodMetadataReadingVisitor extends MethodVisitor {
|
||||
|
||||
private final int access;
|
||||
|
||||
private final String methodName;
|
||||
private final String name;
|
||||
|
||||
private final String descriptor;
|
||||
|
||||
@@ -57,13 +56,13 @@ final class SimpleMethodMetadataReadingVisitor extends MethodVisitor {
|
||||
|
||||
|
||||
SimpleMethodMetadataReadingVisitor(@Nullable ClassLoader classLoader, String declaringClassName,
|
||||
int access, String methodName, String descriptor, Consumer<SimpleMethodMetadata> consumer) {
|
||||
int access, String name, String descriptor, Consumer<SimpleMethodMetadata> consumer) {
|
||||
|
||||
super(SpringAsmInfo.ASM_VERSION);
|
||||
this.classLoader = classLoader;
|
||||
this.declaringClassName = declaringClassName;
|
||||
this.access = access;
|
||||
this.methodName = methodName;
|
||||
this.name = name;
|
||||
this.descriptor = descriptor;
|
||||
this.consumer = consumer;
|
||||
}
|
||||
@@ -72,7 +71,7 @@ final class SimpleMethodMetadataReadingVisitor extends MethodVisitor {
|
||||
@Override
|
||||
@Nullable
|
||||
public AnnotationVisitor visitAnnotation(String descriptor, boolean visible) {
|
||||
return MergedAnnotationReadingVisitor.get(this.classLoader, getSource(),
|
||||
return MergedAnnotationReadingVisitor.get(this.classLoader, this::getSource,
|
||||
descriptor, visible, this.annotations::add);
|
||||
}
|
||||
|
||||
@@ -81,8 +80,8 @@ final class SimpleMethodMetadataReadingVisitor extends MethodVisitor {
|
||||
if (!this.annotations.isEmpty()) {
|
||||
String returnTypeName = Type.getReturnType(this.descriptor).getClassName();
|
||||
MergedAnnotations annotations = MergedAnnotations.of(this.annotations);
|
||||
SimpleMethodMetadata metadata = new SimpleMethodMetadata(this.methodName, this.access,
|
||||
this.declaringClassName, returnTypeName, getSource(), annotations);
|
||||
SimpleMethodMetadata metadata = new SimpleMethodMetadata(this.name,
|
||||
this.access, this.declaringClassName, returnTypeName, annotations);
|
||||
this.consumer.accept(metadata);
|
||||
}
|
||||
}
|
||||
@@ -90,7 +89,7 @@ final class SimpleMethodMetadataReadingVisitor extends MethodVisitor {
|
||||
private Object getSource() {
|
||||
Source source = this.source;
|
||||
if (source == null) {
|
||||
source = new Source(this.declaringClassName, this.methodName, this.descriptor);
|
||||
source = new Source(this.declaringClassName, this.name, this.descriptor);
|
||||
this.source = source;
|
||||
}
|
||||
return source;
|
||||
@@ -104,16 +103,16 @@ final class SimpleMethodMetadataReadingVisitor extends MethodVisitor {
|
||||
|
||||
private final String declaringClassName;
|
||||
|
||||
private final String methodName;
|
||||
private final String name;
|
||||
|
||||
private final String descriptor;
|
||||
|
||||
@Nullable
|
||||
private String toStringValue;
|
||||
|
||||
Source(String declaringClassName, String methodName, String descriptor) {
|
||||
Source(String declaringClassName, String name, String descriptor) {
|
||||
this.declaringClassName = declaringClassName;
|
||||
this.methodName = methodName;
|
||||
this.name = name;
|
||||
this.descriptor = descriptor;
|
||||
}
|
||||
|
||||
@@ -121,7 +120,7 @@ final class SimpleMethodMetadataReadingVisitor extends MethodVisitor {
|
||||
public int hashCode() {
|
||||
int result = 1;
|
||||
result = 31 * result + this.declaringClassName.hashCode();
|
||||
result = 31 * result + this.methodName.hashCode();
|
||||
result = 31 * result + this.name.hashCode();
|
||||
result = 31 * result + this.descriptor.hashCode();
|
||||
return result;
|
||||
}
|
||||
@@ -136,7 +135,7 @@ final class SimpleMethodMetadataReadingVisitor extends MethodVisitor {
|
||||
}
|
||||
Source otherSource = (Source) other;
|
||||
return (this.declaringClassName.equals(otherSource.declaringClassName) &&
|
||||
this.methodName.equals(otherSource.methodName) && this.descriptor.equals(otherSource.descriptor));
|
||||
this.name.equals(otherSource.name) && this.descriptor.equals(otherSource.descriptor));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -145,17 +144,14 @@ final class SimpleMethodMetadataReadingVisitor extends MethodVisitor {
|
||||
if (value == null) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(this.declaringClassName);
|
||||
builder.append('.');
|
||||
builder.append(this.methodName);
|
||||
builder.append(".");
|
||||
builder.append(this.name);
|
||||
Type[] argumentTypes = Type.getArgumentTypes(this.descriptor);
|
||||
builder.append('(');
|
||||
for (int i = 0; i < argumentTypes.length; i++) {
|
||||
if (i != 0) {
|
||||
builder.append(',');
|
||||
}
|
||||
builder.append(argumentTypes[i].getClassName());
|
||||
builder.append("(");
|
||||
for (Type type : argumentTypes) {
|
||||
builder.append(type.getClassName());
|
||||
}
|
||||
builder.append(')');
|
||||
builder.append(")");
|
||||
value = builder.toString();
|
||||
this.toStringValue = value;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2020 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.
|
||||
@@ -302,7 +302,7 @@ public class StopWatch {
|
||||
for (TaskInfo task : getTaskInfo()) {
|
||||
sb.append(nf.format(task.getTimeNanos())).append(" ");
|
||||
sb.append(pf.format((double) task.getTimeNanos() / getTotalTimeNanos())).append(" ");
|
||||
sb.append(task.getTaskName()).append('\n');
|
||||
sb.append(task.getTaskName()).append("\n");
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
@@ -320,7 +320,7 @@ public class StopWatch {
|
||||
for (TaskInfo task : getTaskInfo()) {
|
||||
sb.append("; [").append(task.getTaskName()).append("] took ").append(task.getTimeNanos()).append(" ns");
|
||||
long percent = Math.round(100.0 * task.getTimeNanos() / getTotalTimeNanos());
|
||||
sb.append(" = ").append(percent).append('%');
|
||||
sb.append(" = ").append(percent).append("%");
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
+1
-43
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -33,51 +33,9 @@ import static org.assertj.core.api.Assertions.entry;
|
||||
* Base class for {@link AnnotationMetadata} tests.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @author Sam Brannen
|
||||
*/
|
||||
public abstract class AbstractAnnotationMetadataTests {
|
||||
|
||||
@Test
|
||||
public void verifyEquals() throws Exception {
|
||||
AnnotationMetadata testClass1 = get(TestClass.class);
|
||||
AnnotationMetadata testClass2 = get(TestClass.class);
|
||||
AnnotationMetadata testMemberClass1 = get(TestMemberClass.class);
|
||||
AnnotationMetadata testMemberClass2 = get(TestMemberClass.class);
|
||||
|
||||
assertThat(testClass1.equals(null)).isFalse();
|
||||
|
||||
assertThat(testClass1.equals(testClass1)).isTrue();
|
||||
assertThat(testClass2.equals(testClass2)).isTrue();
|
||||
assertThat(testClass1.equals(testClass2)).isTrue();
|
||||
assertThat(testClass2.equals(testClass1)).isTrue();
|
||||
|
||||
assertThat(testMemberClass1.equals(testMemberClass1)).isTrue();
|
||||
assertThat(testMemberClass2.equals(testMemberClass2)).isTrue();
|
||||
assertThat(testMemberClass1.equals(testMemberClass2)).isTrue();
|
||||
assertThat(testMemberClass2.equals(testMemberClass1)).isTrue();
|
||||
|
||||
assertThat(testClass1.equals(testMemberClass1)).isFalse();
|
||||
assertThat(testMemberClass1.equals(testClass1)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void verifyHashCode() throws Exception {
|
||||
AnnotationMetadata testClass1 = get(TestClass.class);
|
||||
AnnotationMetadata testClass2 = get(TestClass.class);
|
||||
AnnotationMetadata testMemberClass1 = get(TestMemberClass.class);
|
||||
AnnotationMetadata testMemberClass2 = get(TestMemberClass.class);
|
||||
|
||||
assertThat(testClass1).hasSameHashCodeAs(testClass2);
|
||||
assertThat(testMemberClass1).hasSameHashCodeAs(testMemberClass2);
|
||||
|
||||
assertThat(testClass1).doesNotHaveSameHashCodeAs(testMemberClass1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void verifyToString() throws Exception {
|
||||
assertThat(get(TestClass.class).toString()).isEqualTo(TestClass.class.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getClassNameReturnsClassName() {
|
||||
assertThat(get(TestClass.class).getClassName()).isEqualTo(TestClass.class.getName());
|
||||
|
||||
+25
-21
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -20,6 +20,7 @@ import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
/**
|
||||
* Abstract base class for testing implementations of
|
||||
* {@link ClassMetadata#getMemberClassNames()}.
|
||||
@@ -29,45 +30,48 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*/
|
||||
public abstract class AbstractClassMetadataMemberClassTests {
|
||||
|
||||
protected abstract ClassMetadata getClassMetadataFor(Class<?> clazz);
|
||||
public abstract ClassMetadata getClassMetadataFor(Class<?> clazz);
|
||||
|
||||
@Test
|
||||
void withNoMemberClasses() {
|
||||
ClassMetadata metadata = getClassMetadataFor(L0_a.class);
|
||||
String[] nestedClasses = metadata.getMemberClassNames();
|
||||
assertThat(nestedClasses).isEmpty();
|
||||
assertThat(nestedClasses).isEqualTo(new String[]{});
|
||||
}
|
||||
|
||||
public static class L0_a {
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void withPublicMemberClasses() {
|
||||
ClassMetadata metadata = getClassMetadataFor(L0_b.class);
|
||||
String[] nestedClasses = metadata.getMemberClassNames();
|
||||
assertThat(nestedClasses).containsOnly(L0_b.L1.class.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
void withNonPublicMemberClasses() {
|
||||
ClassMetadata metadata = getClassMetadataFor(L0_c.class);
|
||||
String[] nestedClasses = metadata.getMemberClassNames();
|
||||
assertThat(nestedClasses).containsOnly(L0_c.L1.class.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
void againstMemberClass() {
|
||||
ClassMetadata metadata = getClassMetadataFor(L0_b.L1.class);
|
||||
String[] nestedClasses = metadata.getMemberClassNames();
|
||||
assertThat(nestedClasses).isEmpty();
|
||||
}
|
||||
|
||||
public static class L0_a {
|
||||
assertThat(nestedClasses).isEqualTo(new String[]{L0_b.L1.class.getName()});
|
||||
}
|
||||
|
||||
public static class L0_b {
|
||||
public static class L1 { }
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void withNonPublicMemberClasses() {
|
||||
ClassMetadata metadata = getClassMetadataFor(L0_c.class);
|
||||
String[] nestedClasses = metadata.getMemberClassNames();
|
||||
assertThat(nestedClasses).isEqualTo(new String[]{L0_c.L1.class.getName()});
|
||||
}
|
||||
|
||||
public static class L0_c {
|
||||
private static class L1 { }
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void againstMemberClass() {
|
||||
ClassMetadata metadata = getClassMetadataFor(L0_b.L1.class);
|
||||
String[] nestedClasses = metadata.getMemberClassNames();
|
||||
assertThat(nestedClasses).isEqualTo(new String[]{});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-67
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2020 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.
|
||||
@@ -37,54 +37,6 @@ import static org.assertj.core.api.Assertions.entry;
|
||||
*/
|
||||
public abstract class AbstractMethodMetadataTests {
|
||||
|
||||
@Test
|
||||
public void verifyEquals() throws Exception {
|
||||
MethodMetadata withMethod1 = getTagged(WithMethod.class);
|
||||
MethodMetadata withMethod2 = getTagged(WithMethod.class);
|
||||
MethodMetadata withMethodWithTwoArguments1 = getTagged(WithMethodWithTwoArguments.class);
|
||||
MethodMetadata withMethodWithTwoArguments2 = getTagged(WithMethodWithTwoArguments.class);
|
||||
|
||||
assertThat(withMethod1.equals(null)).isFalse();
|
||||
|
||||
assertThat(withMethod1.equals(withMethod1)).isTrue();
|
||||
assertThat(withMethod2.equals(withMethod2)).isTrue();
|
||||
assertThat(withMethod1.equals(withMethod2)).isTrue();
|
||||
assertThat(withMethod2.equals(withMethod1)).isTrue();
|
||||
|
||||
assertThat(withMethodWithTwoArguments1.equals(withMethodWithTwoArguments1)).isTrue();
|
||||
assertThat(withMethodWithTwoArguments2.equals(withMethodWithTwoArguments2)).isTrue();
|
||||
assertThat(withMethodWithTwoArguments1.equals(withMethodWithTwoArguments2)).isTrue();
|
||||
assertThat(withMethodWithTwoArguments2.equals(withMethodWithTwoArguments1)).isTrue();
|
||||
|
||||
assertThat(withMethod1.equals(withMethodWithTwoArguments1)).isFalse();
|
||||
assertThat(withMethodWithTwoArguments1.equals(withMethod1)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void verifyHashCode() throws Exception {
|
||||
MethodMetadata withMethod1 = getTagged(WithMethod.class);
|
||||
MethodMetadata withMethod2 = getTagged(WithMethod.class);
|
||||
MethodMetadata withMethodWithTwoArguments1 = getTagged(WithMethodWithTwoArguments.class);
|
||||
MethodMetadata withMethodWithTwoArguments2 = getTagged(WithMethodWithTwoArguments.class);
|
||||
|
||||
assertThat(withMethod1).hasSameHashCodeAs(withMethod2);
|
||||
assertThat(withMethodWithTwoArguments1).hasSameHashCodeAs(withMethodWithTwoArguments2);
|
||||
|
||||
assertThat(withMethod1).doesNotHaveSameHashCodeAs(withMethodWithTwoArguments1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void verifyToString() throws Exception {
|
||||
assertThat(getTagged(WithMethod.class).toString())
|
||||
.endsWith(WithMethod.class.getName() + ".test()");
|
||||
|
||||
assertThat(getTagged(WithMethodWithOneArgument.class).toString())
|
||||
.endsWith(WithMethodWithOneArgument.class.getName() + ".test(java.lang.String)");
|
||||
|
||||
assertThat(getTagged(WithMethodWithTwoArguments.class).toString())
|
||||
.endsWith(WithMethodWithTwoArguments.class.getName() + ".test(java.lang.String,java.lang.Integer)");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMethodNameReturnsMethodName() {
|
||||
assertThat(getTagged(WithMethod.class).getMethodName()).isEqualTo("test");
|
||||
@@ -219,24 +171,6 @@ public abstract class AbstractMethodMetadataTests {
|
||||
|
||||
}
|
||||
|
||||
public static class WithMethodWithOneArgument {
|
||||
|
||||
@Tag
|
||||
public String test(String text) {
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class WithMethodWithTwoArguments {
|
||||
|
||||
@Tag
|
||||
public String test(String text, Integer num) {
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public abstract static class WithAbstractMethod {
|
||||
|
||||
@Tag
|
||||
|
||||
+3
-23
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -19,7 +19,6 @@ package org.springframework.core.type.classreading;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.asm.ClassReader;
|
||||
@@ -36,7 +35,6 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
* Tests for {@link AnnotationMetadataReadingVisitor}.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @author Sam Brannen
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
class AnnotationMetadataReadingVisitorTests extends AbstractAnnotationMetadataTests {
|
||||
@@ -64,29 +62,11 @@ class AnnotationMetadataReadingVisitorTests extends AbstractAnnotationMetadataTe
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled("equals() not implemented in deprecated AnnotationMetadataReadingVisitor")
|
||||
@Override
|
||||
public void verifyEquals() throws Exception {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled("hashCode() not implemented in deprecated AnnotationMetadataReadingVisitor")
|
||||
@Override
|
||||
public void verifyHashCode() throws Exception {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled("toString() not implemented in deprecated AnnotationMetadataReadingVisitor")
|
||||
@Override
|
||||
public void verifyToString() {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void getAnnotationsReturnsDirectAnnotations() {
|
||||
assertThatExceptionOfType(UnsupportedOperationException.class)
|
||||
.isThrownBy(super::getAnnotationsReturnsDirectAnnotations);
|
||||
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(
|
||||
super::getAnnotationsReturnsDirectAnnotations);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-21
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -19,7 +19,6 @@ package org.springframework.core.type.classreading;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.asm.ClassReader;
|
||||
@@ -36,7 +35,6 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
* Tests for {@link MethodMetadataReadingVisitor}.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @author Sam Brannen
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
class MethodMetadataReadingVisitorTests extends AbstractMethodMetadataTests {
|
||||
@@ -64,26 +62,8 @@ class MethodMetadataReadingVisitorTests extends AbstractMethodMetadataTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled("equals() not implemented in deprecated MethodMetadataReadingVisitor")
|
||||
@Override
|
||||
public void verifyEquals() throws Exception {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled("hashCode() not implemented in deprecated MethodMetadataReadingVisitor")
|
||||
@Override
|
||||
public void verifyHashCode() throws Exception {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled("toString() not implemented in deprecated MethodMetadataReadingVisitor")
|
||||
@Override
|
||||
public void verifyToString() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void getAnnotationsReturnsDirectAnnotations() {
|
||||
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(
|
||||
super::getAnnotationsReturnsDirectAnnotations);
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -194,7 +194,7 @@ class FastByteArrayOutputStreamTests {
|
||||
this.os.write(this.helloBytes);
|
||||
InputStream inputStream = this.os.getInputStream();
|
||||
DigestUtils.appendMd5DigestAsHex(inputStream, builder);
|
||||
builder.append('"');
|
||||
builder.append("\"");
|
||||
String actual = builder.toString();
|
||||
assertThat(actual).isEqualTo("\"0b10a8db164e0754105b7a99be72e3fe5\"");
|
||||
}
|
||||
@@ -208,7 +208,7 @@ class FastByteArrayOutputStreamTests {
|
||||
}
|
||||
InputStream inputStream = this.os.getInputStream();
|
||||
DigestUtils.appendMd5DigestAsHex(inputStream, builder);
|
||||
builder.append('"');
|
||||
builder.append("\"");
|
||||
String actual = builder.toString();
|
||||
assertThat(actual).isEqualTo("\"06225ca1e4533354c516e74512065331d\"");
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -41,7 +41,7 @@ class StopWatchTests {
|
||||
|
||||
private static final long duration1 = 200;
|
||||
private static final long duration2 = 100;
|
||||
private static final long fudgeFactor = 100;
|
||||
private static final long fudgeFactor = 50;
|
||||
|
||||
private final StopWatch stopWatch = new StopWatch(ID);
|
||||
|
||||
@@ -107,7 +107,7 @@ class StopWatchTests {
|
||||
.isLessThanOrEqualTo(duration1 + duration2 + fudgeFactor);
|
||||
assertThat(stopWatch.getTotalTimeSeconds())
|
||||
.as("total time in seconds for task #2")
|
||||
.isGreaterThanOrEqualTo((duration1 + duration2 - fudgeFactor) / 1000.0)
|
||||
.isGreaterThanOrEqualTo((duration1 + duration2 - fudgeFactor) / 1000.0)
|
||||
.isLessThanOrEqualTo((duration1 + duration2 + fudgeFactor) / 1000.0);
|
||||
|
||||
assertThat(stopWatch.getTaskCount()).isEqualTo(2);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2020 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.
|
||||
@@ -612,7 +612,7 @@ class StringUtilsTests {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < components.length; i++) {
|
||||
if (i != 0) {
|
||||
sb.append(',');
|
||||
sb.append(",");
|
||||
}
|
||||
sb.append(components[i]);
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -137,7 +137,7 @@ public class ExpressionException extends RuntimeException {
|
||||
StringBuilder output = new StringBuilder();
|
||||
output.append("Expression [");
|
||||
output.append(this.expressionString);
|
||||
output.append(']');
|
||||
output.append("]");
|
||||
if (this.position >= 0) {
|
||||
output.append(" @");
|
||||
output.append(this.position);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -432,11 +432,11 @@ public class CodeFlow implements Opcodes {
|
||||
public static String createSignatureDescriptor(Method method) {
|
||||
Class<?>[] params = method.getParameterTypes();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append('(');
|
||||
sb.append("(");
|
||||
for (Class<?> param : params) {
|
||||
sb.append(toJvmDescriptor(param));
|
||||
}
|
||||
sb.append(')');
|
||||
sb.append(")");
|
||||
sb.append(toJvmDescriptor(method.getReturnType()));
|
||||
return sb.toString();
|
||||
}
|
||||
@@ -453,7 +453,7 @@ public class CodeFlow implements Opcodes {
|
||||
public static String createSignatureDescriptor(Constructor<?> ctor) {
|
||||
Class<?>[] params = ctor.getParameterTypes();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append('(');
|
||||
sb.append("(");
|
||||
for (Class<?> param : params) {
|
||||
sb.append(toJvmDescriptor(param));
|
||||
}
|
||||
@@ -473,7 +473,7 @@ public class CodeFlow implements Opcodes {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (clazz.isArray()) {
|
||||
while (clazz.isArray()) {
|
||||
sb.append('[');
|
||||
sb.append("[");
|
||||
clazz = clazz.getComponentType();
|
||||
}
|
||||
}
|
||||
@@ -507,9 +507,9 @@ public class CodeFlow implements Opcodes {
|
||||
}
|
||||
}
|
||||
else {
|
||||
sb.append('L');
|
||||
sb.append("L");
|
||||
sb.append(clazz.getName().replace('.', '/'));
|
||||
sb.append(';');
|
||||
sb.append(";");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -284,7 +284,7 @@ public enum SpelMessage {
|
||||
formattedMessage.append("EL").append(this.code);
|
||||
switch (this.kind) {
|
||||
case ERROR:
|
||||
formattedMessage.append('E');
|
||||
formattedMessage.append("E");
|
||||
break;
|
||||
}
|
||||
formattedMessage.append(": ");
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -64,13 +64,13 @@ public class BeanReference extends SpelNodeImpl {
|
||||
public String toStringAST() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (!this.beanName.startsWith(FACTORY_BEAN_PREFIX)) {
|
||||
sb.append('@');
|
||||
sb.append("@");
|
||||
}
|
||||
if (!this.beanName.contains(".")) {
|
||||
sb.append(this.beanName);
|
||||
}
|
||||
else {
|
||||
sb.append('\'').append(this.beanName).append('\'');
|
||||
sb.append("'").append(this.beanName).append("'");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
+4
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -208,14 +208,14 @@ public class ConstructorReference extends SpelNodeImpl {
|
||||
StringBuilder sb = new StringBuilder("new ");
|
||||
int index = 0;
|
||||
sb.append(getChild(index++).toStringAST());
|
||||
sb.append('(');
|
||||
sb.append("(");
|
||||
for (int i = index; i < getChildCount(); i++) {
|
||||
if (i > index) {
|
||||
sb.append(',');
|
||||
sb.append(",");
|
||||
}
|
||||
sb.append(getChild(i).toStringAST());
|
||||
}
|
||||
sb.append(')');
|
||||
sb.append(")");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -140,13 +140,13 @@ public class InlineMap extends SpelNodeImpl {
|
||||
int count = getChildCount();
|
||||
for (int c = 0; c < count; c++) {
|
||||
if (c > 0) {
|
||||
sb.append(',');
|
||||
sb.append(",");
|
||||
}
|
||||
sb.append(getChild(c++).toStringAST());
|
||||
sb.append(':');
|
||||
sb.append(":");
|
||||
sb.append(getChild(c).toStringAST());
|
||||
}
|
||||
sb.append('}');
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -81,10 +81,10 @@ public abstract class Operator extends SpelNodeImpl {
|
||||
StringBuilder sb = new StringBuilder("(");
|
||||
sb.append(getChild(0).toStringAST());
|
||||
for (int i = 1; i < getChildCount(); i++) {
|
||||
sb.append(' ').append(getOperatorName()).append(' ');
|
||||
sb.append(" ").append(getOperatorName()).append(" ");
|
||||
sb.append(getChild(i).toStringAST());
|
||||
}
|
||||
sb.append(')');
|
||||
sb.append(")");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -49,7 +49,7 @@ public class QualifiedIdentifier extends SpelNodeImpl {
|
||||
for (int i = 0; i < getChildCount(); i++) {
|
||||
Object value = this.children[i].getValueInternal(state).getValue();
|
||||
if (i > 0 && (value == null || !value.toString().startsWith("$"))) {
|
||||
sb.append('.');
|
||||
sb.append(".");
|
||||
}
|
||||
sb.append(value);
|
||||
}
|
||||
@@ -67,7 +67,7 @@ public class QualifiedIdentifier extends SpelNodeImpl {
|
||||
else {
|
||||
for (int i = 0; i < getChildCount(); i++) {
|
||||
if (i > 0) {
|
||||
sb.append('.');
|
||||
sb.append(".");
|
||||
}
|
||||
sb.append(getChild(i).toStringAST());
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -90,7 +90,7 @@ public class TypeReference extends SpelNodeImpl {
|
||||
for (int d = 0; d < this.dimensions; d++) {
|
||||
sb.append("[]");
|
||||
}
|
||||
sb.append(')');
|
||||
sb.append(")");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
+5
-5
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -88,12 +88,12 @@ class Token {
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder s = new StringBuilder();
|
||||
s.append('[').append(this.kind.toString());
|
||||
s.append("[").append(this.kind.toString());
|
||||
if (this.kind.hasPayload()) {
|
||||
s.append(':').append(this.data);
|
||||
s.append(":").append(this.data);
|
||||
}
|
||||
s.append(']');
|
||||
s.append('(').append(this.startPos).append(',').append(this.endPos).append(')');
|
||||
s.append("]");
|
||||
s.append("(").append(this.startPos).append(",").append(this.endPos).append(")");
|
||||
return s.toString();
|
||||
}
|
||||
|
||||
|
||||
+6
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -19,7 +19,6 @@ package org.springframework.expression.spel.support;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.core.MethodParameter;
|
||||
@@ -60,7 +59,11 @@ public class ReflectiveConstructorResolver implements ConstructorResolver {
|
||||
Class<?> type = context.getTypeLocator().findType(typeName);
|
||||
Constructor<?>[] ctors = type.getConstructors();
|
||||
|
||||
Arrays.sort(ctors, Comparator.comparingInt(Constructor::getParameterCount));
|
||||
Arrays.sort(ctors, (c1, c2) -> {
|
||||
int c1pl = c1.getParameterCount();
|
||||
int c2pl = c2.getParameterCount();
|
||||
return Integer.compare(c1pl, c2pl);
|
||||
});
|
||||
|
||||
Constructor<?> closeMatch = null;
|
||||
Constructor<?> matchRequiringConversion = null;
|
||||
|
||||
+10
-10
@@ -245,22 +245,22 @@ public abstract class AbstractExpressionTests {
|
||||
sb.append("int[").append(l.length).append("]{");
|
||||
for (int j = 0; j < l.length; j++) {
|
||||
if (j > 0) {
|
||||
sb.append(',');
|
||||
sb.append(",");
|
||||
}
|
||||
sb.append(stringValueOf(l[j]));
|
||||
}
|
||||
sb.append('}');
|
||||
sb.append("}");
|
||||
}
|
||||
else if (primitiveType == Long.TYPE) {
|
||||
long[] l = (long[]) value;
|
||||
sb.append("long[").append(l.length).append("]{");
|
||||
for (int j = 0; j < l.length; j++) {
|
||||
if (j > 0) {
|
||||
sb.append(',');
|
||||
sb.append(",");
|
||||
}
|
||||
sb.append(stringValueOf(l[j]));
|
||||
}
|
||||
sb.append('}');
|
||||
sb.append("}");
|
||||
}
|
||||
else {
|
||||
throw new RuntimeException("Please implement support for type " + primitiveType.getName() +
|
||||
@@ -272,32 +272,32 @@ public abstract class AbstractExpressionTests {
|
||||
if (!isNested) {
|
||||
sb.append(value.getClass().getComponentType().getName());
|
||||
}
|
||||
sb.append('[').append(l.size()).append("]{");
|
||||
sb.append("[").append(l.size()).append("]{");
|
||||
int i = 0;
|
||||
for (Object object : l) {
|
||||
if (i > 0) {
|
||||
sb.append(',');
|
||||
sb.append(",");
|
||||
}
|
||||
i++;
|
||||
sb.append(stringValueOf(object, true));
|
||||
}
|
||||
sb.append('}');
|
||||
sb.append("}");
|
||||
}
|
||||
else {
|
||||
List<Object> l = Arrays.asList((Object[]) value);
|
||||
if (!isNested) {
|
||||
sb.append(value.getClass().getComponentType().getName());
|
||||
}
|
||||
sb.append('[').append(l.size()).append("]{");
|
||||
sb.append("[").append(l.size()).append("]{");
|
||||
int i = 0;
|
||||
for (Object object : l) {
|
||||
if (i > 0) {
|
||||
sb.append(',');
|
||||
sb.append(",");
|
||||
}
|
||||
i++;
|
||||
sb.append(stringValueOf(object));
|
||||
}
|
||||
sb.append('}');
|
||||
sb.append("}");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
+6
-6
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2020 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.
|
||||
@@ -5111,21 +5111,21 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
List<?> ls = (List<?>) object;
|
||||
for (Object l: ls) {
|
||||
s.append(l);
|
||||
s.append(' ');
|
||||
s.append(" ");
|
||||
}
|
||||
}
|
||||
else if (object instanceof Object[]) {
|
||||
Object[] os = (Object[]) object;
|
||||
for (Object o: os) {
|
||||
s.append(o);
|
||||
s.append(' ');
|
||||
s.append(" ");
|
||||
}
|
||||
}
|
||||
else if (object instanceof int[]) {
|
||||
int[] is = (int[]) object;
|
||||
for (int i: is) {
|
||||
s.append(i);
|
||||
s.append(' ');
|
||||
s.append(" ");
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -5931,9 +5931,9 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
public Obj3(String s, Float f, int... ints) {
|
||||
StringBuilder b = new StringBuilder();
|
||||
b.append(s);
|
||||
b.append(':');
|
||||
b.append(":");
|
||||
b.append(Float.toString(f));
|
||||
b.append(':');
|
||||
b.append(":");
|
||||
for (int param: ints) {
|
||||
b.append(Integer.toString(param));
|
||||
}
|
||||
|
||||
+15
-28
@@ -225,40 +225,16 @@ public class BeanPropertyRowMapper<T> implements RowMapper<T> {
|
||||
|
||||
for (PropertyDescriptor pd : BeanUtils.getPropertyDescriptors(mappedClass)) {
|
||||
if (pd.getWriteMethod() != null) {
|
||||
String lowerCaseName = lowerCaseName(pd.getName());
|
||||
this.mappedFields.put(lowerCaseName, pd);
|
||||
String underscoreName = underscoreName(pd.getName());
|
||||
if (!lowerCaseName.equals(underscoreName)) {
|
||||
this.mappedFields.put(underscoreName, pd);
|
||||
this.mappedFields.put(lowerCaseName(pd.getName()), pd);
|
||||
String underscoredName = underscoreName(pd.getName());
|
||||
if (!lowerCaseName(pd.getName()).equals(underscoredName)) {
|
||||
this.mappedFields.put(underscoredName, pd);
|
||||
}
|
||||
this.mappedProperties.add(pd.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified property from the mapped fields.
|
||||
* @param propertyName the property name (as used by property descriptors)
|
||||
* @since 5.3.9
|
||||
*/
|
||||
protected void suppressProperty(String propertyName) {
|
||||
if (this.mappedFields != null) {
|
||||
this.mappedFields.remove(lowerCaseName(propertyName));
|
||||
this.mappedFields.remove(underscoreName(propertyName));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given name to lower case.
|
||||
* By default, conversions will happen within the US locale.
|
||||
* @param name the original name
|
||||
* @return the converted name
|
||||
* @since 4.2
|
||||
*/
|
||||
protected String lowerCaseName(String name) {
|
||||
return name.toLowerCase(Locale.US);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a name in camelCase to an underscored name in lower case.
|
||||
* Any upper case letters are converted to lower case with a preceding underscore.
|
||||
@@ -285,6 +261,17 @@ public class BeanPropertyRowMapper<T> implements RowMapper<T> {
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given name to lower case.
|
||||
* By default, conversions will happen within the US locale.
|
||||
* @param name the original name
|
||||
* @return the converted name
|
||||
* @since 4.2
|
||||
*/
|
||||
protected String lowerCaseName(String name) {
|
||||
return name.toLowerCase(Locale.US);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Extract the values for all columns in the current row.
|
||||
|
||||
@@ -80,9 +80,6 @@ public class DataClassRowMapper<T> extends BeanPropertyRowMapper<T> {
|
||||
int paramCount = this.mappedConstructor.getParameterCount();
|
||||
if (paramCount > 0) {
|
||||
this.constructorParameterNames = BeanUtils.getParameterNames(this.mappedConstructor);
|
||||
for (String name : this.constructorParameterNames) {
|
||||
suppressProperty(name);
|
||||
}
|
||||
this.constructorParameterTypes = new TypeDescriptor[paramCount];
|
||||
for (int i = 0; i < paramCount; i++) {
|
||||
this.constructorParameterTypes[i] = new TypeDescriptor(new MethodParameter(this.mappedConstructor, i));
|
||||
|
||||
+4
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2020 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.
|
||||
@@ -646,13 +646,13 @@ public class CallMetaDataContext {
|
||||
}
|
||||
|
||||
if (StringUtils.hasLength(catalogNameToUse)) {
|
||||
callString.append(catalogNameToUse).append('.');
|
||||
callString.append(catalogNameToUse).append(".");
|
||||
}
|
||||
if (StringUtils.hasLength(schemaNameToUse)) {
|
||||
callString.append(schemaNameToUse).append('.');
|
||||
callString.append(schemaNameToUse).append(".");
|
||||
}
|
||||
callString.append(this.metaDataProvider.procedureNameToUse(getProcedureName()));
|
||||
callString.append('(');
|
||||
callString.append("(");
|
||||
|
||||
for (SqlParameter parameter : this.callParameters) {
|
||||
if (!parameter.isResultsParameter()) {
|
||||
|
||||
+2
-2
@@ -280,7 +280,7 @@ public class TableMetaDataContext {
|
||||
insertStatement.append("INSERT INTO ");
|
||||
if (getSchemaName() != null) {
|
||||
insertStatement.append(getSchemaName());
|
||||
insertStatement.append('.');
|
||||
insertStatement.append(".");
|
||||
}
|
||||
insertStatement.append(getTableName());
|
||||
insertStatement.append(" (");
|
||||
@@ -313,7 +313,7 @@ public class TableMetaDataContext {
|
||||
}
|
||||
String params = String.join(", ", Collections.nCopies(columnCount, "?"));
|
||||
insertStatement.append(params);
|
||||
insertStatement.append(')');
|
||||
insertStatement.append(")");
|
||||
return insertStatement.toString();
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -33,10 +33,10 @@ import org.springframework.jdbc.support.KeyHolder;
|
||||
*
|
||||
* <p>The meta-data processing is based on the DatabaseMetaData provided by the
|
||||
* JDBC driver. As long as the JDBC driver can provide the names of the columns
|
||||
* for a specified table then we can rely on this auto-detection feature. If that
|
||||
* for a specified table than we can rely on this auto-detection feature. If that
|
||||
* is not the case, then the column names must be specified explicitly.
|
||||
*
|
||||
* <p>The actual insert is handled using Spring's {@link JdbcTemplate}.
|
||||
* <p>The actual insert is being handled using Spring's {@link JdbcTemplate}.
|
||||
*
|
||||
* <p>Many of the configuration methods return the current instance of the
|
||||
* SimpleJdbcInsert to provide the ability to chain multiple ones together
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2020 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.
|
||||
@@ -186,10 +186,10 @@ public class TransactionAwareDataSourceProxy extends DelegatingDataSource {
|
||||
// Allow for differentiating between the proxy and the raw Connection.
|
||||
StringBuilder sb = new StringBuilder("Transaction-aware proxy for target Connection ");
|
||||
if (this.target != null) {
|
||||
sb.append('[').append(this.target.toString()).append(']');
|
||||
sb.append("[").append(this.target.toString()).append("]");
|
||||
}
|
||||
else {
|
||||
sb.append(" from DataSource [").append(this.targetDataSource).append(']');
|
||||
sb.append(" from DataSource [").append(this.targetDataSource).append("]");
|
||||
}
|
||||
return sb.toString();
|
||||
case "close":
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -152,7 +152,7 @@ public abstract class AbstractIdentityColumnMaxValueIncrementer extends Abstract
|
||||
for (int i = 0; i < values.length - 1; i++) {
|
||||
sb.append(", ").append(values[i]);
|
||||
}
|
||||
sb.append(')');
|
||||
sb.append(")");
|
||||
}
|
||||
else {
|
||||
long maxValue = values[values.length - 1];
|
||||
|
||||
@@ -25,7 +25,6 @@ import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.jdbc.core.test.ConstructorPerson;
|
||||
import org.springframework.jdbc.core.test.ConstructorPersonWithGenerics;
|
||||
import org.springframework.jdbc.core.test.ConstructorPersonWithSetters;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@@ -63,20 +62,4 @@ public class DataClassRowMapperTests extends AbstractRowMapperTests {
|
||||
mock.verifyClosed();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStaticQueryWithDataClassAndSetters() throws Exception {
|
||||
Mock mock = new Mock();
|
||||
List<ConstructorPersonWithSetters> result = mock.getJdbcTemplate().query(
|
||||
"select name, age, birth_date, balance from people",
|
||||
new DataClassRowMapper<>(ConstructorPersonWithSetters.class));
|
||||
assertThat(result.size()).isEqualTo(1);
|
||||
ConstructorPersonWithSetters person = result.get(0);
|
||||
assertThat(person.name()).isEqualTo("BUBBA");
|
||||
assertThat(person.age()).isEqualTo(22L);
|
||||
assertThat(person.birth_date()).usingComparator(Date::compareTo).isEqualTo(new java.util.Date(1221222L));
|
||||
assertThat(person.balance()).isEqualTo(new BigDecimal("1234.56"));
|
||||
|
||||
mock.verifyClosed();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
-76
@@ -1,76 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-2021 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.jdbc.core.test;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
public class ConstructorPersonWithSetters {
|
||||
|
||||
private String name;
|
||||
|
||||
private long age;
|
||||
|
||||
private Date birth_date;
|
||||
|
||||
private BigDecimal balance;
|
||||
|
||||
|
||||
public ConstructorPersonWithSetters(String name, long age, Date birth_date, BigDecimal balance) {
|
||||
this.name = name.toUpperCase();
|
||||
this.age = age;
|
||||
this.birth_date = birth_date;
|
||||
this.balance = balance;
|
||||
}
|
||||
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void setAge(long age) {
|
||||
this.age = age;
|
||||
}
|
||||
|
||||
public void setBirth_date(Date birth_date) {
|
||||
this.birth_date = birth_date;
|
||||
}
|
||||
|
||||
public void setBalance(BigDecimal balance) {
|
||||
this.balance = balance;
|
||||
}
|
||||
|
||||
public String name() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public long age() {
|
||||
return this.age;
|
||||
}
|
||||
|
||||
public Date birth_date() {
|
||||
return this.birth_date;
|
||||
}
|
||||
|
||||
public BigDecimal balance() {
|
||||
return this.balance;
|
||||
}
|
||||
|
||||
}
|
||||
-57
@@ -1,57 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-2021 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.jdbc.core
|
||||
|
||||
import org.assertj.core.api.Assertions
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.springframework.jdbc.core.test.ConstructorPerson
|
||||
import java.math.BigDecimal
|
||||
import java.util.*
|
||||
|
||||
class KotlinDataClassRowMapperTests : AbstractRowMapperTests() {
|
||||
|
||||
@Test
|
||||
fun testStaticQueryWithDataClass() {
|
||||
val mock = Mock()
|
||||
val result = mock.jdbcTemplate.query(
|
||||
"select name, age, birth_date, balance from people",
|
||||
DataClassRowMapper(ConstructorPerson::class.java)
|
||||
)
|
||||
Assertions.assertThat(result.size).isEqualTo(1)
|
||||
verifyPerson(result[0])
|
||||
mock.verifyClosed()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testInitPropertiesAreNotOverridden() {
|
||||
val mock = Mock()
|
||||
val result = mock.jdbcTemplate.query(
|
||||
"select name, age, birth_date, balance from people",
|
||||
DataClassRowMapper(KotlinPerson::class.java)
|
||||
)
|
||||
Assertions.assertThat(result.size).isEqualTo(1)
|
||||
Assertions.assertThat(result[0].name).isEqualTo("Bubba appended by init")
|
||||
}
|
||||
|
||||
|
||||
data class KotlinPerson(var name: String, val age: Long, val birth_date: Date, val balance: BigDecimal) {
|
||||
init {
|
||||
name += " appended by init"
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+2
-2
@@ -177,9 +177,9 @@ public abstract class AbstractJmsListenerEndpoint implements JmsListenerEndpoint
|
||||
*/
|
||||
protected StringBuilder getEndpointDescription() {
|
||||
StringBuilder result = new StringBuilder();
|
||||
return result.append(getClass().getSimpleName()).append('[').append(this.id).append("] destination=").
|
||||
return result.append(getClass().getSimpleName()).append("[").append(this.id).append("] destination=").
|
||||
append(this.destination).append("' | subscription='").append(this.subscription).
|
||||
append(" | selector='").append(this.selector).append('\'');
|
||||
append(" | selector='").append(this.selector).append("'");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -224,8 +224,8 @@ public class MethodJmsListenerEndpoint extends AbstractJmsListenerEndpoint imple
|
||||
@Override
|
||||
protected StringBuilder getEndpointDescription() {
|
||||
return super.getEndpointDescription()
|
||||
.append(" | bean='").append(this.bean).append('\'')
|
||||
.append(" | method='").append(this.method).append('\'');
|
||||
.append(" | bean='").append(this.bean).append("'")
|
||||
.append(" | method='").append(this.method).append("'");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -63,7 +63,7 @@ public class SimpleJmsListenerEndpoint extends AbstractJmsListenerEndpoint {
|
||||
@Override
|
||||
protected StringBuilder getEndpointDescription() {
|
||||
return super.getEndpointDescription()
|
||||
.append(" | messageListener='").append(this.messageListener).append('\'');
|
||||
.append(" | messageListener='").append(this.messageListener).append("'");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -125,7 +125,7 @@ public class MessagingMessageListenerAdapter extends AbstractAdaptableMessageLis
|
||||
|
||||
private String createMessagingErrorMessage(String description) {
|
||||
InvocableHandlerMethod handlerMethod = getHandlerMethod();
|
||||
StringBuilder sb = new StringBuilder(description).append('\n')
|
||||
StringBuilder sb = new StringBuilder(description).append("\n")
|
||||
.append("Endpoint handler details:\n")
|
||||
.append("Method [").append(handlerMethod.getMethod()).append("]\n")
|
||||
.append("Bean [").append(handlerMethod.getBean()).append("]\n");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -93,7 +93,8 @@ public class SimpleJmsHeaderMapper extends AbstractHeaderMapper<Message> impleme
|
||||
logger.debug("Failed to set JMSType - skipping", ex);
|
||||
}
|
||||
}
|
||||
for (Map.Entry<String, Object> entry : headers.entrySet()) {
|
||||
Set<Map.Entry<String, Object>> entries = headers.entrySet();
|
||||
for (Map.Entry<String, Object> entry : entries) {
|
||||
String headerName = entry.getKey();
|
||||
if (StringUtils.hasText(headerName) && !headerName.startsWith(JmsHeaders.PREFIX)) {
|
||||
Object value = entry.getValue();
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user