Compare commits

..

1 Commits

Author SHA1 Message Date
Spring Builds cedb5874b7 Release v5.3.19 2022-04-13 08:58:09 +00:00
798 changed files with 4056 additions and 6168 deletions
-1
View File
@@ -21,7 +21,6 @@ classes/
/build
buildSrc/build
/spring-*/build
/spring-core/graalvm/build
/spring-core/kotlin-coroutines/build
/framework-bom/build
/integration-tests/build
+22 -32
View File
@@ -1,33 +1,23 @@
Juergen Hoeller <jhoeller@vmware.com>
Juergen Hoeller <jhoeller@vmware.com> <jhoeller@pivotal.io>
Juergen Hoeller <jhoeller@vmware.com> <jhoeller@gopivotal.com>
Rossen Stoyanchev <rstoyanchev@vmware.com>
Rossen Stoyanchev <rstoyanchev@vmware.com> <rstoyanchev@pivotal.io>
Rossen Stoyanchev <rstoyanchev@vmware.com> <rstoyanchev@gopivotal.com>
Phillip Webb <pwebb@vmware.com>
Phillip Webb <pwebb@vmware.com> <pwebb@pivotal.io>
Phillip Webb <pwebb@vmware.com> <pwebb@gopivotal.com>
Chris Beams <cbeams@vmware.com>
Chris Beams <cbeams@vmware.com> <cbeams@pivotal.io>
Chris Beams <cbeams@vmware.com> <cbeams@gopivotal.com>
Arjen Poutsma <apoutsma@vmware.com>
Arjen Poutsma <apoutsma@vmware.com> <apoutsma@pivotal.io>
Arjen Poutsma <apoutsma@vmware.com> <apoutsma@gopivotal.com>
Arjen Poutsma <apoutsma@vmware.com> <poutsma@mac.com>
Oliver Drotbohm <odrotbohm@vmware.com>
Oliver Drotbohm <odrotbohm@vmware.com> <ogierke@vmware.com>
Oliver Drotbohm <odrotbohm@vmware.com> <ogierke@pivotal.io>
Oliver Drotbohm <odrotbohm@vmware.com> <ogierke@gopivotal.com>
Dave Syer <dsyer@vmware.com>
Dave Syer <dsyer@vmware.com> <dsyer@pivotal.io>
Dave Syer <dsyer@vmware.com> <dsyer@gopivotal.com>
Dave Syer <dsyer@vmware.com> <david_syer@hotmail.com>
Andy Clement <aclement@vmware.com>
Andy Clement <aclement@vmware.com> <aclement@pivotal.io>
Andy Clement <aclement@vmware.com> <aclement@gopivotal.com>
Andy Clement <aclement@vmware.com> <andrew.clement@gmail.com>
Sam Brannen <sbrannen@vmware.com>
Sam Brannen <sbrannen@vmware.com> <sbrannen@pivotal.io>
Sam Brannen <sbrannen@vmware.com> <sam@sambrannen.com>
Juergen Hoeller <jhoeller@pivotal.io> jhoeller <jhoeller@vmware.com>
<jhoeller@pivotal.io> <jhoeller@vmware.com>
<jhoeller@pivotal.io> <jhoeller@gopivotal.com>
<rstoyanchev@pivotal.io> <rstoyanchev@vmware.com>
<rstoyanchev@pivotal.io> <rstoyanchev@gopivotal.com>
<pwebb@pivotal.io> <pwebb@vmware.com>
<pwebb@pivotal.io> <pwebb@gopivotal.com>
<cbeams@pivotal.io> <cbeams@vmware.com>
<cbeams@pivotal.io> <cbeams@gopivotal.com>
<cbeams@pivotal.io> <cbeams@gmail.com>
<apoutsma@pivotal.io> <apoutsma@vmware.com>
<apoutsma@pivotal.io> <apoutsma@gopivotal.com>
<apoutsma@pivotal.io> <poutsma@mac.com>
<ogierke@pivotal.io> <ogierke@vmware.com>
<ogierke@pivotal.io> <ogierke@gopivotal.com>
<dsyer@pivotal.io> <dsyer@vmware.com>
<dsyer@pivotal.io> <dsyer@gopivotal.com>
<dsyer@pivotal.io> <david_syer@hotmail.com>
<aclement@pivotal.io> <aclement@vmware.com>
<aclement@pivotal.io> <aclement@gopivotal.com>
<aclement@pivotal.io> <andrew.clement@gmail.com>
<dmitry.katsubo@gmail.com> <dmitry.katsubo@gmai.com>
Nick Williams <nicholas@nicholaswilliams.net>
Nick Williams <nicholas@nicholaswilliams.net> Nicholas Williams <nicholas@nicholaswilliams.net>
+1 -1
View File
@@ -1,3 +1,3 @@
# Enable auto-env through the sdkman_auto_env config
# Add key=value pairs of SDKs to use below
java=8.0.333-librca
java=8.0.322-librca
+3 -3
View File
@@ -14,16 +14,16 @@ For access to artifacts or a distribution zip, see the [Spring Framework Artifac
## Documentation
The Spring Framework maintains reference documentation ([published](https://docs.spring.io/spring-framework/docs/current/spring-framework-reference/) and [source](src/docs/asciidoc)), GitHub [wiki pages](https://github.com/spring-projects/spring-framework/wiki), and an
The Spring Framework maintains reference documentation ([published](https://docs.spring.io/spring-framework/docs/current/spring-framework-reference/) and [source](src/docs/asciidoc)), Github [wiki pages](https://github.com/spring-projects/spring-framework/wiki), and an
[API reference](https://docs.spring.io/spring-framework/docs/current/javadoc-api/). There are also [guides and tutorials](https://spring.io/guides) across Spring projects.
## Micro-Benchmarks
See the [Micro-Benchmarks](https://github.com/spring-projects/spring-framework/wiki/Micro-Benchmarks) wiki page.
See the [Micro-Benchmarks](https://github.com/spring-projects/spring-framework/wiki/Micro-Benchmarks) Wiki page.
## Build from Source
See the [Build from Source](https://github.com/spring-projects/spring-framework/wiki/Build-from-Source) wiki page and the [CONTRIBUTING.md](CONTRIBUTING.md) file.
See the [Build from Source](https://github.com/spring-projects/spring-framework/wiki/Build-from-Source) Wiki page and the [CONTRIBUTING.md](CONTRIBUTING.md) file.
## Continuous Integration Builds
+23 -26
View File
@@ -27,19 +27,19 @@ configure(allprojects) { project ->
dependencyManagement {
imports {
mavenBom "com.fasterxml.jackson:jackson-bom:2.12.7"
mavenBom "io.netty:netty-bom:4.1.79.Final"
mavenBom "io.projectreactor:reactor-bom:2020.0.21"
mavenBom "com.fasterxml.jackson:jackson-bom:2.12.6"
mavenBom "io.netty:netty-bom:4.1.75.Final"
mavenBom "io.projectreactor:reactor-bom:2020.0.18"
mavenBom "io.r2dbc:r2dbc-bom:Arabba-SR13"
mavenBom "io.rsocket:rsocket-bom:1.1.2"
mavenBom "org.eclipse.jetty:jetty-bom:9.4.48.v20220622"
mavenBom "org.eclipse.jetty:jetty-bom:9.4.46.v20220331"
mavenBom "org.jetbrains.kotlin:kotlin-bom:1.5.32"
mavenBom "org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.5.2"
mavenBom "org.jetbrains.kotlinx:kotlinx-serialization-bom:1.2.2"
mavenBom "org.junit:junit-bom:5.8.2"
}
dependencies {
dependencySet(group: 'org.apache.logging.log4j', version: '2.18.0') {
dependencySet(group: 'org.apache.logging.log4j', version: '2.17.2') {
entry 'log4j-api'
entry 'log4j-core'
entry 'log4j-jul'
@@ -67,7 +67,7 @@ configure(allprojects) { project ->
dependency "io.reactivex:rxjava:1.3.8"
dependency "io.reactivex:rxjava-reactive-streams:1.2.1"
dependency "io.reactivex.rxjava2:rxjava:2.2.21"
dependency "io.reactivex.rxjava3:rxjava:3.1.4"
dependency "io.reactivex.rxjava3:rxjava:3.1.3"
dependency "io.smallrye.reactive:mutiny:1.4.0"
dependency "io.projectreactor.tools:blockhound:1.0.6.RELEASE"
@@ -79,11 +79,11 @@ configure(allprojects) { project ->
dependency "com.google.code.gson:gson:2.8.9"
dependency "com.google.protobuf:protobuf-java-util:3.19.3"
dependency "com.googlecode.protobuf-java-format:protobuf-java-format:1.4"
dependency("com.thoughtworks.xstream:xstream:1.4.19") {
dependency("com.thoughtworks.xstream:xstream:1.4.18") {
exclude group: "xpp3", name: "xpp3_min"
exclude group: "xmlpull", name: "xmlpull"
}
dependency "org.apache.johnzon:johnzon-jsonb:1.2.18"
dependency "org.apache.johnzon:johnzon-jsonb:1.2.16"
dependency("org.codehaus.jettison:jettison:1.3.8") {
exclude group: "stax", name: "stax-api"
}
@@ -94,9 +94,9 @@ configure(allprojects) { project ->
dependency "org.ogce:xpp3:1.1.6"
dependency "org.yaml:snakeyaml:1.30"
dependency "com.h2database:h2:2.1.214"
dependency "com.h2database:h2:2.1.210"
dependency "com.github.ben-manes.caffeine:caffeine:2.9.3"
dependency "com.github.librepdf:openpdf:1.3.29"
dependency "com.github.librepdf:openpdf:1.3.27"
dependency "com.rometools:rome:1.18.0"
dependency "commons-io:commons-io:2.5"
dependency "io.vavr:vavr:0.10.4"
@@ -128,18 +128,18 @@ configure(allprojects) { project ->
dependency "org.webjars:webjars-locator-core:0.48"
dependency "org.webjars:underscorejs:1.8.3"
dependencySet(group: 'org.apache.tomcat', version: '9.0.64') {
dependencySet(group: 'org.apache.tomcat', version: '9.0.62') {
entry 'tomcat-util'
entry('tomcat-websocket') {
exclude group: "org.apache.tomcat", name: "tomcat-servlet-api"
exclude group: "org.apache.tomcat", name: "tomcat-websocket-api"
}
}
dependencySet(group: 'org.apache.tomcat.embed', version: '9.0.64') {
dependencySet(group: 'org.apache.tomcat.embed', version: '9.0.62') {
entry 'tomcat-embed-core'
entry 'tomcat-embed-websocket'
}
dependencySet(group: 'io.undertow', version: '2.2.18.Final') {
dependencySet(group: 'io.undertow', version: '2.2.17.Final') {
entry 'undertow-core'
entry('undertow-servlet') {
exclude group: "org.jboss.spec.javax.servlet", name: "jboss-servlet-api_4.0_spec"
@@ -150,7 +150,7 @@ configure(allprojects) { project ->
}
}
dependency "org.eclipse.jetty:jetty-reactive-httpclient:1.1.12"
dependency "org.eclipse.jetty:jetty-reactive-httpclient:1.1.11"
dependency 'org.apache.httpcomponents.client5:httpclient5:5.1.3'
dependency 'org.apache.httpcomponents.core5:httpcore5-reactive:5.1.3'
dependency("org.apache.httpcomponents:httpclient:4.5.13") {
@@ -188,17 +188,17 @@ configure(allprojects) { project ->
exclude group: "junit", name: "junit"
}
dependency "org.testng:testng:7.4.0"
dependency "org.junit.support:testng-engine:1.0.4"
dependency "org.hamcrest:hamcrest:2.2"
dependency "org.junit.support:testng-engine:1.0.1"
dependency "org.hamcrest:hamcrest:2.1"
dependency "org.awaitility:awaitility:3.1.6"
dependency "org.assertj:assertj-core:3.23.0"
dependency "org.assertj:assertj-core:3.22.0"
dependencySet(group: 'org.xmlunit', version: '2.9.0') {
entry 'xmlunit-assertj'
entry('xmlunit-matchers') {
exclude group: "org.hamcrest", name: "hamcrest-core"
}
}
dependencySet(group: 'org.mockito', version: '4.6.1') {
dependencySet(group: 'org.mockito', version: '4.4.0') {
entry('mockito-core') {
exclude group: "org.hamcrest", name: "hamcrest-core"
}
@@ -206,10 +206,10 @@ configure(allprojects) { project ->
}
dependency "io.mockk:mockk:1.12.1"
dependency("net.sourceforge.htmlunit:htmlunit:2.63.0") {
dependency("net.sourceforge.htmlunit:htmlunit:2.60.0") {
exclude group: "commons-logging", name: "commons-logging"
}
dependency("org.seleniumhq.selenium:htmlunit-driver:2.63.0") {
dependency("org.seleniumhq.selenium:htmlunit-driver:2.60.0") {
exclude group: "commons-logging", name: "commons-logging"
}
dependency("org.seleniumhq.selenium:selenium-java:3.141.59") {
@@ -218,7 +218,7 @@ configure(allprojects) { project ->
}
dependency "org.skyscreamer:jsonassert:1.5.0"
dependency "com.jayway.jsonpath:json-path:2.6.0"
dependency "org.bouncycastle:bcpkix-jdk18on:1.71"
dependency "org.bouncycastle:bcpkix-jdk15on:1.66"
dependencySet(group: 'org.apache.tiles', version: '3.0.8') {
entry 'tiles-api'
@@ -340,7 +340,7 @@ configure([rootProject] + javaProjects) { project ->
}
checkstyle {
toolVersion = "10.3.1"
toolVersion = "10.1"
configDirectory.set(rootProject.file("src/checkstyle"))
}
@@ -380,8 +380,7 @@ configure([rootProject] + javaProjects) { project ->
"https://fasterxml.github.io/jackson-core/javadoc/2.10/",
"https://fasterxml.github.io/jackson-databind/javadoc/2.10/",
"https://fasterxml.github.io/jackson-dataformat-xml/javadoc/2.10/",
// TODO Uncomment once httpclient5 API docs are again online.
// "https://hc.apache.org/httpcomponents-client-5.1.x/current/httpclient5/apidocs/",
"https://hc.apache.org/httpcomponents-client-5.1.x/current/httpclient5/apidocs/",
"https://projectreactor.io/docs/test/release/api/",
"https://junit.org/junit4/javadoc/4.13.2/",
// Disabling linking to JUnit 5.8.2, since the `package-list` file no longer exists due to
@@ -414,8 +413,6 @@ configure(rootProject) {
nohttp {
source.exclude "**/test-output/**"
source.exclude "spring-core/graalvm/build/**" // only available on `main`
source.exclude "spring-core-test/build/**" // only available on `main`
allowlistFile = project.file("src/nohttp/allowlist.lines")
def rootPath = file(rootDir).toPath()
def projectDirs = allprojects.collect { it.projectDir } + "${rootDir}/buildSrc"
+1 -1
View File
@@ -1,4 +1,4 @@
FROM ubuntu:focal-20220531
FROM ubuntu:focal-20220404
ADD setup.sh /setup.sh
ADD get-jdk-url.sh /get-jdk-url.sh
+9 -9
View File
@@ -3,18 +3,18 @@ set -e
case "$1" in
java8)
echo "https://github.com/bell-sw/Liberica/releases/download/8u333+2/bellsoft-jdk8u333+2-linux-amd64.tar.gz"
echo "https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u322-b06/OpenJDK8U-jdk_x64_linux_hotspot_8u322b06.tar.gz"
;;
java11)
echo "https://github.com/bell-sw/Liberica/releases/download/11.0.15.1+2/bellsoft-jdk11.0.15.1+2-linux-amd64.tar.gz"
echo "https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.14.1%2B1/OpenJDK11U-jdk_x64_linux_hotspot_11.0.14.1_1.tar.gz"
;;
java17)
echo "https://github.com/bell-sw/Liberica/releases/download/17.0.3.1+2/bellsoft-jdk17.0.3.1+2-linux-amd64.tar.gz"
;;
java18)
echo "https://github.com/bell-sw/Liberica/releases/download/18.0.1.1+2/bellsoft-jdk18.0.1.1+2-linux-amd64.tar.gz"
;;
*)
java17)
echo "https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.2%2B8/OpenJDK17U-jdk_x64_linux_hotspot_17.0.2_8.tar.gz"
;;
java18)
echo "https://github.com/adoptium/temurin18-binaries/releases/download/jdk-18%2B36/OpenJDK18U-jdk_x64_linux_hotspot_18_36.tar.gz"
;;
*)
echo $"Unknown java version"
exit 1
esac
+2
View File
@@ -14,6 +14,8 @@ rm -rf /var/lib/apt/lists/*
curl https://raw.githubusercontent.com/spring-io/concourse-java-scripts/v0.0.4/concourse-java.sh > /opt/concourse-java.sh
curl --output /opt/concourse-release-scripts.jar https://repo.spring.io/release/io/spring/concourse/releasescripts/concourse-release-scripts/0.3.2/concourse-release-scripts-0.3.2.jar
###########################################################
# JAVA
###########################################################
-4
View File
@@ -1,6 +1,5 @@
github-repo: "https://github.com/spring-projects/spring-framework.git"
github-repo-name: "spring-projects/spring-framework"
sonatype-staging-profile: "org.springframework"
docker-hub-organization: "springci"
artifactory-server: "https://repo.spring.io"
branch: "5.3.x"
@@ -8,7 +7,4 @@ milestone: "5.3.x"
build-name: "spring-framework"
pipeline-name: "spring-framework"
concourse-url: "https://ci.spring.io"
registry-mirror-host: docker.repo.spring.io
registry-mirror-username: ((artifactory-username))
registry-mirror-password: ((artifactory-password))
task-timeout: 1h00m
+10 -18
View File
@@ -12,7 +12,7 @@ anchors:
SONATYPE_USERNAME: ((sonatype-username))
SONATYPE_PASSWORD: ((sonatype-password))
SONATYPE_URL: ((sonatype-url))
SONATYPE_STAGING_PROFILE: ((sonatype-staging-profile))
SONATYPE_STAGING_PROFILE_ID: ((sonatype-staging-profile-id))
artifactory-task-params: &artifactory-task-params
ARTIFACTORY_SERVER: ((artifactory-server))
ARTIFACTORY_USERNAME: ((artifactory-username))
@@ -24,10 +24,6 @@ anchors:
username: ((docker-hub-username))
password: ((docker-hub-password))
tag: ((milestone))
registry-mirror-vars: &registry-mirror-vars
registry-mirror-host: ((registry-mirror-host))
registry-mirror-username: ((registry-mirror-username))
registry-mirror-password: ((registry-mirror-password))
slack-fail-params: &slack-fail-params
text: >
:concourse-failed: <https://ci.spring.io/teams/${BUILD_TEAM_NAME}/pipelines/${BUILD_PIPELINE_NAME}/jobs/${BUILD_JOB_NAME}/builds/${BUILD_NAME}|${BUILD_PIPELINE_NAME} ${BUILD_JOB_NAME} failed!>
@@ -96,7 +92,7 @@ resources:
branch: ((branch))
paths: ["ci/images/*"]
- name: ci-image
type: registry-image
type: docker-image
icon: docker
source:
<<: *docker-resource-source
@@ -166,20 +162,13 @@ resources:
jobs:
- name: build-ci-images
plan:
- get: git-repo
- get: ci-images-git-repo
trigger: true
- task: build-ci-image
privileged: true
file: git-repo/ci/tasks/build-ci-image.yml
output_mapping:
image: ci-image
vars:
ci-image-name: ci-image
<<: *registry-mirror-vars
- get: ci-images-git-repo
trigger: true
- in_parallel:
- put: ci-image
params:
image: ci-image/image.tar
build: ci-images-git-repo/ci/images
dockerfile: ci-images-git-repo/ci/images/ci-image/Dockerfile
- name: build
serial: true
public: true
@@ -356,6 +345,7 @@ jobs:
download_artifacts: false
save_build_info: true
- task: promote
image: ci-image
file: git-repo/ci/tasks/promote-version.yml
params:
RELEASE_TYPE: M
@@ -400,6 +390,7 @@ jobs:
download_artifacts: false
save_build_info: true
- task: promote
image: ci-image
file: git-repo/ci/tasks/promote-version.yml
params:
RELEASE_TYPE: RC
@@ -444,6 +435,7 @@ jobs:
download_artifacts: true
save_build_info: true
- task: promote
image: ci-image
file: git-repo/ci/tasks/promote-version.yml
params:
RELEASE_TYPE: RELEASE
+2 -2
View File
@@ -6,11 +6,11 @@ CONFIG_DIR=git-repo/ci/config
version=$( cat artifactory-repo/build-info.json | jq -r '.buildInfo.modules[0].id' | sed 's/.*:.*:\(.*\)/\1/' )
export BUILD_INFO_LOCATION=$(pwd)/artifactory-repo/build-info.json
java -jar /concourse-release-scripts.jar \
java -jar /opt/concourse-release-scripts.jar \
--spring.config.location=${CONFIG_DIR}/release-scripts.yml \
publishToCentral $RELEASE_TYPE $BUILD_INFO_LOCATION artifactory-repo || { exit 1; }
java -jar /concourse-release-scripts.jar \
java -jar /opt/concourse-release-scripts.jar \
--spring.config.location=${CONFIG_DIR}/release-scripts.yml \
promote $RELEASE_TYPE $BUILD_INFO_LOCATION || { exit 1; }
+8
View File
@@ -0,0 +1,8 @@
#!/bin/bash
export BUILD_INFO_LOCATION=$(pwd)/artifactory-repo/build-info.json
version=$( cat artifactory-repo/build-info.json | jq -r '.buildInfo.modules[0].id' | sed 's/.*:.*:\(.*\)/\1/' )
java -jar /opt/concourse-release-scripts.jar syncToCentral "RELEASE" $BUILD_INFO_LOCATION || { exit 1; }
echo "Sync complete"
echo $version > version/version
-31
View File
@@ -1,31 +0,0 @@
---
platform: linux
image_resource:
type: registry-image
source:
repository: concourse/oci-build-task
tag: 0.9.1
registry_mirror:
host: ((registry-mirror-host))
username: ((registry-mirror-username))
password: ((registry-mirror-password))
inputs:
- name: ci-images-git-repo
outputs:
- name: image
caches:
- path: ci-image-cache
params:
CONTEXT: ci-images-git-repo/ci/images
DOCKERFILE: ci-images-git-repo/ci/images/ci-image/Dockerfile
DOCKER_HUB_AUTH: ((docker-hub-auth))
run:
path: /bin/sh
args:
- "-c"
- |
mkdir -p /root/.docker
cat > /root/.docker/config.json <<EOF
{ "auths": { "https://index.docker.io/v1/": { "auth": "$DOCKER_HUB_AUTH" }}}
EOF
build
+1 -6
View File
@@ -1,10 +1,5 @@
---
platform: linux
image_resource:
type: registry-image
source:
repository: springio/concourse-release-scripts
tag: '0.3.4'
inputs:
- name: git-repo
- name: artifactory-repo
@@ -18,6 +13,6 @@ params:
SONATYPE_USER:
SONATYPE_PASSWORD:
SONATYPE_URL:
SONATYPE_STAGING_PROFILE:
SONATYPE_STAGING_PROFILE_ID:
run:
path: git-repo/ci/scripts/promote-version.sh
+3 -3
View File
@@ -1,5 +1,5 @@
version=5.3.22
org.gradle.jvmargs=-Xmx2048m
version=5.3.19
org.gradle.jvmargs=-Xmx1536M
org.gradle.caching=true
org.gradle.parallel=true
kotlin.stdlib.default.dependency=false
kotlin.stdlib.default.dependency=false
-2
View File
@@ -72,7 +72,6 @@ eclipse.classpath.file.whenMerged {
// Include project specific settings
task eclipseSettings(type: Copy) {
from rootProject.files(
'src/eclipse/org.eclipse.core.resources.prefs',
'src/eclipse/org.eclipse.jdt.core.prefs',
'src/eclipse/org.eclipse.jdt.ui.prefs')
into project.file('.settings/')
@@ -80,7 +79,6 @@ task eclipseSettings(type: Copy) {
}
task cleanEclipseSettings(type: Delete) {
delete project.file('.settings/org.eclipse.core.resources.prefs')
delete project.file('.settings/org.eclipse.jdt.core.prefs')
delete project.file('.settings/org.eclipse.jdt.ui.prefs')
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 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.
@@ -28,7 +28,7 @@ import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatException;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
/**
* Integration tests for advice invocation order for advice configured via the
@@ -52,7 +52,7 @@ class AopNamespaceHandlerAdviceOrderIntegrationTests {
assertThat(aspect.invocations).containsExactly("around - start", "before", "around - end", "after", "after returning");
aspect.invocations.clear();
assertThatException().isThrownBy(() -> echo.echo(new Exception()));
assertThatExceptionOfType(Exception.class).isThrownBy(() -> echo.echo(new Exception()));
assertThat(aspect.invocations).containsExactly("around - start", "before", "around - end", "after", "after throwing");
}
}
@@ -69,7 +69,7 @@ class AopNamespaceHandlerAdviceOrderIntegrationTests {
assertThat(aspect.invocations).containsExactly("around - start", "before", "around - end", "after returning", "after");
aspect.invocations.clear();
assertThatException().isThrownBy(() -> echo.echo(new Exception()));
assertThatExceptionOfType(Exception.class).isThrownBy(() -> echo.echo(new Exception()));
assertThat(aspect.invocations).containsExactly("around - start", "before", "around - end", "after throwing", "after");
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 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.
@@ -38,7 +38,7 @@ import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatException;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
/**
* Integration tests for advice invocation order for advice configured via
@@ -65,7 +65,8 @@ class AspectJAutoProxyAdviceOrderIntegrationTests {
assertThat(aspect.invocations).containsExactly("around - start", "before", "after returning", "after", "around - end");
aspect.invocations.clear();
assertThatException().isThrownBy(() -> echo.echo(new Exception()));
assertThatExceptionOfType(Exception.class).isThrownBy(
() -> echo.echo(new Exception()));
assertThat(aspect.invocations).containsExactly("around - start", "before", "after throwing", "after", "around - end");
}
}
@@ -94,7 +95,8 @@ class AspectJAutoProxyAdviceOrderIntegrationTests {
assertThat(aspect.invocations).containsExactly("around - start", "before", "after returning", "after", "around - end");
aspect.invocations.clear();
assertThatException().isThrownBy(() -> echo.echo(new Exception()));
assertThatExceptionOfType(Exception.class).isThrownBy(
() -> echo.echo(new Exception()));
assertThat(aspect.invocations).containsExactly("around - start", "before", "after throwing", "after", "around - end");
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 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.
@@ -34,7 +34,7 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Repository;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatException;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
/**
* Integration tests for the @EnableCaching annotation.
@@ -62,7 +62,8 @@ class EnableCachingIntegrationTests {
// this test is a bit fragile, but gets the job done, proving that an
// attempt was made to look up the AJ aspect. It's due to classpath issues
// in .integration-tests that it's not found.
assertThatException().isThrownBy(ctx::refresh)
assertThatExceptionOfType(Exception.class).isThrownBy(
ctx::refresh)
.withMessageContaining("AspectJCachingConfiguration");
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 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.
@@ -45,7 +45,7 @@ import org.springframework.transaction.interceptor.BeanFactoryTransactionAttribu
import org.springframework.transaction.testfixture.CallCountingTransactionManager;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatException;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
/**
* Integration tests for the @EnableTransactionManagement annotation.
@@ -98,7 +98,7 @@ class EnableTransactionManagementIntegrationTests {
// this test is a bit fragile, but gets the job done, proving that an
// attempt was made to look up the AJ aspect. It's due to classpath issues
// in .integration-tests that it's not found.
assertThatException()
assertThatExceptionOfType(Exception.class)
.isThrownBy(ctx::refresh)
.withMessageContaining("AspectJJtaTransactionManagementConfiguration");
}
+2 -2
View File
@@ -7,8 +7,8 @@ pluginManagement {
}
plugins {
id "com.gradle.enterprise" version "3.10.2"
id "io.spring.ge.conventions" version "0.0.10"
id "com.gradle.enterprise" version "3.8.1"
id "io.spring.ge.conventions" version "0.0.9"
}
include "spring-aop"
@@ -63,7 +63,7 @@ public interface Joinpoint {
/**
* Return the static part of this joinpoint.
* <p>The static part is an accessible object on which a chain of
* interceptors is installed.
* interceptors are installed.
*/
@Nonnull
AccessibleObject getStaticPart();
@@ -36,7 +36,7 @@ public interface IntroductionAwareMethodMatcher extends MethodMatcher {
* @param targetClass the target class
* @param hasIntroductions {@code true} if the object on whose behalf we are
* asking is the subject on one or more introductions; {@code false} otherwise
* @return whether this method matches statically
* @return whether or not this method matches statically
*/
boolean matches(Method method, Class<?> targetClass, boolean hasIntroductions);
@@ -60,7 +60,7 @@ public interface MethodMatcher {
* will be made.
* @param method the candidate method
* @param targetClass the target class
* @return whether this method matches statically
* @return whether or not this method matches statically
*/
boolean matches(Method method, Class<?> targetClass);
@@ -70,7 +70,7 @@ public interface MethodMatcher {
* runtime even if the 2-arg matches method returns {@code true}?
* <p>Can be invoked when an AOP proxy is created, and need not be invoked
* again before each method invocation,
* @return whether a runtime match via the 3-arg
* @return whether or not a runtime match via the 3-arg
* {@link #matches(java.lang.reflect.Method, Class, Object[])} method
* is required if static matching passed
*/
@@ -18,7 +18,7 @@ package org.springframework.aop;
/**
* Marker interface implemented by all AOP proxies. Used to detect
* whether objects are Spring-generated proxies.
* whether or not objects are Spring-generated proxies.
*
* @author Rob Harrop
* @since 2.0.1
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 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.
@@ -368,7 +368,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
* to which argument name. There are multiple strategies for determining
* this binding, which are arranged in a ChainOfResponsibility.
*/
public final void calculateArgumentBindings() {
public final synchronized void calculateArgumentBindings() {
// The simple case... nothing to bind.
if (this.argumentsIntrospected || this.parameterTypes.length == 0) {
return;
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* 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.
@@ -378,7 +378,7 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut
}
catch (Throwable ex) {
if (logger.isDebugEnabled()) {
logger.debug("Failed to evaluate join point for arguments " + Arrays.toString(args) +
logger.debug("Failed to evaluate join point for arguments " + Arrays.asList(args) +
" - falling back to non-match", ex);
}
return false;
@@ -39,7 +39,7 @@ import org.springframework.lang.Nullable;
public interface AspectJAdvisorFactory {
/**
* Determine whether the given class is an aspect, as reported
* Determine whether or not the given class is an aspect, as reported
* by AspectJ's {@link org.aspectj.lang.reflect.AjTypeSystem}.
* <p>Will simply return {@code false} if the supposed aspect is
* invalid (such as an extension of a concrete aspect class).
@@ -47,7 +47,7 @@ public interface AspectJAdvisorFactory {
* such as those with unsupported instantiation models.
* Use the {@link #validate} method to handle these cases if necessary.
* @param clazz the supposed annotation-style AspectJ class
* @return whether this class is recognized by AspectJ as an aspect class
* @return whether or not this class is recognized by AspectJ as an aspect class
*/
boolean isAspect(Class<?> clazz);
@@ -67,7 +67,7 @@ public class AspectMetadata implements Serializable {
/**
* Spring AOP pointcut corresponding to the per clause of the
* aspect. Will be the {@code Pointcut.TRUE} canonical instance in the
* aspect. Will be the Pointcut.TRUE canonical instance in the
* case of a singleton, otherwise an AspectJExpressionPointcut.
*/
private final Pointcut perClausePointcut;
@@ -60,8 +60,8 @@ public class AspectJAwareAdvisorAutoProxyCreator extends AbstractAdvisorAutoProx
* <li>Otherwise the advice declared first gets highest precedence (i.e., runs
* first).</li>
* </ul>
* <p><b>Important:</b> Advisors are sorted in precedence order, from the highest
* precedence to the lowest. "On the way in" to a join point, the highest precedence
* <p><b>Important:</b> Advisors are sorted in precedence order, from highest
* precedence to lowest. "On the way in" to a join point, the highest precedence
* advisor should run first. "On the way out" of a join point, the highest
* precedence advisor should run last.
*/
@@ -314,7 +314,7 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
}
/**
* Add all the given advisors to this proxy configuration.
* Add all of the given advisors to this proxy configuration.
* @param advisors the advisors to register
*/
public void addAdvisors(Advisor... advisors) {
@@ -322,7 +322,7 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
}
/**
* Add all the given advisors to this proxy configuration.
* Add all of the given advisors to this proxy configuration.
* @param advisors the advisors to register
*/
public void addAdvisors(Collection<Advisor> advisors) {
@@ -72,8 +72,8 @@ final class JdkDynamicAopProxy implements AopProxy, InvocationHandler, Serializa
* NOTE: We could avoid the code duplication between this class and the CGLIB
* proxies by refactoring "invoke" into a template method. However, this approach
* adds at least 10% performance overhead versus a copy-paste solution, so we sacrifice
* elegance for performance (we have a good test suite to ensure that the different
* proxies behave the same :-)).
* elegance for performance. (We have a good test suite to ensure that the different
* proxies behave the same :-)
* This way, we can also more easily take advantage of minor optimizations in each class.
*/
@@ -198,7 +198,7 @@ final class JdkDynamicAopProxy implements AopProxy, InvocationHandler, Serializa
// Get the interception chain for this method.
List<Object> chain = this.advised.getInterceptorsAndDynamicInterceptionAdvice(method, targetClass);
// Check whether we have any advice. If we don't, we can fall back on direct
// Check whether we have any advice. If we don't, we can fallback on direct
// reflective invocation of the target, and avoid creating a MethodInvocation.
if (chain.isEmpty()) {
// We can skip creating a MethodInvocation: just invoke the target directly
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* 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.
@@ -50,7 +50,7 @@ import org.springframework.util.ObjectUtils;
/**
* {@link org.springframework.beans.factory.FactoryBean} implementation that builds an
* AOP proxy based on beans in a Spring {@link org.springframework.beans.factory.BeanFactory}.
* AOP proxy based on beans in Spring {@link org.springframework.beans.factory.BeanFactory}.
*
* <p>{@link org.aopalliance.intercept.MethodInterceptor MethodInterceptors} and
* {@link org.springframework.aop.Advisor Advisors} are identified by a list of bean
@@ -61,11 +61,10 @@ import org.springframework.util.ObjectUtils;
*
* <p>Global interceptors and advisors can be added at the factory level. The specified
* ones are expanded in an interceptor list where an "xxx*" entry is included in the
* list, matching the given prefix with the bean names &mdash; for example, "global*"
* would match both "globalBean1" and "globalBean2"; whereas, "*" would match all
* defined interceptors. The matching interceptors get applied according to their
* returned order value, if they implement the {@link org.springframework.core.Ordered}
* interface.
* list, matching the given prefix with the bean names (e.g. "global*" would match
* both "globalBean1" and "globalBean2", "*" all defined interceptors). The matching
* interceptors get applied according to their returned order value, if they implement
* the {@link org.springframework.core.Ordered} interface.
*
* <p>Creates a JDK proxy when proxy interfaces are given, and a CGLIB proxy for the
* actual target class if not. Note that the latter will only work if the target class
@@ -76,7 +75,7 @@ import org.springframework.util.ObjectUtils;
* This won't work for existing prototype references, which are independent. However,
* it will work for prototypes subsequently obtained from the factory. Changes to
* interception will work immediately on singletons (including existing references).
* However, to change interfaces or a target it's necessary to obtain a new instance
* However, to change interfaces or target it's necessary to obtain a new instance
* from the factory. This means that singleton instances obtained from the factory
* do not have the same object identity. However, they do have the same interceptors
* and target, and changing any reference will change all objects.
@@ -407,7 +406,7 @@ public class ProxyFactoryBean extends ProxyCreatorSupport
if (namedBeanClass != null) {
return (Advisor.class.isAssignableFrom(namedBeanClass) || Advice.class.isAssignableFrom(namedBeanClass));
}
// Treat it as a target bean if we can't tell.
// Treat it as an target bean if we can't tell.
if (logger.isDebugEnabled()) {
logger.debug("Could not determine type of bean with name '" + beanName +
"' - assuming it is neither an Advisor nor an Advice");
@@ -425,7 +424,7 @@ public class ProxyFactoryBean extends ProxyCreatorSupport
if (!this.advisorChainInitialized && !ObjectUtils.isEmpty(this.interceptorNames)) {
if (this.beanFactory == null) {
throw new IllegalStateException("No BeanFactory available anymore (probably due to serialization) " +
"- cannot resolve interceptor names " + Arrays.toString(this.interceptorNames));
"- cannot resolve interceptor names " + Arrays.asList(this.interceptorNames));
}
// Globals can't be last unless we specified a targetSource using the property...
@@ -119,7 +119,7 @@ public abstract class AbstractAutoProxyCreator extends ProxyProcessorSupport
private AdvisorAdapterRegistry advisorAdapterRegistry = GlobalAdvisorAdapterRegistry.getInstance();
/**
* Indicates whether the proxy should be frozen. Overridden from super
* Indicates whether or not the proxy should be frozen. Overridden from super
* to prevent the configuration from becoming frozen too early.
*/
private boolean freezeProxy = false;
@@ -145,7 +145,7 @@ public abstract class AbstractAutoProxyCreator extends ProxyProcessorSupport
/**
* Set whether the proxy should be frozen, preventing advice
* Set whether or not the proxy should be frozen, preventing advice
* from being added to it once it is created.
* <p>Overridden from the super class to prevent the proxy configuration
* from being frozen before the proxy is created.
@@ -56,7 +56,7 @@ public abstract class AbstractTraceInterceptor implements MethodInterceptor, Ser
protected transient Log defaultLogger = LogFactory.getLog(getClass());
/**
* Indicates whether proxy class names should be hidden when using dynamic loggers.
* Indicates whether or not proxy class names should be hidden when using dynamic loggers.
* @see #setUseDynamicLogger
*/
private boolean hideProxyClassNames = false;
@@ -119,7 +119,7 @@ public abstract class AbstractTraceInterceptor implements MethodInterceptor, Ser
/**
* Determines whether logging is enabled for the particular {@code MethodInvocation}.
* Determines whether or not logging is enabled for the particular {@code MethodInvocation}.
* If not, the method invocation proceeds as normal, otherwise the method invocation is passed
* to the {@code invokeUnderTrace} method for handling.
* @see #invokeUnderTrace(org.aopalliance.intercept.MethodInvocation, org.apache.commons.logging.Log)
@@ -36,7 +36,7 @@ public interface AsyncUncaughtExceptionHandler {
* Handle the given uncaught exception thrown from an asynchronous method.
* @param ex the exception thrown from the asynchronous method
* @param method the asynchronous method
* @param params the parameters used to invoke the method
* @param params the parameters used to invoked the method
*/
void handleUncaughtException(Throwable ex, Method method, Object... params);
@@ -217,7 +217,7 @@ public abstract class AopUtils {
* out a pointcut for a class.
* @param pc the static or dynamic pointcut to check
* @param targetClass the class to test
* @param hasIntroductions whether the advisor chain
* @param hasIntroductions whether or not the advisor chain
* for this bean includes any introductions
* @return whether the pointcut can apply on any method
*/
@@ -261,7 +261,7 @@ public abstract class AopUtils {
/**
* Can the given advisor apply at all on the given class?
* This is an important test as it can be used to optimize
* out an advisor for a class.
* out a advisor for a class.
* @param advisor the advisor to check
* @param targetClass class we're testing
* @return whether the pointcut can apply on any method
@@ -272,11 +272,11 @@ public abstract class AopUtils {
/**
* Can the given advisor apply at all on the given class?
* <p>This is an important test as it can be used to optimize out an advisor for a class.
* <p>This is an important test as it can be used to optimize out a advisor for a class.
* This version also takes into account introductions (for IntroductionAwareMethodMatchers).
* @param advisor the advisor to check
* @param targetClass class we're testing
* @param hasIntroductions whether the advisor chain for this bean includes
* @param hasIntroductions whether or not the advisor chain for this bean includes
* any introductions
* @return whether the pointcut can apply on any method
*/
@@ -43,7 +43,7 @@ public class DefaultPointcutAdvisor extends AbstractGenericPointcutAdvisor imple
/**
* Create an empty DefaultPointcutAdvisor.
* <p>Advice must be set before using setter methods.
* <p>Advice must be set before use using setter methods.
* Pointcut will normally be set also, but defaults to {@code Pointcut.TRUE}.
*/
public DefaultPointcutAdvisor() {
@@ -90,7 +90,7 @@ public abstract class MethodMatchers {
* @param targetClass the target class
* @param hasIntroductions {@code true} if the object on whose behalf we are
* asking is the subject on one or more introductions; {@code false} otherwise
* @return whether this method matches statically
* @return whether or not this method matches statically
*/
public static boolean matches(MethodMatcher mm, Method method, Class<?> targetClass, boolean hasIntroductions) {
Assert.notNull(mm, "MethodMatcher must not be null");
@@ -37,7 +37,7 @@ import org.springframework.lang.Nullable;
* {@link AbstractPrototypeBasedTargetSource} can be used to create objects
* in order to put them into the pool.
*
* <p>Subclasses must also implement some monitoring methods from the
* <p>Subclasses must also implement some of the monitoring methods from the
* {@link PoolingConfig} interface. The {@link #getPoolingConfigMixin()} method
* makes these stats available on proxied objects through an IntroductionAdvisor.
*
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 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.
@@ -142,11 +142,11 @@ public class TrickyAspectJPointcutExpressionTests {
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
@interface Log {
public static @interface Log {
}
public interface TestService {
public static interface TestService {
public String sayHello();
}
@@ -931,7 +931,7 @@ abstract class AbstractMakeModifiable {
return setter.getDeclaringClass().getMethod(getterName);
}
catch (NoSuchMethodException ex) {
// must be write-only
// must be write only
return null;
}
}
@@ -48,7 +48,7 @@ public class IntroductionBenchmarkTests {
}
}
public interface Counter {
public static interface Counter {
int getCount();
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* 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.
@@ -44,7 +44,7 @@ import org.springframework.core.annotation.Order;
import org.springframework.core.testfixture.TimeStamped;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatRuntimeException;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
/**
* Also tests AdvisedSupport and ProxyCreatorSupport superclasses.
@@ -277,7 +277,7 @@ public class ProxyFactoryTests {
assertThat(config.getAdvisors().length == oldCount).isTrue();
assertThatRuntimeException()
assertThatExceptionOfType(RuntimeException.class)
.as("Existing object won't implement this interface any more")
.isThrownBy(ts::getTimeStamp); // Existing reference will fail
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 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.
@@ -26,7 +26,6 @@ import org.junit.jupiter.api.Test;
import org.springframework.aop.testfixture.advice.MyThrowsHandler;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatException;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.mockito.BDDMockito.given;
@@ -64,7 +63,9 @@ public class ThrowsAdviceInterceptorTests {
Exception ex = new Exception();
MethodInvocation mi = mock(MethodInvocation.class);
given(mi.proceed()).willThrow(ex);
assertThatException().isThrownBy(() -> ti.invoke(mi)).isSameAs(ex);
assertThatExceptionOfType(Exception.class).isThrownBy(() ->
ti.invoke(mi))
.isSameAs(ex);
assertThat(th.getCalls()).isEqualTo(0);
}
@@ -307,7 +307,7 @@ public class DelegatingIntroductionInterceptorTests {
}
private interface SubTimeStamped extends TimeStamped {
private static interface SubTimeStamped extends TimeStamped {
}
}
@@ -26,7 +26,7 @@ import org.springframework.context.annotation.Import;
/**
* Signals the current application context to apply dependency injection to
* non-managed classes that are instantiated outside the Spring bean factory
* non-managed classes that are instantiated outside of the Spring bean factory
* (typically classes annotated with the
* {@link org.springframework.beans.factory.annotation.Configurable @Configurable}
* annotation).
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 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.
@@ -22,9 +22,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.transaction.testfixture.CallCountingTransactionManager;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatException;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.assertj.core.api.Assertions.assertThatRuntimeException;
/**
* @author Rod Johnson
@@ -106,44 +104,44 @@ public class TransactionAspectTests {
@Test
public void defaultCommitOnAnnotatedClass() throws Throwable {
Exception ex = new Exception();
assertThatException()
.isThrownBy(() -> testRollback(() -> annotationOnlyOnClassWithNoInterface.echo(ex), false))
assertThatExceptionOfType(Exception.class).isThrownBy(() ->
testRollback(() -> annotationOnlyOnClassWithNoInterface.echo(ex), false))
.isSameAs(ex);
}
@Test
public void defaultRollbackOnAnnotatedClass() throws Throwable {
RuntimeException ex = new RuntimeException();
assertThatRuntimeException()
.isThrownBy(() -> testRollback(() -> annotationOnlyOnClassWithNoInterface.echo(ex), true))
assertThatExceptionOfType(RuntimeException.class).isThrownBy(() ->
testRollback(() -> annotationOnlyOnClassWithNoInterface.echo(ex), true))
.isSameAs(ex);
}
@Test
public void defaultCommitOnSubclassOfAnnotatedClass() throws Throwable {
Exception ex = new Exception();
assertThatException()
.isThrownBy(() -> testRollback(() -> new SubclassOfClassWithTransactionalAnnotation().echo(ex), false))
assertThatExceptionOfType(Exception.class).isThrownBy(() ->
testRollback(() -> new SubclassOfClassWithTransactionalAnnotation().echo(ex), false))
.isSameAs(ex);
}
@Test
public void defaultCommitOnSubclassOfClassWithTransactionalMethodAnnotated() throws Throwable {
Exception ex = new Exception();
assertThatException()
.isThrownBy(() -> testRollback(() -> new SubclassOfClassWithTransactionalMethodAnnotation().echo(ex), false))
assertThatExceptionOfType(Exception.class).isThrownBy(() ->
testRollback(() -> new SubclassOfClassWithTransactionalMethodAnnotation().echo(ex), false))
.isSameAs(ex);
}
@Test
public void noCommitOnImplementationOfAnnotatedInterface() throws Throwable {
Exception ex = new Exception();
final Exception ex = new Exception();
testNotTransactional(() -> new ImplementsAnnotatedInterface().echo(ex), ex);
}
@Test
public void noRollbackOnImplementationOfAnnotatedInterface() throws Throwable {
Exception rollbackProvokingException = new RuntimeException();
final Exception rollbackProvokingException = new RuntimeException();
testNotTransactional(() -> new ImplementsAnnotatedInterface().echo(rollbackProvokingException),
rollbackProvokingException);
}
@@ -167,9 +165,8 @@ public class TransactionAspectTests {
protected void testNotTransactional(TransactionOperationCallback toc, Throwable expected) throws Throwable {
txManager.clear();
assertThat(txManager.begun).isEqualTo(0);
assertThatExceptionOfType(Throwable.class)
.isThrownBy(toc::performTransactionalOperation)
.isSameAs(expected);
assertThatExceptionOfType(Throwable.class).isThrownBy(
toc::performTransactionalOperation).isSameAs(expected);
assertThat(txManager.begun).isEqualTo(0);
}
@@ -82,7 +82,7 @@ public interface BeanWrapper extends ConfigurablePropertyAccessor {
* Obtain the property descriptor for a specific property
* of the wrapped object.
* @param propertyName the property to obtain the descriptor for
* (may be a nested path, but not an indexed/mapped property)
* (may be a nested path, but no indexed/mapped property)
* @return the property descriptor for the specified property
* @throws InvalidPropertyException if there is no such property
*/
@@ -22,7 +22,6 @@ import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.net.URL;
import java.security.ProtectionDomain;
import java.util.Collections;
import java.util.HashSet;
@@ -293,12 +292,10 @@ public final class CachedIntrospectionResults {
// Only allow all name variants of Class properties
continue;
}
if (URL.class == beanClass && "content".equals(pd.getName())) {
// Only allow URL attribute introspection, not content resolution
continue;
}
if (pd.getWriteMethod() == null && isInvalidReadOnlyPropertyType(pd.getPropertyType())) {
// Ignore read-only properties such as ClassLoader - no need to bind to those
if (pd.getWriteMethod() == null && pd.getPropertyType() != null &&
(ClassLoader.class.isAssignableFrom(pd.getPropertyType()) ||
ProtectionDomain.class.isAssignableFrom(pd.getPropertyType()))) {
// Ignore ClassLoader and ProtectionDomain read-only properties - no need to bind to those
continue;
}
if (logger.isTraceEnabled()) {
@@ -347,8 +344,10 @@ public final class CachedIntrospectionResults {
// GenericTypeAwarePropertyDescriptor leniently resolves a set* write method
// against a declared read method, so we prefer read method descriptors here.
pd = buildGenericTypeAwarePropertyDescriptor(beanClass, pd);
if (pd.getWriteMethod() == null && isInvalidReadOnlyPropertyType(pd.getPropertyType())) {
// Ignore read-only properties such as ClassLoader - no need to bind to those
if (pd.getWriteMethod() == null && pd.getPropertyType() != null &&
(ClassLoader.class.isAssignableFrom(pd.getPropertyType()) ||
ProtectionDomain.class.isAssignableFrom(pd.getPropertyType()))) {
// Ignore ClassLoader and ProtectionDomain read-only properties - no need to bind to those
continue;
}
this.propertyDescriptors.put(pd.getName(), pd);
@@ -380,7 +379,8 @@ public final class CachedIntrospectionResults {
if (Modifier.isStatic(method.getModifiers()) ||
method.getDeclaringClass() == Object.class || method.getDeclaringClass() == Class.class ||
method.getParameterCount() > 0 || method.getReturnType() == void.class ||
isInvalidReadOnlyPropertyType(method.getReturnType())) {
ClassLoader.class.isAssignableFrom(method.getReturnType()) ||
ProtectionDomain.class.isAssignableFrom(method.getReturnType())) {
return false;
}
try {
@@ -393,12 +393,6 @@ public final class CachedIntrospectionResults {
}
}
private boolean isInvalidReadOnlyPropertyType(@Nullable Class<?> returnType) {
return (returnType != null && (AutoCloseable.class.isAssignableFrom(returnType) ||
ClassLoader.class.isAssignableFrom(returnType) ||
ProtectionDomain.class.isAssignableFrom(returnType)));
}
BeanInfo getBeanInfo() {
return this.beanInfo;
@@ -327,7 +327,7 @@ public class MutablePropertyValues implements PropertyValues, Serializable {
/**
* Register the specified property as "processed" in the sense
* of some processor calling the corresponding setter method
* outside the PropertyValue(s) mechanism.
* outside of the PropertyValue(s) mechanism.
* <p>This will lead to {@code true} being returned from
* a {@link #contains} call for the specified property.
* @param propertyName the name of the property.
@@ -22,7 +22,7 @@ package org.springframework.beans;
* {@link org.springframework.beans.PropertyEditorRegistry property editor registry}.
*
* <p>This is particularly useful when you need to use the same set of
* property editors in several situations: write a corresponding
* property editors in several different situations: write a corresponding
* registrar and reuse that in each case.
*
* @author Juergen Hoeller
@@ -45,7 +45,7 @@ import org.springframework.lang.Nullable;
*
* <p><b>The container is only responsible for managing the lifecycle of the FactoryBean
* instance, not the lifecycle of the objects created by the FactoryBean.</b> Therefore,
* a destroy method on an exposed bean object (such as {@link java.io.Closeable#close()})
* a destroy method on an exposed bean object (such as {@link java.io.Closeable#close()}
* will <i>not</i> be called automatically. Instead, a FactoryBean should implement
* {@link DisposableBean} and delegate any such close call to the underlying object.
*
@@ -108,7 +108,7 @@ public interface FactoryBean<T> {
* been fully initialized. It must not rely on state created during
* initialization; of course, it can still use such state if available.
* <p><b>NOTE:</b> Autowiring will simply ignore FactoryBeans that return
* {@code null} here. Therefore, it is highly recommended to implement
* {@code null} here. Therefore it is highly recommended to implement
* this method properly, using the current state of the FactoryBean.
* @return the type of object that this FactoryBean creates,
* or {@code null} if not known at the time of the call
@@ -343,7 +343,7 @@ public interface ListableBeanFactory extends BeanFactory {
/**
* Find an {@link Annotation} of {@code annotationType} on the specified bean,
* traversing its interfaces and superclasses if no annotation can be found on
* traversing its interfaces and super classes if no annotation can be found on
* the given class itself, as well as checking the bean's factory method (if any).
* @param beanName the name of the bean to look for annotations on
* @param annotationType the type of annotation to look for
@@ -361,7 +361,7 @@ public interface ListableBeanFactory extends BeanFactory {
/**
* Find an {@link Annotation} of {@code annotationType} on the specified bean,
* traversing its interfaces and superclasses if no annotation can be found on
* traversing its interfaces and super classes if no annotation can be found on
* the given class itself, as well as checking the bean's factory method (if any).
* @param beanName the name of the bean to look for annotations on
* @param annotationType the type of annotation to look for
@@ -137,7 +137,7 @@ public class QualifierAnnotationAutowireCandidateResolver extends GenericTypeAwa
* as a <em>qualifier</em>, the bean must 'match' against the annotation as
* well as any attributes it may contain. The bean definition must contain
* the same qualifier or match by meta attributes. A "value" attribute will
* fall back to match against the bean name or an alias if a qualifier or
* fallback to match against the bean name or an alias if a qualifier or
* attribute does not match.
* @see Qualifier
*/
@@ -186,7 +186,7 @@ public class QualifierAnnotationAutowireCandidateResolver extends GenericTypeAwa
if (isQualifier(metaType)) {
foundMeta = true;
// Only accept fallback match if @Qualifier annotation has a value...
// Otherwise, it is just a marker for a custom qualifier annotation.
// Otherwise it is just a marker for a custom qualifier annotation.
if ((fallbackToMeta && ObjectUtils.isEmpty(AnnotationUtils.getValue(metaAnn))) ||
!checkQualifier(bdHolder, metaAnn, typeConverter)) {
return false;
@@ -30,7 +30,7 @@ import org.springframework.beans.BeansException;
*
* <p>A {@code BeanFactoryPostProcessor} may interact with and modify bean
* definitions, but never bean instances. Doing so may cause premature bean
* instantiation, violating the container and causing unintended side effects.
* instantiation, violating the container and causing unintended side-effects.
* If bean instance interaction is required, consider implementing
* {@link BeanPostProcessor} instead.
*
@@ -65,7 +65,7 @@ public class ConstructorArgumentValues {
/**
* Copy all given argument values into this object, using separate holder
* instances to keep the values independent of the original object.
* instances to keep the values independent from the original object.
* <p>Note: Identical ValueHolder instances will only be registered once,
* to allow for merging and re-merging of argument value definitions. Distinct
* ValueHolder instances carrying the same content are of course allowed.
@@ -155,7 +155,7 @@ public abstract class YamlProcessor {
* resources. Each resource is parsed in turn and the documents inside checked against
* the {@link #setDocumentMatchers(DocumentMatcher...) matchers}. If a document
* matches it is passed into the callback, along with its representation as Properties.
* Depending on the {@link #setResolutionMethod(ResolutionMethod)} not all the
* Depending on the {@link #setResolutionMethod(ResolutionMethod)} not all of the
* documents will be parsed.
* @param callback a callback to delegate to once matching documents are found
* @see #createYaml()
@@ -124,7 +124,7 @@ public class BeanComponentDefinition extends BeanDefinitionHolder implements Com
}
/**
* This implementation expects the other object to be of type BeanComponentDefinition
* This implementations expects the other object to be of type BeanComponentDefinition
* as well, in addition to the superclass's equality requirements.
*/
@Override
@@ -50,13 +50,13 @@ import org.springframework.beans.factory.config.BeanReference;
* {@link #getBeanReferences}, tools may wish to inspect all {@link BeanDefinition BeanDefinitions} to gather
* the full set of {@link BeanReference BeanReferences}. Implementations are required to provide
* all {@link BeanReference BeanReferences} that are required to validate the configuration of the
* overall logical entity as well as those required to provide full user visualization of the configuration.
* overall logical entity as well as those required to provide full user visualisation of the configuration.
* It is expected that certain {@link BeanReference BeanReferences} will not be important to
* validation or to the user view of the configuration and as such these may be omitted. A tool may wish to
* display any additional {@link BeanReference BeanReferences} sourced through the supplied
* {@link BeanDefinition BeanDefinitions} but this is not considered to be a typical case.
*
* <p>Tools can determine the importance of contained {@link BeanDefinition BeanDefinitions} by checking the
* <p>Tools can determine the important of contained {@link BeanDefinition BeanDefinitions} by checking the
* {@link BeanDefinition#getRole role identifier}. The role is essentially a hint to the tool as to how
* important the configuration provider believes a {@link BeanDefinition} is to the end user. It is expected
* that tools will <strong>not</strong> display all {@link BeanDefinition BeanDefinitions} for a given
@@ -1,5 +1,5 @@
/**
* Support package for the Java {@link java.util.ServiceLoader} facility.
* Support package for the Java 6 ServiceLoader facility.
*/
@NonNullApi
@NonNullFields
@@ -1510,7 +1510,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
try {
PropertyDescriptor pd = bw.getPropertyDescriptor(propertyName);
// Don't try autowiring by type for type Object: never makes sense,
// even if it technically is an unsatisfied, non-simple property.
// even if it technically is a unsatisfied, non-simple property.
if (Object.class != pd.getPropertyType()) {
MethodParameter methodParam = BeanUtils.getWriteMethodParameter(pd);
// Do not allow eager init for type matching in case of a prioritized post-processor.
@@ -945,7 +945,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
}
/**
* Specify whether the configured initializer method is the default.
* Specify whether or not the configured initializer method is the default.
* <p>The default value is {@code true} for a locally specified init method
* but switched to {@code false} for a shared setting in a defaults section
* (e.g. {@code bean init-method} versus {@code beans default-init-method}
@@ -984,7 +984,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
}
/**
* Specify whether the configured destroy method is the default.
* Specify whether or not the configured destroy method is the default.
* <p>The default value is {@code true} for a locally specified destroy method
* but switched to {@code false} for a shared setting in a defaults section
* (e.g. {@code bean destroy-method} versus {@code beans default-destroy-method}
@@ -593,7 +593,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
RootBeanDefinition mbd = getMergedLocalBeanDefinition(beanName);
BeanDefinitionHolder dbd = mbd.getDecoratedDefinition();
// Set up the types that we want to match against
// Setup the types that we want to match against
Class<?> classToMatch = typeToMatch.resolve();
if (classToMatch == null) {
classToMatch = FactoryBean.class;
@@ -293,7 +293,7 @@ public final class BeanDefinitionBuilder {
}
/**
* Set whether this definition is abstract.
* Set whether or not this definition is abstract.
*/
public BeanDefinitionBuilder setAbstract(boolean flag) {
this.beanDefinition.setAbstract(flag);
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* 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.
@@ -985,7 +985,7 @@ class ConstructorResolver {
/**
* Delegate for checking Java's {@link ConstructorProperties} annotation.
* Delegate for checking Java 6's {@link ConstructorProperties} annotation.
*/
private static class ConstructorPropertiesChecker {
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* 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.
@@ -280,7 +280,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
}
/**
* Return the dependency comparator for this BeanFactory (may be {@code null}).
* Return the dependency comparator for this BeanFactory (may be {@code null}.
* @since 4.0
*/
@Nullable
@@ -585,9 +585,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
if (!matchFound) {
// In case of FactoryBean, try to match FactoryBean instance itself next.
beanName = FACTORY_BEAN_PREFIX + beanName;
if (includeNonSingletons || isSingleton(beanName, mbd, dbd)) {
matchFound = isTypeMatch(beanName, type, allowFactoryBeanInit);
}
matchFound = isTypeMatch(beanName, type, allowFactoryBeanInit);
}
}
if (matchFound) {
@@ -33,7 +33,7 @@ import org.springframework.util.ClassUtils;
/**
* Basic {@link AutowireCandidateResolver} that performs a full generic type
* match with the candidate's type if the dependency is declared as a generic type
* (e.g. {@code Repository<Customer>}).
* (e.g. Repository&lt;Customer&gt;).
*
* <p>This is the base class for
* {@link org.springframework.beans.factory.annotation.QualifierAnnotationAutowireCandidateResolver},
@@ -17,7 +17,7 @@
package org.springframework.beans.factory.support;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Arrays;
import java.util.List;
import org.springframework.beans.BeanMetadataElement;
@@ -31,8 +31,6 @@ import org.springframework.lang.Nullable;
* @author Rod Johnson
* @author Rob Harrop
* @author Juergen Hoeller
* @author Stephane Nicoll
* @author Sam Brannen
* @since 27.05.2003
* @param <E> the element type
*/
@@ -57,16 +55,16 @@ public class ManagedList<E> extends ArrayList<E> implements Mergeable, BeanMetad
/**
* Create a new instance containing an arbitrary number of elements.
* Return a new instance containing an arbitrary number of elements.
* @param elements the elements to be contained in the list
* @param <E> the {@code List}'s element type
* @return a {@code ManagedList} containing the specified elements
* @return a {@code List} containing the specified elements
* @since 5.3.16
*/
@SafeVarargs
@SuppressWarnings("unchecked")
public static <E> ManagedList<E> of(E... elements) {
ManagedList<E> list = new ManagedList<>();
Collections.addAll(list, elements);
list.addAll(Arrays.asList(elements));
return list;
}
@@ -16,7 +16,7 @@
package org.springframework.beans.factory.support;
import java.util.Collections;
import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.Set;
@@ -30,8 +30,6 @@ import org.springframework.lang.Nullable;
*
* @author Juergen Hoeller
* @author Rob Harrop
* @author Stephane Nicoll
* @author Sam Brannen
* @since 21.01.2004
* @param <E> the element type
*/
@@ -56,16 +54,16 @@ public class ManagedSet<E> extends LinkedHashSet<E> implements Mergeable, BeanMe
/**
* Create a new instance containing an arbitrary number of elements.
* Return a new instance containing an arbitrary number of elements.
* @param elements the elements to be contained in the set
* @param <E> the {@code Set}'s element type
* @return a {@code ManagedSet} containing the specified elements
* @return a {@code Set} containing the specified elements
* @since 5.3.16
*/
@SafeVarargs
@SuppressWarnings("unchecked")
public static <E> ManagedSet<E> of(E... elements) {
ManagedSet<E> set = new ManagedSet<>();
Collections.addAll(set, elements);
set.addAll(Arrays.asList(elements));
return set;
}
@@ -124,7 +124,7 @@ public abstract class AbstractBeanDefinitionParser implements BeanDefinitionPars
/**
* Register the supplied {@link BeanDefinitionHolder bean} with the supplied
* {@link BeanDefinitionRegistry registry}.
* <p>Subclasses can override this method to control whether the supplied
* <p>Subclasses can override this method to control whether or not the supplied
* {@link BeanDefinitionHolder bean} is actually even registered, or to
* register even more beans.
* <p>The default implementation registers the supplied {@link BeanDefinitionHolder bean}
@@ -1362,7 +1362,7 @@ public class BeanDefinitionParserDelegate {
}
/**
* Parse a custom element (outside the default namespace).
* Parse a custom element (outside of the default namespace).
* @param ele the element to parse
* @return the resulting bean definition
*/
@@ -1372,7 +1372,7 @@ public class BeanDefinitionParserDelegate {
}
/**
* Parse a custom element (outside the default namespace).
* Parse a custom element (outside of the default namespace).
* @param ele the element to parse
* @param containingBd the containing bean definition (if any)
* @return the resulting bean definition
@@ -96,7 +96,7 @@ public class DefaultNamespaceHandlerResolver implements NamespaceHandlerResolver
* Create a new {@code DefaultNamespaceHandlerResolver} using the
* supplied mapping file location.
* @param classLoader the {@link ClassLoader} instance used to load mapping resources
* may be {@code null}, in which case the thread context ClassLoader will be used
* may be {@code null}, in which case the thread context ClassLoader will be used)
* @param handlerMappingsLocation the mapping file location
*/
public DefaultNamespaceHandlerResolver(@Nullable ClassLoader classLoader, String handlerMappingsLocation) {
@@ -56,7 +56,7 @@ public class DelegatingEntityResolver implements EntityResolver {
* <p>Configures the {@link PluggableSchemaResolver} with the supplied
* {@link ClassLoader}.
* @param classLoader the ClassLoader to use for loading
* (can be {@code null} to use the default ClassLoader)
* (can be {@code null}) to use the default ClassLoader)
*/
public DelegatingEntityResolver(@Nullable ClassLoader classLoader) {
this.dtdResolver = new BeansDtdResolver();
@@ -80,7 +80,7 @@ public class PluggableSchemaResolver implements EntityResolver {
* Loads the schema URL &rarr; schema file location mappings using the default
* mapping file pattern "META-INF/spring.schemas".
* @param classLoader the ClassLoader to use for loading
* (can be {@code null} to use the default ClassLoader)
* (can be {@code null}) to use the default ClassLoader)
* @see PropertiesLoaderUtils#loadAllProperties(String, ClassLoader)
*/
public PluggableSchemaResolver(@Nullable ClassLoader classLoader) {
@@ -92,7 +92,7 @@ public class PluggableSchemaResolver implements EntityResolver {
* Loads the schema URL &rarr; schema file location mappings using the given
* mapping file pattern.
* @param classLoader the ClassLoader to use for loading
* (can be {@code null} to use the default ClassLoader)
* (can be {@code null}) to use the default ClassLoader)
* @param schemaMappingsLocation the location of the file that defines schema mappings
* (must not be empty)
* @see PropertiesLoaderUtils#loadAllProperties(String, ClassLoader)
@@ -50,7 +50,7 @@ import org.springframework.util.StringUtils;
* the bean that will be considered as a parameter.
*
* <b>Note</b>: This implementation supports only named parameters - there is no
* support for indexes or types. Furthermore, the names are used as hints by
* support for indexes or types. Further more, the names are used as hints by
* the container which, by default, does type introspection.
*
* @author Costin Leau
@@ -184,7 +184,7 @@ public class XmlBeanDefinitionReader extends AbstractBeanDefinitionReader {
}
/**
* Set whether the XML parser should be XML namespace aware.
* Set whether or not the XML parser should be XML namespace aware.
* Default is "false".
* <p>This is typically not needed when schema validation is active.
* However, without validation, this has to be switched to "true"
@@ -195,7 +195,7 @@ public class XmlBeanDefinitionReader extends AbstractBeanDefinitionReader {
}
/**
* Return whether the XML parser should be XML namespace aware.
* Return whether or not the XML parser should be XML namespace aware.
*/
public boolean isNamespaceAware() {
return this.namespaceAware;
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,7 +29,6 @@ import org.springframework.util.StringUtils;
* e.g. {@code UTF-8}, {@code ISO-8859-16}, etc.
*
* @author Arjen Poutsma
* @author Sam Brannen
* @since 2.5.4
* @see Charset
*/
@@ -38,7 +37,7 @@ public class CharsetEditor extends PropertyEditorSupport {
@Override
public void setAsText(String text) throws IllegalArgumentException {
if (StringUtils.hasText(text)) {
setValue(Charset.forName(text.trim()));
setValue(Charset.forName(text));
}
else {
setValue(null);
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,14 +19,11 @@ package org.springframework.beans.propertyeditors;
import java.beans.PropertyEditorSupport;
import java.util.Currency;
import org.springframework.util.StringUtils;
/**
* Editor for {@code java.util.Currency}, translating currency codes into Currency
* objects. Exposes the currency code as text representation of a Currency object.
*
* @author Juergen Hoeller
* @author Sam Brannen
* @since 3.0
* @see java.util.Currency
*/
@@ -34,9 +31,6 @@ public class CurrencyEditor extends PropertyEditorSupport {
@Override
public void setAsText(String text) throws IllegalArgumentException {
if (StringUtils.hasText(text)) {
text = text.trim();
}
setValue(Currency.getInstance(text));
}
@@ -26,7 +26,7 @@ import org.springframework.util.StringUtils;
* Custom {@link java.beans.PropertyEditor} for String arrays.
*
* <p>Strings must be in CSV format, with a customizable separator.
* By default, values in the result are trimmed of whitespace.
* By default values in the result are trimmed of whitespace.
*
* @author Rod Johnson
* @author Juergen Hoeller
@@ -86,7 +86,7 @@ public class StringArrayPropertyEditor extends PropertyEditorSupport {
* @param emptyArrayAsNull {@code true} if an empty String array
* is to be transformed into {@code null}
* @param trimValues {@code true} if the values in the parsed arrays
* are to be trimmed of whitespace (default is {@code true})
* are to be trimmed of whitespace (default is true)
*/
public StringArrayPropertyEditor(String separator, boolean emptyArrayAsNull, boolean trimValues) {
this(separator, null, emptyArrayAsNull, trimValues);
@@ -114,7 +114,7 @@ public class StringArrayPropertyEditor extends PropertyEditorSupport {
* @param emptyArrayAsNull {@code true} if an empty String array
* is to be transformed into {@code null}
* @param trimValues {@code true} if the values in the parsed arrays
* are to be trimmed of whitespace (default is {@code true})
* are to be trimmed of whitespace (default is true)
*/
public StringArrayPropertyEditor(
String separator, @Nullable String charsToDelete, boolean emptyArrayAsNull, boolean trimValues) {
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2013 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;
*
* @author Juergen Hoeller
* @author Nicholas Williams
* @author Sam Brannen
* @since 3.0
* @see java.util.TimeZone
* @see ZoneIdEditor
@@ -37,9 +36,6 @@ public class TimeZoneEditor extends PropertyEditorSupport {
@Override
public void setAsText(String text) throws IllegalArgumentException {
if (StringUtils.hasText(text)) {
text = text.trim();
}
setValue(StringUtils.parseTimeZoneString(text));
}
@@ -130,7 +130,7 @@ public class URIEditor extends PropertyEditorSupport {
/**
* Create a URI instance for the given user-specified String value.
* <p>The default implementation encodes the value into an RFC-2396 compliant URI.
* <p>The default implementation encodes the value into a RFC-2396 compliant URI.
* @param value the value to convert into a URI instance
* @return the URI instance
* @throws java.net.URISyntaxException if URI conversion failed
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2016 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,14 +19,11 @@ package org.springframework.beans.propertyeditors;
import java.beans.PropertyEditorSupport;
import java.time.ZoneId;
import org.springframework.util.StringUtils;
/**
* Editor for {@code java.time.ZoneId}, translating zone ID Strings into {@code ZoneId}
* objects. Exposes the {@code TimeZone} ID as a text representation.
*
* @author Nicholas Williams
* @author Sam Brannen
* @since 4.0
* @see java.time.ZoneId
* @see TimeZoneEditor
@@ -35,9 +32,6 @@ public class ZoneIdEditor extends PropertyEditorSupport {
@Override
public void setAsText(String text) throws IllegalArgumentException {
if (StringUtils.hasText(text)) {
text = text.trim();
}
setValue(ZoneId.of(text));
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2016 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.
@@ -43,7 +43,6 @@ import org.springframework.core.io.ContextResource;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceEditor;
import org.springframework.core.io.ResourceLoader;
import org.springframework.core.io.WritableResource;
import org.springframework.core.io.support.ResourceArrayPropertyEditor;
import org.springframework.core.io.support.ResourcePatternResolver;
@@ -103,7 +102,6 @@ public class ResourceEditorRegistrar implements PropertyEditorRegistrar {
ResourceEditor baseEditor = new ResourceEditor(this.resourceLoader, this.propertyResolver);
doRegisterEditor(registry, Resource.class, baseEditor);
doRegisterEditor(registry, ContextResource.class, baseEditor);
doRegisterEditor(registry, WritableResource.class, baseEditor);
doRegisterEditor(registry, InputStream.class, new InputStreamEditor(baseEditor));
doRegisterEditor(registry, InputSource.class, new InputSourceEditor(baseEditor));
doRegisterEditor(registry, File.class, new FileEditor(baseEditor));
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 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.
@@ -39,7 +39,7 @@ inline fun <reified T : Any> ListableBeanFactory.getBeansOfType(includeNonSingle
/**
* Extension for [ListableBeanFactory.getBeanNamesForAnnotation] providing a
* `getBeanNamesForAnnotation<Foo>()` variant.
* `getBeansOfType<Foo>()` variant.
*
* @author Sebastien Deleuze
* @since 5.0
@@ -280,7 +280,7 @@ class BeanUtilsTests {
* {@code Number} can NOT be copied to {@code Integer}.
*/
@Test
void copyPropertiesDoesNotCopyFromSuperTypeToSubType() {
void copyPropertiesDoesNotCopyeFromSuperTypeToSubType() {
NumberHolder numberHolder = new NumberHolder();
numberHolder.setNumber(Integer.valueOf(42));
IntegerHolder integerHolder = new IntegerHolder();
@@ -25,7 +25,6 @@ import org.junit.jupiter.api.Test;
import org.springframework.beans.testfixture.beans.TestBean;
import org.springframework.core.OverridingClassLoader;
import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.io.UrlResource;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
@@ -154,7 +153,7 @@ class BeanWrapperTests extends AbstractPropertyAccessorTests {
}
@Test
void propertyDescriptors() throws Exception {
void propertyDescriptors() {
TestBean target = new TestBean();
target.setSpouse(new TestBean());
BeanWrapper accessor = createAccessor(target);
@@ -183,29 +182,11 @@ class BeanWrapperTests extends AbstractPropertyAccessorTests {
assertThat(accessor.isReadableProperty("class.package")).isFalse();
assertThat(accessor.isReadableProperty("class.module")).isFalse();
assertThat(accessor.isReadableProperty("class.classLoader")).isFalse();
assertThat(accessor.isReadableProperty("class.name")).isTrue();
assertThat(accessor.isReadableProperty("class.simpleName")).isTrue();
assertThat(accessor.isReadableProperty("classLoader")).isTrue();
assertThat(accessor.isWritableProperty("classLoader")).isTrue();
OverridingClassLoader ocl = new OverridingClassLoader(getClass().getClassLoader());
accessor.setPropertyValue("classLoader", ocl);
assertThat(accessor.getPropertyValue("classLoader")).isSameAs(ocl);
accessor = createAccessor(new UrlResource("https://spring.io"));
assertThat(accessor.isReadableProperty("class.package")).isFalse();
assertThat(accessor.isReadableProperty("class.module")).isFalse();
assertThat(accessor.isReadableProperty("class.classLoader")).isFalse();
assertThat(accessor.isReadableProperty("class.name")).isTrue();
assertThat(accessor.isReadableProperty("class.simpleName")).isTrue();
assertThat(accessor.isReadableProperty("URL.protocol")).isTrue();
assertThat(accessor.isReadableProperty("URL.host")).isTrue();
assertThat(accessor.isReadableProperty("URL.port")).isTrue();
assertThat(accessor.isReadableProperty("URL.file")).isTrue();
assertThat(accessor.isReadableProperty("URL.content")).isFalse();
assertThat(accessor.isReadableProperty("inputStream")).isFalse();
assertThat(accessor.isReadableProperty("filename")).isTrue();
assertThat(accessor.isReadableProperty("description")).isTrue();
}
@Test
@@ -26,6 +26,7 @@ import java.security.Principal;
import java.security.PrivilegedAction;
import java.text.NumberFormat;
import java.text.ParseException;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
@@ -94,7 +95,6 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
import static org.assertj.core.api.Assertions.assertThatNoException;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.isNull;
@@ -178,8 +178,10 @@ class DefaultListableBeanFactoryTests {
registerBeanDefinitions(p);
assertThat(!DummyFactory.wasPrototypeCreated()).as("prototype not instantiated").isTrue();
assertBeanNamesForType(TestBean.class, false, false);
assertThat(lbf.getBeanNamesForAnnotation(SuppressWarnings.class)).isEmpty();
String[] beanNames = lbf.getBeanNamesForType(TestBean.class, true, false);
assertThat(beanNames).hasSize(0);
beanNames = lbf.getBeanNamesForAnnotation(SuppressWarnings.class);
assertThat(beanNames).hasSize(0);
assertThat(lbf.containsSingleton("x1")).isFalse();
assertThat(lbf.containsBean("x1")).isTrue();
@@ -210,8 +212,10 @@ class DefaultListableBeanFactoryTests {
registerBeanDefinitions(p);
assertThat(!DummyFactory.wasPrototypeCreated()).as("prototype not instantiated").isTrue();
assertBeanNamesForType(TestBean.class, false, false);
assertThat(lbf.getBeanNamesForAnnotation(SuppressWarnings.class)).isEmpty();
String[] beanNames = lbf.getBeanNamesForType(TestBean.class, true, false);
assertThat(beanNames).hasSize(0);
beanNames = lbf.getBeanNamesForAnnotation(SuppressWarnings.class);
assertThat(beanNames).hasSize(0);
assertThat(lbf.containsSingleton("x1")).isFalse();
assertThat(lbf.containsBean("x1")).isTrue();
@@ -241,8 +245,10 @@ class DefaultListableBeanFactoryTests {
registerBeanDefinitions(p);
assertThat(!DummyFactory.wasPrototypeCreated()).as("prototype not instantiated").isTrue();
assertBeanNamesForType(TestBean.class, false, false);
assertThat(lbf.getBeanNamesForAnnotation(SuppressWarnings.class)).isEmpty();
String[] beanNames = lbf.getBeanNamesForType(TestBean.class, true, false);
assertThat(beanNames).hasSize(0);
beanNames = lbf.getBeanNamesForAnnotation(SuppressWarnings.class);
assertThat(beanNames).hasSize(0);
assertThat(lbf.containsSingleton("x1")).isFalse();
assertThat(lbf.containsBean("x1")).isTrue();
@@ -272,8 +278,10 @@ class DefaultListableBeanFactoryTests {
registerBeanDefinitions(p);
lbf.preInstantiateSingletons();
assertThat(DummyFactory.wasPrototypeCreated()).as("prototype not instantiated").isFalse();
assertBeanNamesForType(TestBean.class, true, false, "x1");
assertThat(!DummyFactory.wasPrototypeCreated()).as("prototype not instantiated").isTrue();
String[] beanNames = lbf.getBeanNamesForType(TestBean.class, true, false);
assertThat(beanNames).hasSize(1);
assertThat(beanNames[0]).isEqualTo("x1");
assertThat(lbf.containsSingleton("x1")).isTrue();
assertThat(lbf.containsBean("x1")).isTrue();
assertThat(lbf.containsBean("&x1")).isTrue();
@@ -308,10 +316,14 @@ class DefaultListableBeanFactoryTests {
assertThat(lbf.isTypeMatch("&x2", Object.class)).isTrue();
assertThat(lbf.getType("x2")).isEqualTo(TestBean.class);
assertThat(lbf.getType("&x2")).isEqualTo(DummyFactory.class);
assertThat(lbf.getAliases("x1")).containsExactly("x2");
assertThat(lbf.getAliases("&x1")).containsExactly("&x2");
assertThat(lbf.getAliases("x2")).containsExactly("x1");
assertThat(lbf.getAliases("&x2")).containsExactly("&x1");
assertThat(lbf.getAliases("x1").length).isEqualTo(1);
assertThat(lbf.getAliases("x1")[0]).isEqualTo("x2");
assertThat(lbf.getAliases("&x1").length).isEqualTo(1);
assertThat(lbf.getAliases("&x1")[0]).isEqualTo("&x2");
assertThat(lbf.getAliases("x2").length).isEqualTo(1);
assertThat(lbf.getAliases("x2")[0]).isEqualTo("x1");
assertThat(lbf.getAliases("&x2").length).isEqualTo(1);
assertThat(lbf.getAliases("&x2")[0]).isEqualTo("&x1");
}
@Test
@@ -321,7 +333,9 @@ class DefaultListableBeanFactoryTests {
lbf.registerBeanDefinition("x1", rbd);
TestBeanFactory.initialized = false;
assertBeanNamesForType(TestBean.class, true, false, "x1");
String[] beanNames = lbf.getBeanNamesForType(TestBean.class, true, false);
assertThat(beanNames).hasSize(1);
assertThat(beanNames[0]).isEqualTo("x1");
assertThat(lbf.containsSingleton("x1")).isFalse();
assertThat(lbf.containsBean("x1")).isTrue();
assertThat(lbf.containsBean("&x1")).isFalse();
@@ -344,7 +358,9 @@ class DefaultListableBeanFactoryTests {
lbf.registerBeanDefinition("x1", rbd);
TestBeanFactory.initialized = false;
assertBeanNamesForType(TestBean.class, true, false, "x1");
String[] beanNames = lbf.getBeanNamesForType(TestBean.class, true, false);
assertThat(beanNames).hasSize(1);
assertThat(beanNames[0]).isEqualTo("x1");
assertThat(lbf.containsSingleton("x1")).isFalse();
assertThat(lbf.containsBean("x1")).isTrue();
assertThat(lbf.containsBean("&x1")).isFalse();
@@ -369,7 +385,9 @@ class DefaultListableBeanFactoryTests {
lbf.registerBeanDefinition("x1", rbd);
TestBeanFactory.initialized = false;
assertBeanNamesForType(TestBean.class, true, false, "x1");
String[] beanNames = lbf.getBeanNamesForType(TestBean.class, true, false);
assertThat(beanNames).hasSize(1);
assertThat(beanNames[0]).isEqualTo("x1");
assertThat(lbf.containsSingleton("x1")).isFalse();
assertThat(lbf.containsBean("x1")).isTrue();
assertThat(lbf.containsBean("&x1")).isFalse();
@@ -395,7 +413,9 @@ class DefaultListableBeanFactoryTests {
lbf.registerBeanDefinition("x1", rbd);
TestBeanFactory.initialized = false;
assertBeanNamesForType(TestBean.class, true, false, "x1");
String[] beanNames = lbf.getBeanNamesForType(TestBean.class, true, false);
assertThat(beanNames).hasSize(1);
assertThat(beanNames[0]).isEqualTo("x1");
assertThat(lbf.containsSingleton("x1")).isFalse();
assertThat(lbf.containsBean("x1")).isTrue();
assertThat(lbf.containsBean("&x1")).isFalse();
@@ -428,10 +448,14 @@ class DefaultListableBeanFactoryTests {
assertThat(lbf.isTypeMatch("&x2", Object.class)).isFalse();
assertThat(lbf.getType("x2")).isEqualTo(TestBean.class);
assertThat(lbf.getType("&x2")).isNull();
assertThat(lbf.getAliases("x1")).containsExactly("x2");
assertThat(lbf.getAliases("&x1")).containsExactly("&x2");
assertThat(lbf.getAliases("x2")).containsExactly("x1");
assertThat(lbf.getAliases("&x2")).containsExactly("&x1");
assertThat(lbf.getAliases("x1").length).isEqualTo(1);
assertThat(lbf.getAliases("x1")[0]).isEqualTo("x2");
assertThat(lbf.getAliases("&x1").length).isEqualTo(1);
assertThat(lbf.getAliases("&x1")[0]).isEqualTo("&x2");
assertThat(lbf.getAliases("x2").length).isEqualTo(1);
assertThat(lbf.getAliases("x2")[0]).isEqualTo("x1");
assertThat(lbf.getAliases("&x2").length).isEqualTo(1);
assertThat(lbf.getAliases("&x2")[0]).isEqualTo("&x1");
}
@Test
@@ -595,7 +619,8 @@ class DefaultListableBeanFactoryTests {
lbf.registerSingleton("string", "A");
TestBean self = (TestBean) lbf.getBean("self");
assertThat(self.getStringArray()).containsExactly("A");
assertThat(self.getStringArray()).hasSize(1);
assertThat(self.getStringArray()).contains("A");
}
@Test
@@ -608,7 +633,8 @@ class DefaultListableBeanFactoryTests {
lbf.registerSingleton("string", "A");
TestBean self = (TestBean) lbf.getBean("self");
assertThat(self.getStringArray()).containsExactly("A");
assertThat(self.getStringArray()).hasSize(1);
assertThat(self.getStringArray()).contains("A");
}
@Test
@@ -640,7 +666,8 @@ class DefaultListableBeanFactoryTests {
.withCauseInstanceOf(NotWritablePropertyException.class)
.satisfies(ex -> {
NotWritablePropertyException cause = (NotWritablePropertyException) ex.getCause();
assertThat(cause.getPossibleMatches()).containsExactly("age");
assertThat(cause.getPossibleMatches()).hasSize(1);
assertThat(cause.getPossibleMatches()[0]).isEqualTo("age");
});
}
@@ -658,7 +685,7 @@ class DefaultListableBeanFactoryTests {
lbf = new DefaultListableBeanFactory();
p = new Properties();
p.setProperty("kerry.(class)", TestBean.class.getName());
p.setProperty("kerry.(scope)", BeanDefinition.SCOPE_PROTOTYPE);
p.setProperty("kerry.(scope)", "prototype");
p.setProperty("kerry.age", "35");
registerBeanDefinitions(p);
kerry1 = (TestBean) lbf.getBean("kerry");
@@ -1118,7 +1145,7 @@ class DefaultListableBeanFactoryTests {
assertThat(lbf.containsBean("singletonObject")).isTrue();
assertThat(lbf.isSingleton("singletonObject")).isTrue();
assertThat(lbf.getType("singletonObject")).isEqualTo(TestBean.class);
assertThat(lbf.getAliases("singletonObject")).isEmpty();
assertThat(lbf.getAliases("singletonObject").length).isEqualTo(0);
DependenciesBean test = (DependenciesBean) lbf.getBean("test");
assertThat(lbf.getBean("singletonObject")).isEqualTo(singletonObject);
assertThat(test.getSpouse()).isEqualTo(singletonObject);
@@ -1764,12 +1791,12 @@ class DefaultListableBeanFactoryTests {
assertThat(bean.beanName).isEqualTo("bd1");
assertThat(bean.spouseAge).isEqualTo(42);
assertThat(lbf.getBeanNamesForType(ConstructorDependency.class)).hasSize(1);
assertThat(lbf.getBeanNamesForType(ConstructorDependencyFactoryBean.class)).hasSize(1);
assertThat(lbf.getBeanNamesForType(ResolvableType.forClassWithGenerics(FactoryBean.class, Object.class))).hasSize(1);
assertThat(lbf.getBeanNamesForType(ResolvableType.forClassWithGenerics(FactoryBean.class, String.class))).isEmpty();
assertThat(lbf.getBeanNamesForType(ResolvableType.forClassWithGenerics(FactoryBean.class, Object.class), true, true)).hasSize(1);
assertThat(lbf.getBeanNamesForType(ResolvableType.forClassWithGenerics(FactoryBean.class, String.class), true, true)).isEmpty();
assertThat(lbf.getBeanNamesForType(ConstructorDependency.class).length).isEqualTo(1);
assertThat(lbf.getBeanNamesForType(ConstructorDependencyFactoryBean.class).length).isEqualTo(1);
assertThat(lbf.getBeanNamesForType(ResolvableType.forClassWithGenerics(FactoryBean.class, Object.class)).length).isEqualTo(1);
assertThat(lbf.getBeanNamesForType(ResolvableType.forClassWithGenerics(FactoryBean.class, String.class)).length).isEqualTo(0);
assertThat(lbf.getBeanNamesForType(ResolvableType.forClassWithGenerics(FactoryBean.class, Object.class), true, true).length).isEqualTo(1);
assertThat(lbf.getBeanNamesForType(ResolvableType.forClassWithGenerics(FactoryBean.class, String.class), true, true).length).isEqualTo(0);
}
private RootBeanDefinition createConstructorDependencyBeanDefinition(int age) {
@@ -1834,45 +1861,46 @@ class DefaultListableBeanFactoryTests {
@Test
void getBeanNamesForTypeBeforeFactoryBeanCreation() {
FactoryBeanThatShouldntBeCalled.instantiated = false;
lbf.registerBeanDefinition("factoryBean", new RootBeanDefinition(FactoryBeanThatShouldntBeCalled.class));
assertThat(lbf.containsSingleton("factoryBean")).isFalse();
assertThat(FactoryBeanThatShouldntBeCalled.instantiated).isFalse();
assertBeanNamesForType(Runnable.class, false, false, "&factoryBean");
assertBeanNamesForType(Callable.class, false, false, "&factoryBean");
assertBeanNamesForType(RepositoryFactoryInformation.class, false, false, "&factoryBean");
assertBeanNamesForType(FactoryBean.class, false, false, "&factoryBean");
String[] beanNames = lbf.getBeanNamesForType(Runnable.class, false, false);
assertThat(beanNames.length).isEqualTo(1);
assertThat(beanNames[0]).isEqualTo("&factoryBean");
beanNames = lbf.getBeanNamesForType(Callable.class, false, false);
assertThat(beanNames.length).isEqualTo(1);
assertThat(beanNames[0]).isEqualTo("&factoryBean");
beanNames = lbf.getBeanNamesForType(RepositoryFactoryInformation.class, false, false);
assertThat(beanNames.length).isEqualTo(1);
assertThat(beanNames[0]).isEqualTo("&factoryBean");
beanNames = lbf.getBeanNamesForType(FactoryBean.class, false, false);
assertThat(beanNames.length).isEqualTo(1);
assertThat(beanNames[0]).isEqualTo("&factoryBean");
}
@Test
void getBeanNamesForTypeAfterFactoryBeanCreation() {
FactoryBeanThatShouldntBeCalled.instantiated = false;
lbf.registerBeanDefinition("factoryBean", new RootBeanDefinition(FactoryBeanThatShouldntBeCalled.class));
lbf.getBean("&factoryBean");
assertThat(FactoryBeanThatShouldntBeCalled.instantiated).isTrue();
assertThat(lbf.containsSingleton("factoryBean")).isTrue();
assertBeanNamesForType(Runnable.class, false, false, "&factoryBean");
assertBeanNamesForType(Callable.class, false, false, "&factoryBean");
assertBeanNamesForType(RepositoryFactoryInformation.class, false, false, "&factoryBean");
assertBeanNamesForType(FactoryBean.class, false, false, "&factoryBean");
}
String[] beanNames = lbf.getBeanNamesForType(Runnable.class, false, false);
assertThat(beanNames.length).isEqualTo(1);
assertThat(beanNames[0]).isEqualTo("&factoryBean");
@Test // gh-28616
void getBeanNamesForTypeWithPrototypeScopedFactoryBean() {
FactoryBeanThatShouldntBeCalled.instantiated = false;
RootBeanDefinition beanDefinition = new RootBeanDefinition(FactoryBeanThatShouldntBeCalled.class);
beanDefinition.setScope(BeanDefinition.SCOPE_PROTOTYPE);
lbf.registerBeanDefinition("factoryBean", beanDefinition);
assertThat(FactoryBeanThatShouldntBeCalled.instantiated).isFalse();
assertThat(lbf.containsSingleton("factoryBean")).isFalse();
beanNames = lbf.getBeanNamesForType(Callable.class, false, false);
assertThat(beanNames.length).isEqualTo(1);
assertThat(beanNames[0]).isEqualTo("&factoryBean");
// We should not find any beans of the following types if the FactoryBean itself is prototype-scoped.
assertBeanNamesForType(Runnable.class, false, false);
assertBeanNamesForType(Callable.class, false, false);
assertBeanNamesForType(RepositoryFactoryInformation.class, false, false);
assertBeanNamesForType(FactoryBean.class, false, false);
beanNames = lbf.getBeanNamesForType(RepositoryFactoryInformation.class, false, false);
assertThat(beanNames.length).isEqualTo(1);
assertThat(beanNames[0]).isEqualTo("&factoryBean");
beanNames = lbf.getBeanNamesForType(FactoryBean.class, false, false);
assertThat(beanNames.length).isEqualTo(1);
assertThat(beanNames[0]).isEqualTo("&factoryBean");
}
/**
@@ -2137,7 +2165,8 @@ class DefaultListableBeanFactoryTests {
RootBeanDefinition bd = new RootBeanDefinition(ConstructorDependencyBean.class);
bd.setAutowireMode(RootBeanDefinition.AUTOWIRE_CONSTRUCTOR);
lbf.registerBeanDefinition("test", bd);
assertThatExceptionOfType(UnsatisfiedDependencyException.class).isThrownBy(lbf::preInstantiateSingletons);
assertThatExceptionOfType(UnsatisfiedDependencyException.class).isThrownBy(
lbf::preInstantiateSingletons);
}
@Test
@@ -2145,7 +2174,8 @@ class DefaultListableBeanFactoryTests {
RootBeanDefinition bd = new RootBeanDefinition(ConstructorDependencyFactoryBean.class);
bd.setAutowireMode(RootBeanDefinition.AUTOWIRE_CONSTRUCTOR);
lbf.registerBeanDefinition("test", bd);
assertThatExceptionOfType(UnsatisfiedDependencyException.class).isThrownBy(lbf::preInstantiateSingletons);
assertThatExceptionOfType(UnsatisfiedDependencyException.class).isThrownBy(
lbf::preInstantiateSingletons);
}
@Test
@@ -2153,7 +2183,8 @@ class DefaultListableBeanFactoryTests {
RootBeanDefinition bd = new RootBeanDefinition(ConstructorDependencyFactoryBean.class);
bd.setAutowireMode(RootBeanDefinition.AUTOWIRE_CONSTRUCTOR);
lbf.registerBeanDefinition("test", bd);
assertThatExceptionOfType(UnsatisfiedDependencyException.class).isThrownBy(() -> lbf.getBeansOfType(String.class));
assertThatExceptionOfType(UnsatisfiedDependencyException.class).isThrownBy(() ->
lbf.getBeansOfType(String.class));
}
@Test
@@ -2180,7 +2211,8 @@ class DefaultListableBeanFactoryTests {
RootBeanDefinition bd = new RootBeanDefinition(ConstructorDependencyWithClassResolution.class);
bd.getConstructorArgumentValues().addGenericArgumentValue("java.lang.Strin");
lbf.registerBeanDefinition("test", bd);
assertThatExceptionOfType(UnsatisfiedDependencyException.class).isThrownBy(lbf::preInstantiateSingletons);
assertThatExceptionOfType(UnsatisfiedDependencyException.class).isThrownBy(
lbf::preInstantiateSingletons);
}
@Test
@@ -2204,13 +2236,7 @@ class DefaultListableBeanFactoryTests {
@Test
void prototypeFactoryBeanNotEagerlyCalled() {
lbf.registerBeanDefinition("test", new RootBeanDefinition(FactoryBeanThatShouldntBeCalled.class));
assertThatNoException().isThrownBy(lbf::preInstantiateSingletons);
}
@Test
void prototypeFactoryBeanNotEagerlyCalledInCaseOfBeanClassName() {
lbf.registerBeanDefinition("test", new RootBeanDefinition(FactoryBeanThatShouldntBeCalled.class.getName(), null, null));
assertThatNoException().isThrownBy(lbf::preInstantiateSingletons);
lbf.preInstantiateSingletons();
}
@Test
@@ -2250,6 +2276,13 @@ class DefaultListableBeanFactoryTests {
assertThat(factory.initialized).isTrue();
}
@Test
void prototypeFactoryBeanNotEagerlyCalledInCaseOfBeanClassName() {
lbf.registerBeanDefinition("test",
new RootBeanDefinition(FactoryBeanThatShouldntBeCalled.class.getName(), null, null));
lbf.preInstantiateSingletons();
}
@Test
void prototypeStringCreatedRepeatedly() {
RootBeanDefinition stringDef = new RootBeanDefinition(String.class);
@@ -2429,7 +2462,10 @@ class DefaultListableBeanFactoryTests {
lbf.registerBeanDefinition("fmWithArgs", factoryMethodDefinitionWithArgs);
assertThat(lbf.getBeanDefinitionCount()).isEqualTo(4);
assertBeanNamesForType(TestBean.class, true, true, "fmWithProperties", "fmWithArgs");
List<String> tbNames = Arrays.asList(lbf.getBeanNamesForType(TestBean.class));
assertThat(tbNames.contains("fmWithProperties")).isTrue();
assertThat(tbNames.contains("fmWithArgs")).isTrue();
assertThat(tbNames.size()).isEqualTo(2);
TestBean tb = (TestBean) lbf.getBean("fmWithProperties");
TestBean second = (TestBean) lbf.getBean("fmWithProperties");
@@ -2633,19 +2669,6 @@ class DefaultListableBeanFactoryTests {
return (new org.springframework.beans.factory.support.PropertiesBeanDefinitionReader(lbf)).registerBeanDefinitions(p, prefix);
}
private void assertBeanNamesForType(Class<?> type, boolean includeNonSingletons, boolean allowEagerInit, String... names) {
if (names.length == 0) {
assertThat(lbf.getBeanNamesForType(type, includeNonSingletons, allowEagerInit))
.as("bean names for type " + type.getName())
.isEmpty();
}
else {
assertThat(lbf.getBeanNamesForType(type, includeNonSingletons, allowEagerInit))
.as("bean names for type " + type.getName())
.containsExactly(names);
}
}
public static class NoDependencies {
@@ -2836,12 +2859,6 @@ class DefaultListableBeanFactoryTests {
public static class FactoryBeanThatShouldntBeCalled<T extends Repository<S, ID>, S, ID extends Serializable>
extends RepositoryFactoryBeanSupport<T, S, ID> implements Runnable, Callable<T> {
static boolean instantiated = false;
{
instantiated = true;
}
@Override
public T getObject() {
throw new IllegalStateException();
@@ -43,7 +43,7 @@ public class MethodInvokingFactoryBeanTests {
@Test
public void testParameterValidation() throws Exception {
// assert that only static OR non-static are set, but not both or none
// assert that only static OR non static are set, but not both or none
MethodInvokingFactoryBean mcfb = new MethodInvokingFactoryBean();
assertThatIllegalArgumentException().isThrownBy(mcfb::afterPropertiesSet);
@@ -278,19 +278,19 @@ public class ServiceLocatorFactoryBeanTests {
}
public interface TestServiceLocator {
public static interface TestServiceLocator {
TestService getTestService();
}
public interface TestServiceLocator2 {
public static interface TestServiceLocator2 {
TestService getTestService(String id) throws CustomServiceLocatorException2;
}
public interface TestServiceLocator3 {
public static interface TestServiceLocator3 {
TestService getTestService();
@@ -302,13 +302,13 @@ public class ServiceLocatorFactoryBeanTests {
}
public interface TestService2Locator {
public static interface TestService2Locator {
TestService2 getTestService() throws CustomServiceLocatorException3;
}
public interface ServiceLocatorInterfaceWithExtraNonCompliantMethod {
public static interface ServiceLocatorInterfaceWithExtraNonCompliantMethod {
TestService2 getTestService();
@@ -25,61 +25,61 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
/**
* Unit tests for {@link ManagedList}.
*
* @author Rick Evans
* @author Juergen Hoeller
* @author Sam Brannen
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
class ManagedListTests {
public class ManagedListTests {
@Test
void mergeSunnyDay() {
public void mergeSunnyDay() {
ManagedList parent = ManagedList.of("one", "two");
ManagedList child = ManagedList.of("three");
child.setMergeEnabled(true);
List mergedList = child.merge(parent);
assertThat(mergedList).as("merge() obviously did not work.").containsExactly("one", "two", "three");
assertThat(mergedList.size()).as("merge() obviously did not work.").isEqualTo(3);
}
@Test
void mergeWithNullParent() {
public void mergeWithNullParent() {
ManagedList child = ManagedList.of("one");
child.setMergeEnabled(true);
assertThat(child.merge(null)).isSameAs(child);
}
@Test
void mergeNotAllowedWhenMergeNotEnabled() {
public void mergeNotAllowedWhenMergeNotEnabled() {
ManagedList child = new ManagedList();
assertThatIllegalStateException().isThrownBy(() -> child.merge(null));
assertThatIllegalStateException().isThrownBy(() ->
child.merge(null));
}
@Test
void mergeWithIncompatibleParentType() {
public void mergeWithNonCompatibleParentType() {
ManagedList child = ManagedList.of("one");
child.setMergeEnabled(true);
assertThatIllegalArgumentException().isThrownBy(() -> child.merge("hello"));
assertThatIllegalArgumentException().isThrownBy(() ->
child.merge("hello"));
}
@Test
void mergeEmptyChild() {
public void mergeEmptyChild() {
ManagedList parent = ManagedList.of("one", "two");
ManagedList child = new ManagedList();
child.setMergeEnabled(true);
List mergedList = child.merge(parent);
assertThat(mergedList).as("merge() obviously did not work.").containsExactly("one", "two");
assertThat(mergedList.size()).as("merge() obviously did not work.").isEqualTo(2);
}
@Test
void mergedChildValuesDoNotOverrideTheParents() {
public void mergeChildValuesOverrideTheParents() {
// doesn't make much sense in the context of a list...
ManagedList parent = ManagedList.of("one", "two");
ManagedList child = ManagedList.of("one");
child.setMergeEnabled(true);
List mergedList = child.merge(parent);
assertThat(mergedList).as("merge() obviously did not work.").containsExactly("one", "two", "one");
assertThat(mergedList.size()).as("merge() obviously did not work.").isEqualTo(3);
}
}
@@ -25,62 +25,61 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
/**
* Unit tests for {@link ManagedSet}.
*
* @author Rick Evans
* @author Juergen Hoeller
* @author Sam Brannen
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
class ManagedSetTests {
public class ManagedSetTests {
@Test
void mergeSunnyDay() {
public void mergeSunnyDay() {
ManagedSet parent = ManagedSet.of("one", "two");
ManagedSet child = ManagedSet.of("three");
child.add("three");
child.add("four");
child.setMergeEnabled(true);
Set mergedSet = child.merge(parent);
assertThat(mergedSet).as("merge() obviously did not work.").containsExactly("one", "two", "three", "four");
assertThat(mergedSet.size()).as("merge() obviously did not work.").isEqualTo(3);
}
@Test
void mergeWithNullParent() {
public void mergeWithNullParent() {
ManagedSet child = ManagedSet.of("one");
child.setMergeEnabled(true);
assertThat(child.merge(null)).isSameAs(child);
}
@Test
void mergeNotAllowedWhenMergeNotEnabled() {
assertThatIllegalStateException().isThrownBy(() -> new ManagedSet().merge(null));
public void mergeNotAllowedWhenMergeNotEnabled() {
assertThatIllegalStateException().isThrownBy(() ->
new ManagedSet().merge(null));
}
@Test
void mergeWithNonCompatibleParentType() {
public void mergeWithNonCompatibleParentType() {
ManagedSet child = ManagedSet.of("one");
child.setMergeEnabled(true);
assertThatIllegalArgumentException().isThrownBy(() -> child.merge("hello"));
assertThatIllegalArgumentException().isThrownBy(() ->
child.merge("hello"));
}
@Test
void mergeEmptyChild() {
public void mergeEmptyChild() {
ManagedSet parent = ManagedSet.of("one", "two");
ManagedSet child = new ManagedSet();
child.setMergeEnabled(true);
Set mergedSet = child.merge(parent);
assertThat(mergedSet).as("merge() obviously did not work.").containsExactly("one", "two");
assertThat(mergedSet.size()).as("merge() obviously did not work.").isEqualTo(2);
}
@Test
void mergeChildValuesOverrideTheParents() {
public void mergeChildValuesOverrideTheParents() {
// asserts that the set contract is not violated during a merge() operation...
ManagedSet parent = ManagedSet.of("one", "two");
ManagedSet child = ManagedSet.of("one");
child.setMergeEnabled(true);
Set mergedSet = child.merge(parent);
assertThat(mergedSet).as("merge() obviously did not work.").containsExactly("one", "two");
assertThat(mergedSet.size()).as("merge() obviously did not work.").isEqualTo(2);
}
}
@@ -58,7 +58,6 @@ import org.springframework.core.io.Resource;
import org.springframework.core.testfixture.security.TestPrincipal;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatException;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
/**
@@ -304,14 +303,14 @@ public class CallbacksSecurityTests {
Method method = bean.getClass().getMethod("destroy");
method.setAccessible(true);
assertThatException().isThrownBy(() ->
assertThatExceptionOfType(Exception.class).isThrownBy(() ->
AccessController.doPrivileged((PrivilegedExceptionAction<Object>) () -> {
method.invoke(bean);
return null;
}, acc));
Class<ConstructorBean> cl = ConstructorBean.class;
assertThatException().isThrownBy(() ->
assertThatExceptionOfType(Exception.class).isThrownBy(() ->
AccessController.doPrivileged((PrivilegedExceptionAction<Object>) () ->
cl.newInstance(), acc));
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 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,7 +23,8 @@ import org.springframework.beans.testfixture.beans.TestBean;
import org.springframework.core.io.ClassPathResource;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatException;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
/**
* With Spring 3.1, bean id attributes (and all other id attributes across the
@@ -39,23 +40,22 @@ import static org.assertj.core.api.Assertions.assertThatException;
* @see org.springframework.beans.factory.xml.XmlBeanFactoryTests#withDuplicateName
* @see org.springframework.beans.factory.xml.XmlBeanFactoryTests#withDuplicateNameInAlias
*/
class DuplicateBeanIdTests {
public class DuplicateBeanIdTests {
@Test
void duplicateBeanIdsWithinSameNestingLevelRaisesError() {
public void duplicateBeanIdsWithinSameNestingLevelRaisesError() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(bf);
assertThatException().as("duplicate ids in same nesting level").isThrownBy(() ->
assertThatExceptionOfType(Exception.class).as("duplicate ids in same nesting level").isThrownBy(() ->
reader.loadBeanDefinitions(new ClassPathResource("DuplicateBeanIdTests-sameLevel-context.xml", this.getClass())));
}
@Test
void duplicateBeanIdsAcrossNestingLevels() {
public void duplicateBeanIdsAcrossNestingLevels() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(bf);
reader.loadBeanDefinitions(new ClassPathResource("DuplicateBeanIdTests-multiLevel-context.xml", this.getClass()));
TestBean testBean = bf.getBean(TestBean.class); // there should be only one
assertThat(testBean.getName()).isEqualTo("nested");
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 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,26 +19,19 @@ package org.springframework.beans.propertyeditors;
import java.time.ZoneId;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import static org.assertj.core.api.Assertions.assertThat;
/**
* @author Nicholas Williams
* @author Sam Brannen
*/
class ZoneIdEditorTests {
public class ZoneIdEditorTests {
private final ZoneIdEditor editor = new ZoneIdEditor();
@ParameterizedTest(name = "[{index}] text = ''{0}''")
@ValueSource(strings = {
"America/Chicago",
" America/Chicago ",
})
void americaChicago(String text) {
editor.setAsText(text);
@Test
public void americaChicago() {
editor.setAsText("America/Chicago");
ZoneId zoneId = (ZoneId) editor.getValue();
assertThat(zoneId).as("The zone ID should not be null.").isNotNull();
@@ -48,7 +41,7 @@ class ZoneIdEditorTests {
}
@Test
void americaLosAngeles() {
public void americaLosAngeles() {
editor.setAsText("America/Los_Angeles");
ZoneId zoneId = (ZoneId) editor.getValue();
@@ -59,12 +52,12 @@ class ZoneIdEditorTests {
}
@Test
void getNullAsText() {
public void getNullAsText() {
assertThat(editor.getAsText()).as("The returned value is not correct.").isEqualTo("");
}
@Test
void getValueAsText() {
public void getValueAsText() {
editor.setValue(ZoneId.of("America/New_York"));
assertThat(editor.getAsText()).as("The text version is not correct.").isEqualTo("America/New_York");
}
@@ -22,7 +22,7 @@ import java.io.IOException;
* Interface used for {@link org.springframework.beans.testfixture.beans.TestBean}.
*
* <p>Two methods are the same as on Person, but if this
* extends person it breaks quite a few tests.
* extends person it breaks quite a few tests..
*
* @author Rod Johnson
* @author Juergen Hoeller
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* 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.
@@ -22,7 +22,6 @@ import javax.lang.model.element.Element;
/**
* Provide the list of stereotypes that match an {@link Element}.
*
* <p>If an element has one or more stereotypes, it is referenced in the index
* of candidate components and each stereotype can be queried individually.
*
@@ -19,7 +19,7 @@ package org.springframework.context.index.sample;
import org.springframework.stereotype.Component;
/**
* Candidate with an inner class that isn't static (and should therefore not be added).
* Candidate with a inner class that isn't static (and should therefore not be added).
*
* @author Stephane Nicoll
*/
@@ -235,7 +235,7 @@ public class DefaultJCacheOperationSource extends AnnotationJCacheOperationSourc
* {@code CacheResolver} from a custom {@code CacheResolver} implementation so we have to
* fall back on the {@code CacheManager}.
* <p>This gives this weird situation of a perfectly valid configuration that breaks all
* of a sudden because the JCache support is enabled. To avoid this we resolve the default
* the sudden because the JCache support is enabled. To avoid this we resolve the default
* exception {@code CacheResolver} as late as possible to avoid such hard requirement
* in other cases.
*/
@@ -27,7 +27,7 @@ import org.springframework.util.Assert;
/**
* Cache decorator which synchronizes its {@link #put}, {@link #evict} and
* {@link #clear} operations with Spring-managed transactions (through Spring's
* {@link TransactionSynchronizationManager}), performing the actual cache
* {@link TransactionSynchronizationManager}, performing the actual cache
* put/evict/clear operation only in the after-commit phase of a successful
* transaction. If no transaction is active, {@link #put}, {@link #evict} and
* {@link #clear} operations will be performed immediately, as usual.

Some files were not shown because too many files have changed in this diff Show More