Compare commits

..

92 Commits

Author SHA1 Message Date
Spring Builds ab5a6a5e48 Release v5.3.16 2022-02-17 07:33:24 +00:00
Juergen Hoeller f8a59c267f Polishing 2022-02-16 20:04:51 +01:00
Juergen Hoeller 1166577d2c Upgrade to Netty 4.1.74, Jetty 9.4.45, Undertow 2.2.16, Hibernate Validator 6.2.2, Apache Johnzon 1.2.16, EclipseLink 2.7.10 2022-02-16 20:04:27 +01:00
Phillip Webb 36dc4e4c5f Add mavenCentral() to pluginManagement repositories
Update the pluginManagement repositories used by Grade to include
`mavenCentral()` since `gradlePluginPortal()` has been suffering
from timeouts recently.
2022-02-16 14:35:50 +01:00
Sam Brannen 3ac60147f3 Improve documentation for uri(URI) method in WebTestClient
Prior to this commit, it was not clear that a configured base URI would
not be applied when invoking uri(URI).

This commit adds a note to the Javadoc to clarify that behavior.

Closes gh-28058
2022-02-16 12:11:33 +01:00
Sam Brannen e3ceb9b23d Polish @Target declarations for stereotype annotations 2022-02-16 12:01:14 +01:00
Arjen Poutsma 5ab966fbde Polish contribution
See gh-28038
2022-02-16 11:16:38 +01:00
vikey 7276752e7c Fix CronExpression issue with DST
This commit fixes an issue with CronExpression fails to calculate next
execution on the day of daylight saving time.

Closes gh-28038
2022-02-16 11:16:38 +01:00
Sam Brannen 685a195ba1 Deprecate SocketUtils
SocketUtils was introduced in Spring Framework 4.0, primarily to assist
in writing integration tests which start an external server on an
available random port. However, these utilities make no guarantee about
the subsequent availability of a given port and are therefore
unreliable. Instead of using SocketUtils to find an available local
port for a server, it is recommended that users rely on a server's
ability to start on a random port that it selects or is assigned by the
operating system. To interact with that server, the user should query
the server for the port it is currently using.

SocketUtils is now deprecated in 5.3.16 and will be removed in 6.0.

Closes gh-28052
2022-02-15 14:28:58 +01:00
Sam Brannen 3188c0f7db Ensure fix for gh-28012 is actually tested
In 3ec612aaf8, I accidentally removed tests that verified support for
non-synthesizable merged annotations for recursive annotations in
Kotlin.

This commit reinstates those non-synthesizable tests while retaining
the synthesizable tests.
2022-02-15 13:47:03 +01:00
Stephane Nicoll 3ea540adbc Upgrade to Reactor 2020.0.16
Closes gh-28039
2022-02-15 13:37:08 +01:00
rstoyanchev ec03e8830e Remove path variables from pathWithinMapping
Closes gh-27913
2022-02-14 20:51:02 +00:00
rstoyanchev 11cb938232 Polishing contribution
Closes gh-28000
2022-02-14 20:51:02 +00:00
Ivan Zbykovskyi f004bb1b64 Add formatting for SockJS GoAway frame
Prevents infinite loop for xhr-polling and xhr-streaming transports.

See gh-28000
2022-02-14 20:51:02 +00:00
Brian Clozel 88f73bffa0 Make assertion message lazy in ServletRequestPathUtils
Closes gh-27946
2022-02-14 16:21:41 +01:00
Brian Clozel 0ab054c7b9 Upgrade concourse-release-scripts in CI
This commit also reverts the change of resource type for the publication
of the CI image and fixes a bug in the CI image setup with available
JDKs.
2022-02-14 10:55:07 +01:00
Sébastien Deleuze 8eb618b480 Make Kotlin functions accessible in CoroutinesUtils
In order to allow using private classes like in Java
for example.

Closes gh-23840
2022-02-14 10:43:31 +01:00
Brian Clozel 2f78abd56e Upgrade CI pipeline
This commit upgrades the CI pipeline with the following:

* replace JDK16 with JDK17 as build variant
* upgrade all JDK versions
* replace docker-image with registry-image resource for CI image
2022-02-14 10:29:45 +01:00
Sam Brannen 3ec612aaf8 Support recursive annotations in merged annotations
Although Java does not allow the definition of recursive annotations,
Kotlin does, and prior to this commit an attempt to synthesize a
merged annotation using the MergedAnnotation API resulted in a
StackOverflowError if there was a recursive cycle in the annotation
definitions.

This commit addresses this issue by tracking which annotations have
already been visited and short circuits the recursive algorithm if a
cycle is detected.

Closes gh-28012
2022-02-12 23:42:57 +01:00
Sam Brannen 4eaee1e738 Short circuit if-conditions in AttributeMethods 2022-02-11 20:41:23 +01:00
Sébastien Deleuze eca755ec88 Upgrade to Dokka 1.6.10
Closes gh-28040
2022-02-11 17:42:06 +01:00
Stephane Nicoll 4201479546 Start building against Reactor 2020.0.16 snapshots
See gh-28039
2022-02-11 15:41:49 +01:00
Sam Brannen b60340b102 Simplify tests for synthesized annotation toString()
See gh-28015
2022-02-11 15:33:14 +01:00
Sam Brannen 2fd39839f8 Improve toString() for synthesized annotations
Although the initial report in gh-28015 only covered inconsistencies
for arrays and strings in the toString() implementations for
annotations between the JDK (after Java 9) and Spring, it has since
come to our attention that there was further room for improvement.

This commit therefore addresses the following in toString() output for
synthesized annotations.

- characters are now wrapped in single quotes.

- bytes are now properly formatted as "(byte) 0x##".

- long, float, and double values are now appended with "L", "f", and
  "d", respectively. The use of lowercase for "f" and "d" is solely to
  align with the choice made by the JDK team.

However, this commit does not address the following issues which we may
choose to address at a later point in time.

- non-ASCII, non-visible, and non-printable characters within a
  character or String literal are not escaped.

- formatting for float and double values does not take into account
  whether a value is not a number (NaN) or infinite.

Closes gh-28015
2022-02-10 17:14:37 +01:00
Sam Brannen ce87285be5 Use canonical names for types in synthesized annotation toString
My proposal for the same change in the JDK is currently targeted for
JDK 19.

- https://bugs.openjdk.java.net/browse/JDK-8281462
- https://bugs.openjdk.java.net/browse/JDK-8281568
- https://github.com/openjdk/jdk/pull/7418

See gh-28015
2022-02-10 16:59:00 +01:00
Sam Brannen 97582fd0a1 Update Eclipse template to @since 5.3.16 2022-02-10 13:43:02 +01:00
Stephane Nicoll d2c7dfb79e Add convenience factory method for Managed[List|Set|Map]
Closes gh-28026
2022-02-10 12:37:19 +01:00
Sam Brannen 7139a877f4 Ensure toString() for synthesized annotations is source code compatible
Since the introduction of synthesized annotation support in Spring
Framework 4.2 (a.k.a., merged annotations), the toString()
implementation attempted to align with the formatting used by the JDK
itself. However, Class annotation attributes were formatted using
Class#getName in Spring; whereas, the JDK used Class#toString up until
JDK 9.

In addition, JDK 9 introduced new formatting for toString() for
annotations, apparently intended to align with the syntax used in the
source code declaration of the annotation. However, JDK 9+ formats enum
annotation attributes using Enum#toString instead of Enum#name, which
can lead to issues if toString() is overridden in an enum.

This commit updates the formatting used for synthesized annotations by
ensuring that toString() generates a string that is compatible with the
syntax of the originating source code, going beyond the changes made in
JDK 9 by using Enum#name instead of Enum#toString.

Closes gh-28015
2022-02-08 14:10:36 +01:00
Sam Brannen 669b05dc1d Allow AutowiredAnnotationBeanPostProcessor to compile on JDK 11 2022-02-08 14:06:27 +01:00
Sam Brannen 038b88e2a1 Polishing 2022-02-05 20:23:45 +01:00
Sam Brannen eb84c84373 Polish contribution
See gh-27993
2022-02-05 20:15:30 +01:00
Gleidson Leopoldo 920be8e1b2 Add support for strict JSON comparison in WebTestClient
Prior to this commit, WebTestClient only supported "lenient" comparison
of the expected JSON body.

This commit introduces an overloaded variant of `json()` in the
BodyContentSpec that accepts an additional boolean flag to specify
whether a "strict" comparison should be performed.

This new feature is analogous to the existing support in MockMvc.

Closes gh-27993
2022-02-05 20:15:30 +01:00
Sam Brannen a13ad3e969 Polishing 2022-02-05 20:15:30 +01:00
Stephane Nicoll 874432b38a Merge pull request #28010 from izeye
* pr/28010:
  Fix Javadoc since for AopProxyUtils.isLambda()

Closes gh-28010
2022-02-05 13:59:33 +01:00
izeye 4ab03fede8 Fix Javadoc since for AopProxyUtils.isLambda()
See gh-28010
2022-02-05 13:59:01 +01:00
Juergen Hoeller 5bbdd36e19 Upgrade to Checkstyle 9.3, HtmlUnit 2.58, Apache HttpClient 5.1.3 2022-02-04 23:51:23 +01:00
Juergen Hoeller a22feac803 Update license header for https (nohttp rule)
See gh-27802
2022-02-04 23:51:05 +01:00
Juergen Hoeller bc9cd9a687 Find interface method even for late-bound interface declaration in subclass
Closes gh-27995
2022-02-04 23:21:27 +01:00
Juergen Hoeller a71a45e719 Deprecate AsyncTaskExecutor.execute(Runnable task, long startTimeout)
Closes gh-27959
2022-02-04 23:21:00 +01:00
Juergen Hoeller 132d8c7f45 Support for CGLIB BeanMap utility on JDK 17
Closes gh-27802
2022-02-04 23:19:06 +01:00
Sam Brannen 5d7a632965 Ensure Spring AOP generates JDK dynamic proxies for lambdas
Prior to this commit, if AOP proxy generation was configured with
proxyTargetClass=true (which is the default behavior in recent versions
of Spring Boot), beans implemented as lambda expressions or method
references could not be proxied with CGLIB on Java 16 or higher without
specifying `--add-opens java.base/java.lang=ALL-UNNAMED`.

This commit addresses this shortcoming by ensuring that beans
implemented as lambda expressions or method references are always
proxied using a JDK dynamic proxy even if proxyTargetClass=true.

Closes gh-27971
2022-02-04 19:59:35 +01:00
Stephane Nicoll 6bc7d41734 Merge pull request #28004 from An1s9n
* pr/28004:
  Polish reference to ManagedBean annotation

Closes gh-28004
2022-02-04 09:24:30 +01:00
Pavel Anisimov 05d3e820f9 Polish reference to ManagedBean annotation
See gh-28004
2022-02-04 09:23:32 +01:00
Sam Brannen f8a5a8d7be Use modern language features in tests 2022-02-03 14:50:10 +01:00
Stephane Nicoll 82a2544918 Upgrade to spring javaformat 0.0.31 2022-02-03 08:49:16 +01:00
Stephane Nicoll e702c22da4 Upgrade Ubuntu version in CI image 2022-02-03 08:48:52 +01:00
rstoyanchev c4e362500b Polishing tests 2022-02-02 17:09:04 +00:00
rstoyanchev 8d5a6520ce Ensure all converters don't close InputStream
Closes gh-27969
2022-02-02 15:55:13 +00:00
rstoyanchev 4effca35b5 Ignore Content-Type that is invalid (not concrete)
Closes gh-27957
2022-02-02 15:55:07 +00:00
Arjen Poutsma 8f9a1cdc0c Consider current date in "1W" cron expressions
Prior to this commit, the QuartzCronField::weekdayNearestTo would elapse
until the next month before checking if the current day matched.

After this commit, the current day is checked before we elapse until
the next month.

Closes gh-27966
2022-02-01 13:51:40 +01:00
Stephane Nicoll 136bd2002e Upgrade to spring javaformat 0.0.30 2022-01-31 09:34:12 +01:00
Sam Brannen a749a6bf54 Stop applying Groovy plugin for the root Gradle project
The root project does not rely on the Groovy plugin.

See gh-27945
2022-01-30 15:49:59 +01:00
Sam Brannen 7072aab53b Improve log message when searching for default executor for async processing
Closes gh-27983
2022-01-30 15:44:40 +01:00
Sam Brannen dbeae27d3c Reduce build time by reducing shutdown wait period for Jetty tests 2022-01-29 12:41:39 +01:00
Sam Brannen fb312d0ed5 Improve Javadoc for DatabasePopulator
See gh-27008
2022-01-28 16:40:35 +01:00
Sam Brannen 0e670b1c15 Polish contribution
See gh-27984
2022-01-28 16:15:21 +01:00
wkwkhautbois fadfcf4e43 Fix ServletUriComponentsBuilder examples in ref docs
Closes gh-27984
2022-01-28 16:10:54 +01:00
Arjen Poutsma caa13690e8 Support multiple boundary buffers in MultipartParser
In a small minority of cases, the multipart boundary can spread across
three incoming buffers.

Prior to this commit, MultipartParser.BodyState only supported two
buffers. If the boundary is spread across three buffers, the first
buffer of the three is sent as a whole, even though it contains the
first bytes of the boundary.

This commit fixes this bug, by enqueuing all prior buffers in a queue,
and emitting the ones that cannot contain boundary bytes.

Closes gh-27939
2022-01-28 13:42:24 +01:00
Sam Brannen 6647023151 Document how to register annotated classes in a GenericWebApplicationContext
Closes gh-27778
2022-01-27 16:08:16 +01:00
Sam Brannen e32f94bf8c Polish GenericWebApplicationContext and AnnotationConfigWebApplicationContext 2022-01-27 16:08:07 +01:00
Stephane Nicoll bd6d697395 Upgrade Java versions in CI image 2022-01-27 09:52:25 +01:00
Sam Brannen 7f65e17ff2 Improve documentation for implementing AspectJ around advice
Closes gh-27980
2022-01-26 17:32:48 +01:00
Sam Brannen 9095f1d584 Polish AspectJ documentation 2022-01-26 17:32:48 +01:00
Stephane Nicoll 4f16d5b5b2 Merge pull request #27826 from Drezir
* pr/27826:
  Polish "Add CacheErrorHandler implementation that logs exceptions"
  Add CacheErrorHandler implementation that logs exceptions

Closes gh-27826
2022-01-26 14:12:13 +01:00
Stephane Nicoll 6a6c7df824 Polish "Add CacheErrorHandler implementation that logs exceptions"
See gh-27826
2022-01-26 14:10:49 +01:00
Adam Ostrožlík 5c9fbcc23c Add CacheErrorHandler implementation that logs exceptions
See gh-27826
2022-01-26 14:10:49 +01:00
Sam Brannen f4f5cee76c Polish AOP namespace tests 2022-01-26 12:29:30 +01:00
Sam Brannen bf1cf549b1 Delete unused XML config in AOP namespace tests
See gh-22246
2022-01-26 12:15:10 +01:00
Juergen Hoeller 1272cd557d Upgrade to SmallRye Mutiny 1.3.1, Aalto 1.3.1, Woodstox 6.2.8 2022-01-26 00:02:12 +01:00
Juergen Hoeller 993b6d1351 Upgrade to Tomcat 9.0.58, Protobuf 3.19.3, Rome 1.18, H2 2.1.210, SLF4J 1.7.35, Mockito 4.3.1, HtmlUnit 2.57, XMLUnit 2.9, Checkstyle 9.2.1 2022-01-25 23:51:22 +01:00
Juergen Hoeller 0a92d84778 Check open status before close call (aligned with EntityManagerFactoryUtils)
Closes gh-27972
2022-01-25 23:50:45 +01:00
Sam Brannen 652c13a6ea Enable ReflectionUtilsTests.findMethodWithVarArgs()
See gh-13286
2022-01-25 09:58:57 +01:00
Sam Brannen cb3fa89946 Polish ReflectionUtilsTests 2022-01-25 09:57:36 +01:00
Sam Brannen d01dca14e9 Filter methods in Object in ReflectionUtils.USER_DECLARED_METHODS
Prior to this commit, the USER_DECLARED_METHODS MethodFilter in
ReflectionUtils did not actually filter methods declared in
java.lang.Object as stated in its Javadoc.

Consequently, if ReflectionUtils.doWithMethods was invoked with
USER_DECLARED_METHODS and Object.class as the class to introspect, all
non-bridge non-synthetic methods declared in java.lang.Object were
passed to the supplied MethodCallback, which breaks the contract of
USER_DECLARED_METHODS.

In addition, if USER_DECLARED_METHODS was composed with a custom
MethodFilter using `USER_DECLARED_METHODS.and(<custom MethodFilter>)`,
that composed method filter allowed all non-bridge non-synthetic
methods declared in java.lang.Object to be passed to the supplied
MethodCallback, which also breaks the contract of
USER_DECLARED_METHODS. This behavior resulted in regressions in code
that had previously used USER_DECLARED_METHODS by itself and then began
using USER_DECLARED_METHODS in a composed filter. For example, since
commit c419ea7ba7 ReflectiveAspectJAdvisorFactory has incorrectly
processed methods in java.lang.Object as candidates for advice methods.

This commit fixes this bug and associated regressions by ensuring that
USER_DECLARED_METHODS actually filters methods declared in
java.lang.Object. In addition, ReflectionUtils.doWithMethods now aborts
its search algorithm early if invoked with the USER_DECLARED_METHODS
filter and Object.class as the class to introspect.

Closes gh-27970
2022-01-24 20:09:22 +01:00
Sam Brannen d698446f7c Polish ReflectionUtils[Tests] 2022-01-24 19:46:40 +01:00
Stephane Nicoll 5ef023afd2 Merge pull request #27967 from arey
* pr/27967:
  Fix CaffeineCacheManager configuration example in reference doc

Closes gh-27967
2022-01-22 10:42:08 +01:00
Antoine Rey 316764cad0 Fix CaffeineCacheManager configuration example in reference doc
See gh-27967
2022-01-22 10:40:47 +01:00
Sam Brannen a681d6af22 Fix Javadoc links to JSR 305 annotations where feasible
Prior to this commit, we only (indirectly) configured external Javadoc
links for types in the javax.annotation package for JSR 250, since
those types are part of Java 8 SE. However, an external Javadoc link
for types from JSR 305 was not configured.

To address this issue, this commit now configures an external Javadoc
link for JSR 305 types. However, the external Javadoc link for JSR 305
must be configured last to ensure that types from JSR 250 (such as
@PostConstruct) are still supported. This is due to the fact that JSR
250 and JSR 305 both define types in javax.annotation, which results in
a split package, and the javadoc tool does not support split packages
across multiple external Javadoc sites. Instead, the Javadoc tool
iterates over all external links, and the first external site that
claims to support a given package (via the package-list file) wins.

This means:

- Javadoc for JSR 250 annotations is fully supported.
- Javadoc for JSR 305 annotations in the javax.annotation package will
  continue to result in a 404 (page not found) error.
- Javadoc for JSR 305 annotations in the javax.annotation.meta package
  is fully supported.

For Spring Framework 6.0, the Javadoc for JSR 250 types in
jakarta.annotation package is served from the JBoss Application Server
Javadoc site instead of from Oracle's Java SE documentation site, since
JSR 250 annotations are no longer included in Java SE.

Closes gh-27904
2022-01-21 16:07:55 +01:00
shirohoo 7211912057 Polish tests in spring-web
This PR polishes trivial things in tests in spring-web.

Closes gh-27958
2022-01-20 15:44:24 +01:00
Juergen Hoeller 148eac0200 Upgrade to SLF4J 1.7.33, Netty 4.1.73, R2DBC Arabba-SR12 2022-01-19 13:54:22 +01:00
Juergen Hoeller 86be03945b Polishing 2022-01-19 13:54:03 +01:00
Juergen Hoeller 537aced28b Avoid message listener recovery in case of persistence exceptions on commit
Closes gh-1807
2022-01-19 13:53:38 +01:00
Sam Brannen 5c76ff5ef6 Ensure unresolvable placeholders can be ignored with @Value
Prior to this commit, if a PropertySourcesPlaceholderConfigurer bean
was configured with its ignoreUnresolvablePlaceholders flag set to
true, unresolvable placeholders in an @Value annotation were not
ignored, resulting in a BeanCreationException for the bean using @Value.

For example, given a property declared as `my.app.var = ${var}` without
a corresponding `var` property declared, an attempt to resolve
`@Value("${my.app.var}")` resulted in the following exception.

java.lang.IllegalArgumentException: Could not resolve placeholder 'var' in value "${var}"

This commit fixes this by modifying
PropertySourcesPlaceholderConfigurer's postProcessBeanFactory(...)
method so that a local PropertyResolver is created if the
ignoreUnresolvablePlaceholders flag is set to true. The local
PropertyResolver then enforces that flag, since the Environment in the
ApplicationContext is most likely not configured with
ignoreUnresolvablePlaceholders set to true.

Closes gh-27947
2022-01-18 16:00:55 +01:00
Sam Brannen d02d5adb54 Download gradle-enterprise-conventions plugin from "release" repo
See gh-27942
2022-01-17 18:03:27 +01:00
Jerome Prinet 71f7469578 Upgrade to Gradle Enterprise 3.8.1
Closes gh-27942
2022-01-17 17:59:38 +01:00
Sam Brannen 420c4f3df3 Explicitly test BeanPropertyRowMapper.underscoreName(String)
See gh-27929
2022-01-17 16:54:03 +01:00
Sam Brannen 420ff46b2a Polishing 2022-01-17 16:54:03 +01:00
Marten Deinum 261bc2ad6a Fix regression in BeanPropertyRowMapper.underscoreName(String)
Commit 6316a35 introduced a regression for property names starting with
multiple uppercase letters (such as setEMail(...)).

This commit fixes that regression and includes an additional test to
cover this case.

See gh-27929
Closes gh-27941
2022-01-17 16:53:36 +01:00
Sam Brannen c92b9bc7fe Properly abort transferTo test for Undertow
Instead of simply returning prematurely and allowing the tests to be
marked as SUCCESS, this commit uses a failed assumption to abort the
the trasferTo tests for Undertow, resulting in the parameterized test
invocation properly being marked as ABORTED.

See gh-25310
2022-01-13 17:55:37 +01:00
Sam Brannen 4b1b25496b Improve comment parsing in DTD/XSD detection algorithm
Prior to this commit, XmlValidationModeDetector did not properly parse
all categories of comments (described below). When such categories of
comments were encountered XmlValidationModeDetector may have
incorrectly detected that an XML file used a DTD when it used an XSD,
or vice versa.

This commit revises the parsing algorithm in XmlValidationModeDetector
so that multi-line comments and multiple comments on a single line are
properly recognized.

Specifically, with this commit the following categories of comments are
now handled properly.

- Multiple comments on a single line
- Multi-line comment: beginning on one line and then ending on another
  line with an additional comment following on that same line.
- Multi-line comment: beginning at the end of XML content on one line
  and then spanning multiple lines.

Closes gh-27915
2022-01-13 16:11:15 +01:00
Sam Brannen 9e8b6feb54 Polishing 2022-01-13 14:56:14 +01:00
Spring Builds 3631d2f36e Next development version (v5.3.16-SNAPSHOT) 2022-01-13 11:22:39 +00:00
246 changed files with 3496 additions and 2032 deletions
+33 -28
View File
@@ -2,7 +2,7 @@ plugins {
id 'io.spring.dependency-management' version '1.0.11.RELEASE' apply false
id 'io.spring.nohttp' version '0.0.10'
id "io.freefair.aspectj" version '6.2.0' apply false
id 'org.jetbrains.dokka' version '1.5.0' apply false
id 'org.jetbrains.dokka' version '1.6.10' apply false
id 'org.jetbrains.kotlin.jvm' version '1.5.32' apply false
id "org.jetbrains.kotlin.plugin.serialization" version "1.5.32" apply false
id 'org.asciidoctor.jvm.convert' version '3.3.2'
@@ -28,11 +28,11 @@ configure(allprojects) { project ->
dependencyManagement {
imports {
mavenBom "com.fasterxml.jackson:jackson-bom:2.12.6"
mavenBom "io.netty:netty-bom:4.1.72.Final"
mavenBom "io.projectreactor:reactor-bom:2020.0.15"
mavenBom "io.r2dbc:r2dbc-bom:Arabba-SR11"
mavenBom "io.netty:netty-bom:4.1.74.Final"
mavenBom "io.projectreactor:reactor-bom:2020.0.16"
mavenBom "io.r2dbc:r2dbc-bom:Arabba-SR12"
mavenBom "io.rsocket:rsocket-bom:1.1.1"
mavenBom "org.eclipse.jetty:jetty-bom:9.4.44.v20210927"
mavenBom "org.eclipse.jetty:jetty-bom:9.4.45.v20220203"
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"
@@ -45,7 +45,7 @@ configure(allprojects) { project ->
entry 'log4j-jul'
entry 'log4j-slf4j-impl'
}
dependency "org.slf4j:slf4j-api:1.7.32"
dependency "org.slf4j:slf4j-api:1.7.35"
dependency("com.google.code.findbugs:findbugs:3.0.1") {
exclude group: "dom4j", name: "dom4j"
}
@@ -68,22 +68,22 @@ configure(allprojects) { project ->
dependency "io.reactivex:rxjava-reactive-streams:1.2.1"
dependency "io.reactivex.rxjava2:rxjava:2.2.21"
dependency "io.reactivex.rxjava3:rxjava:3.1.3"
dependency "io.smallrye.reactive:mutiny:1.2.0"
dependency "io.smallrye.reactive:mutiny:1.3.1"
dependency "io.projectreactor.tools:blockhound:1.0.6.RELEASE"
dependency "com.caucho:hessian:4.0.63"
dependency "com.fasterxml:aalto-xml:1.3.0"
dependency("com.fasterxml.woodstox:woodstox-core:6.2.7") {
dependency "com.fasterxml:aalto-xml:1.3.1"
dependency("com.fasterxml.woodstox:woodstox-core:6.2.8") {
exclude group: "stax", name: "stax-api"
}
dependency "com.google.code.gson:gson:2.8.9"
dependency "com.google.protobuf:protobuf-java-util:3.19.1"
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.18") {
exclude group: "xpp3", name: "xpp3_min"
exclude group: "xmlpull", name: "xmlpull"
}
dependency "org.apache.johnzon:johnzon-jsonb:1.2.15"
dependency "org.apache.johnzon:johnzon-jsonb:1.2.16"
dependency("org.codehaus.jettison:jettison:1.3.8") {
exclude group: "stax", name: "stax-api"
}
@@ -94,10 +94,10 @@ configure(allprojects) { project ->
dependency "org.ogce:xpp3:1.1.6"
dependency "org.yaml:snakeyaml:1.30"
dependency "com.h2database:h2:2.0.206"
dependency "com.h2database:h2:2.1.210"
dependency "com.github.ben-manes.caffeine:caffeine:2.9.3"
dependency "com.github.librepdf:openpdf:1.3.26"
dependency "com.rometools:rome:1.16.0"
dependency "com.rometools:rome:1.18.0"
dependency "commons-io:commons-io:2.5"
dependency "io.vavr:vavr:0.10.4"
dependency "net.sf.jopt-simple:jopt-simple:5.0.4"
@@ -124,22 +124,22 @@ configure(allprojects) { project ->
dependency "org.ehcache:jcache:1.0.1"
dependency "org.ehcache:ehcache:3.4.0"
dependency "org.hibernate:hibernate-core:5.4.33.Final"
dependency "org.hibernate:hibernate-validator:6.2.1.Final"
dependency "org.hibernate:hibernate-validator:6.2.2.Final"
dependency "org.webjars:webjars-locator-core:0.48"
dependency "org.webjars:underscorejs:1.8.3"
dependencySet(group: 'org.apache.tomcat', version: '9.0.56') {
dependencySet(group: 'org.apache.tomcat', version: '9.0.58') {
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.56') {
dependencySet(group: 'org.apache.tomcat.embed', version: '9.0.58') {
entry 'tomcat-embed-core'
entry 'tomcat-embed-websocket'
}
dependencySet(group: 'io.undertow', version: '2.2.14.Final') {
dependencySet(group: 'io.undertow', version: '2.2.16.Final') {
entry 'undertow-core'
entry('undertow-servlet') {
exclude group: "org.jboss.spec.javax.servlet", name: "jboss-servlet-api_4.0_spec"
@@ -151,8 +151,8 @@ configure(allprojects) { project ->
}
dependency "org.eclipse.jetty:jetty-reactive-httpclient:1.1.10"
dependency 'org.apache.httpcomponents.client5:httpclient5:5.1.2'
dependency 'org.apache.httpcomponents.core5:httpcore5-reactive:5.1.2'
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") {
exclude group: "commons-logging", name: "commons-logging"
}
@@ -192,13 +192,13 @@ configure(allprojects) { project ->
dependency "org.hamcrest:hamcrest:2.1"
dependency "org.awaitility:awaitility:3.1.6"
dependency "org.assertj:assertj-core:3.22.0"
dependencySet(group: 'org.xmlunit', version: '2.8.4') {
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.2.0') {
dependencySet(group: 'org.mockito', version: '4.3.1') {
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.56.0") {
dependency("net.sourceforge.htmlunit:htmlunit:2.58.0") {
exclude group: "commons-logging", name: "commons-logging"
}
dependency("org.seleniumhq.selenium:htmlunit-driver:2.56.0") {
dependency("org.seleniumhq.selenium:htmlunit-driver:2.58.0") {
exclude group: "commons-logging", name: "commons-logging"
}
dependency("org.seleniumhq.selenium:selenium-java:3.141.59") {
@@ -238,7 +238,7 @@ configure(allprojects) { project ->
dependency "com.ibm.websphere:uow:6.0.2.17"
dependency "com.jamonapi:jamon:2.82"
dependency "joda-time:joda-time:2.10.13"
dependency "org.eclipse.persistence:org.eclipse.persistence.jpa:2.7.9"
dependency "org.eclipse.persistence:org.eclipse.persistence.jpa:2.7.10"
dependency "org.javamoney:moneta:1.3"
dependency "com.sun.activation:javax.activation:1.2.0"
@@ -340,7 +340,7 @@ configure([rootProject] + javaProjects) { project ->
}
checkstyle {
toolVersion = "9.2"
toolVersion = "9.3"
configDirectory.set(rootProject.file("src/checkstyle"))
}
@@ -362,7 +362,7 @@ configure([rootProject] + javaProjects) { project ->
// JSR-305 only used for non-required meta-annotations
compileOnly("com.google.code.findbugs:jsr305")
testCompileOnly("com.google.code.findbugs:jsr305")
checkstyle("io.spring.javaformat:spring-javaformat-checkstyle:0.0.29")
checkstyle("io.spring.javaformat:spring-javaformat-checkstyle:0.0.31")
}
ext.javadocLinks = [
@@ -388,7 +388,13 @@ configure([rootProject] + javaProjects) { project ->
// "https://junit.org/junit5/docs/5.8.2/api/",
"https://www.reactive-streams.org/reactive-streams-1.0.3-javadoc/",
"https://javadoc.io/static/io.rsocket/rsocket-core/1.1.1/",
"https://r2dbc.io/spec/0.8.5.RELEASE/api/"
"https://r2dbc.io/spec/0.8.5.RELEASE/api/",
// The external Javadoc link for JSR 305 must come last to ensure that types from
// JSR 250 (such as @PostConstruct) are still supported. This is due to the fact
// that JSR 250 and JSR 305 both define types in javax.annotation, which results
// in a split package, and the javadoc tool does not support split packages
// across multiple external Javadoc sites.
"https://www.javadoc.io/doc/com.google.code.findbugs/jsr305/3.0.2/"
] as String[]
}
@@ -399,7 +405,6 @@ configure(moduleProjects) { project ->
configure(rootProject) {
description = "Spring Framework"
apply plugin: "groovy"
apply plugin: "kotlin"
apply plugin: "io.spring.nohttp"
apply plugin: 'org.springframework.build.api-diff'
+2 -2
View File
@@ -1,4 +1,4 @@
FROM ubuntu:focal-20210827
FROM ubuntu:focal-20220113
ADD setup.sh /setup.sh
ADD get-jdk-url.sh /get-jdk-url.sh
@@ -6,6 +6,6 @@ RUN ./setup.sh java8
ENV JAVA_HOME /opt/openjdk/java8
ENV JDK11 /opt/openjdk/java11
ENV JDK16 /opt/openjdk/java16
ENV JDK17 /opt/openjdk/java17
ENV PATH $JAVA_HOME/bin:$PATH
+7 -4
View File
@@ -3,13 +3,16 @@ set -e
case "$1" in
java8)
echo "https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u302-b08/OpenJDK8U-jdk_x64_linux_hotspot_8u302b08.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/adoptium/temurin11-binaries/releases/download/jdk-11.0.12%2B7/OpenJDK11U-jdk_x64_linux_hotspot_11.0.12_7.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"
;;
java16)
echo "https://github.com/adoptium/temurin16-binaries/releases/download/jdk-16.0.2%2B7/OpenJDK16U-jdk_x64_linux_hotspot_16.0.2_7.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/jdk18-2022-02-12-08-06-beta/OpenJDK18-jdk_x64_linux_hotspot_2022-02-12-08-06.tar.gz"
;;
*)
echo $"Unknown java version"
+2 -2
View File
@@ -14,7 +14,7 @@ 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
curl --output /opt/concourse-release-scripts.jar https://repo.spring.io/release/io/spring/concourse/releasescripts/concourse-release-scripts/0.3.3/concourse-release-scripts-0.3.3.jar
###########################################################
# JAVA
@@ -22,7 +22,7 @@ curl --output /opt/concourse-release-scripts.jar https://repo.spring.io/release/
mkdir -p /opt/openjdk
pushd /opt/openjdk > /dev/null
for jdk in java8 java11 java16
for jdk in java8 java11 java17
do
JDK_URL=$( /get-jdk-url.sh $jdk )
mkdir $jdk
-3
View File
@@ -1,6 +1,3 @@
email-server: "smtp.svc.pivotal.io"
email-from: "ci@spring.io"
email-to: ["spring-framework-dev@pivotal.io"]
github-repo: "https://github.com/spring-projects/spring-framework.git"
github-repo-name: "spring-projects/spring-framework"
docker-hub-organization: "springci"
+7 -7
View File
@@ -124,14 +124,14 @@ resources:
access_token: ((github-ci-status-token))
branch: ((branch))
context: jdk11-build
- name: repo-status-jdk16-build
- name: repo-status-jdk17-build
type: github-status-resource
icon: eye-check-outline
source:
repository: ((github-repo-name))
access_token: ((github-ci-status-token))
branch: ((branch))
context: jdk16-build
context: jdk17-build
- name: slack-alert
type: slack-notification
icon: slack
@@ -249,7 +249,7 @@ jobs:
<<: *slack-fail-params
- put: repo-status-jdk11-build
params: { state: "success", commit: "git-repo" }
- name: jdk16-build
- name: jdk17-build
serial: true
public: true
plan:
@@ -257,7 +257,7 @@ jobs:
- get: git-repo
- get: every-morning
trigger: true
- put: repo-status-jdk16-build
- put: repo-status-jdk17-build
params: { state: "pending", commit: "git-repo" }
- do:
- task: check-project
@@ -270,12 +270,12 @@ jobs:
<<: *build-project-task-params
on_failure:
do:
- put: repo-status-jdk16-build
- put: repo-status-jdk17-build
params: { state: "failure", commit: "git-repo" }
- put: slack-alert
params:
<<: *slack-fail-params
- put: repo-status-jdk16-build
- put: repo-status-jdk17-build
params: { state: "success", commit: "git-repo" }
- name: build-pull-requests
serial: true
@@ -458,7 +458,7 @@ jobs:
groups:
- name: "builds"
jobs: ["build", "jdk11-build", "jdk16-build"]
jobs: ["build", "jdk11-build", "jdk17-build"]
- name: "releases"
jobs: ["stage-milestone", "stage-rc", "stage-release", "promote-milestone", "promote-rc", "promote-release", "create-github-release"]
- name: "ci-images"
+1 -1
View File
@@ -1,4 +1,4 @@
version=5.3.15
version=5.3.16
org.gradle.jvmargs=-Xmx1536M
org.gradle.caching=true
org.gradle.parallel=true
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 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,6 @@ import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.ClassPathBeanDefinitionScanner;
import org.springframework.context.annotation.ScopeMetadata;
import org.springframework.context.annotation.ScopeMetadataResolver;
import org.springframework.context.annotation.ScopedProxyMode;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpSession;
@@ -307,29 +306,26 @@ class ClassPathBeanDefinitionScannerJsr330ScopeIntegrationTests {
GenericWebApplicationContext context = new GenericWebApplicationContext();
ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context);
scanner.setIncludeAnnotationConfig(false);
scanner.setScopeMetadataResolver(new ScopeMetadataResolver() {
@Override
public ScopeMetadata resolveScopeMetadata(BeanDefinition definition) {
ScopeMetadata metadata = new ScopeMetadata();
if (definition instanceof AnnotatedBeanDefinition) {
AnnotatedBeanDefinition annDef = (AnnotatedBeanDefinition) definition;
for (String type : annDef.getMetadata().getAnnotationTypes()) {
if (type.equals(javax.inject.Singleton.class.getName())) {
metadata.setScopeName(BeanDefinition.SCOPE_SINGLETON);
break;
}
else if (annDef.getMetadata().getMetaAnnotationTypes(type).contains(javax.inject.Scope.class.getName())) {
metadata.setScopeName(type.substring(type.length() - 13, type.length() - 6).toLowerCase());
metadata.setScopedProxyMode(scopedProxyMode);
break;
}
else if (type.startsWith("javax.inject")) {
metadata.setScopeName(BeanDefinition.SCOPE_PROTOTYPE);
}
scanner.setScopeMetadataResolver(definition -> {
ScopeMetadata metadata = new ScopeMetadata();
if (definition instanceof AnnotatedBeanDefinition) {
AnnotatedBeanDefinition annDef = (AnnotatedBeanDefinition) definition;
for (String type : annDef.getMetadata().getAnnotationTypes()) {
if (type.equals(javax.inject.Singleton.class.getName())) {
metadata.setScopeName(BeanDefinition.SCOPE_SINGLETON);
break;
}
else if (annDef.getMetadata().getMetaAnnotationTypes(type).contains(javax.inject.Scope.class.getName())) {
metadata.setScopeName(type.substring(type.length() - 13, type.length() - 6).toLowerCase());
metadata.setScopedProxyMode(scopedProxyMode);
break;
}
else if (type.startsWith("javax.inject")) {
metadata.setScopeName(BeanDefinition.SCOPE_PROTOTYPE);
}
}
return metadata;
}
return metadata;
});
// Scan twice in order to find errors in the bean definition compatibility check.
+4 -3
View File
@@ -1,13 +1,14 @@
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
maven { url "https://repo.spring.io/plugins-release" }
maven { url "https://repo.spring.io/release" }
}
}
plugins {
id "com.gradle.enterprise" version "3.7.2"
id "io.spring.ge.conventions" version "0.0.7"
id "com.gradle.enterprise" version "3.8.1"
id "io.spring.ge.conventions" version "0.0.9"
}
include "spring-aop"
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2022 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,6 +44,7 @@ import org.springframework.util.ReflectionUtils;
*
* @author Rod Johnson
* @author Juergen Hoeller
* @author Sam Brannen
* @see org.springframework.aop.support.AopUtils
*/
public abstract class AopProxyUtils {
@@ -133,7 +134,7 @@ public abstract class AopProxyUtils {
if (targetClass.isInterface()) {
advised.setInterfaces(targetClass);
}
else if (Proxy.isProxyClass(targetClass)) {
else if (Proxy.isProxyClass(targetClass) || isLambda(targetClass)) {
advised.setInterfaces(targetClass.getInterfaces());
}
specifiedInterfaces = advised.getProxiedInterfaces();
@@ -244,4 +245,18 @@ public abstract class AopProxyUtils {
return arguments;
}
/**
* Determine if the supplied {@link Class} is a JVM-generated implementation
* class for a lambda expression or method reference.
* <p>This method makes a best-effort attempt at determining this, based on
* checks that work on modern, main stream JVMs.
* @param clazz the class to check
* @return {@code true} if the class is a lambda implementation class
* @since 5.3.16
*/
static boolean isLambda(Class<?> clazz) {
return (clazz.isSynthetic() && (clazz.getSuperclass() == Object.class) &&
(clazz.getInterfaces().length > 0) && clazz.getName().contains("$$Lambda"));
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2022 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.
@@ -40,6 +40,7 @@ import org.springframework.core.NativeDetector;
* @author Rod Johnson
* @author Juergen Hoeller
* @author Sebastien Deleuze
* @author Sam Brannen
* @since 12.03.2004
* @see AdvisedSupport#setOptimize
* @see AdvisedSupport#setProxyTargetClass
@@ -59,7 +60,7 @@ public class DefaultAopProxyFactory implements AopProxyFactory, Serializable {
throw new AopConfigException("TargetSource cannot determine target class: " +
"Either an interface or a target is required for proxy creation.");
}
if (targetClass.isInterface() || Proxy.isProxyClass(targetClass)) {
if (targetClass.isInterface() || Proxy.isProxyClass(targetClass) || AopProxyUtils.isLambda(targetClass)) {
return new JdkDynamicAopProxy(config);
}
return new ObjenesisCglibAopProxy(config);
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2022 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.
@@ -233,7 +233,8 @@ public abstract class AsyncExecutionAspectSupport implements BeanFactoryAware {
return beanFactory.getBean(TaskExecutor.class);
}
catch (NoUniqueBeanDefinitionException ex) {
logger.debug("Could not find unique TaskExecutor bean", ex);
logger.debug("Could not find unique TaskExecutor bean. " +
"Continuing search for an Executor bean named 'taskExecutor'", ex);
try {
return beanFactory.getBean(DEFAULT_TASK_EXECUTOR_BEAN_NAME, Executor.class);
}
@@ -246,7 +247,8 @@ public abstract class AsyncExecutionAspectSupport implements BeanFactoryAware {
}
}
catch (NoSuchBeanDefinitionException ex) {
logger.debug("Could not find default TaskExecutor bean", ex);
logger.debug("Could not find default TaskExecutor bean. " +
"Continuing search for an Executor bean named 'taskExecutor'", ex);
try {
return beanFactory.getBean(DEFAULT_TASK_EXECUTOR_BEAN_NAME, Executor.class);
}
@@ -98,7 +98,7 @@ abstract class AbstractAspectJAdvisorFactoryTests {
}
@Test
void perTargetAspect() throws SecurityException, NoSuchMethodException {
void perTargetAspect() throws Exception {
TestBean target = new TestBean();
int realAge = 65;
target.setAge(realAge);
@@ -130,7 +130,7 @@ abstract class AbstractAspectJAdvisorFactoryTests {
}
@Test
void multiplePerTargetAspects() throws SecurityException, NoSuchMethodException {
void multiplePerTargetAspects() throws Exception {
TestBean target = new TestBean();
int realAge = 65;
target.setAge(realAge);
@@ -158,7 +158,7 @@ abstract class AbstractAspectJAdvisorFactoryTests {
}
@Test
void multiplePerTargetAspectsWithOrderAnnotation() throws SecurityException, NoSuchMethodException {
void multiplePerTargetAspectsWithOrderAnnotation() throws Exception {
TestBean target = new TestBean();
int realAge = 65;
target.setAge(realAge);
@@ -184,7 +184,7 @@ abstract class AbstractAspectJAdvisorFactoryTests {
}
@Test
void perThisAspect() throws SecurityException, NoSuchMethodException {
void perThisAspect() throws Exception {
TestBean target = new TestBean();
int realAge = 65;
target.setAge(realAge);
@@ -220,7 +220,7 @@ abstract class AbstractAspectJAdvisorFactoryTests {
}
@Test
void perTypeWithinAspect() throws SecurityException, NoSuchMethodException {
void perTypeWithinAspect() throws Exception {
TestBean target = new TestBean();
int realAge = 65;
target.setAge(realAge);
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2022 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 static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
/**
* @since 2.0
* @author Rod Johnson
* @author Chris Beams
* @author Sam Brannen
@@ -56,7 +55,7 @@ class AspectMetadataTests {
assertThat(am.getAjType().getPerClause().getKind()).isEqualTo(PerClauseKind.PERTARGET);
assertThat(am.getPerClausePointcut()).isInstanceOf(AspectJExpressionPointcut.class);
assertThat(((AspectJExpressionPointcut) am.getPerClausePointcut()).getExpression())
.isEqualTo("execution(* *.getSpouse())");
.isEqualTo("execution(* *.getSpouse())");
}
@Test
@@ -67,7 +66,7 @@ class AspectMetadataTests {
assertThat(am.getAjType().getPerClause().getKind()).isEqualTo(PerClauseKind.PERTHIS);
assertThat(am.getPerClausePointcut()).isInstanceOf(AspectJExpressionPointcut.class);
assertThat(((AspectJExpressionPointcut) am.getPerClausePointcut()).getExpression())
.isEqualTo("execution(* *.getSpouse())");
.isEqualTo("execution(* *.getSpouse())");
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@
package org.springframework.aop.config;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
@@ -40,7 +41,7 @@ import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifie
* @author Juergen Hoeller
* @author Chris Beams
*/
public class AopNamespaceHandlerEventTests {
class AopNamespaceHandlerEventTests {
private static final Class<?> CLASS = AopNamespaceHandlerEventTests.class;
@@ -57,25 +58,24 @@ public class AopNamespaceHandlerEventTests {
@BeforeEach
public void setup() {
void setup() {
this.reader = new XmlBeanDefinitionReader(this.beanFactory);
this.reader.setEventListener(this.eventListener);
}
@Test
public void testPointcutEvents() {
void pointcutEvents() {
this.reader.loadBeanDefinitions(POINTCUT_EVENTS_CONTEXT);
ComponentDefinition[] componentDefinitions = this.eventListener.getComponentDefinitions();
assertThat(componentDefinitions.length).as("Incorrect number of events fired").isEqualTo(1);
boolean condition = componentDefinitions[0] instanceof CompositeComponentDefinition;
assertThat(condition).as("No holder with nested components").isTrue();
assertThat(componentDefinitions).as("Incorrect number of events fired").hasSize(1);
assertThat(componentDefinitions[0]).as("No holder with nested components").isInstanceOf(CompositeComponentDefinition.class);
CompositeComponentDefinition compositeDef = (CompositeComponentDefinition) componentDefinitions[0];
assertThat(compositeDef.getName()).isEqualTo("aop:config");
ComponentDefinition[] nestedComponentDefs = compositeDef.getNestedComponents();
assertThat(nestedComponentDefs.length).as("Incorrect number of inner components").isEqualTo(2);
assertThat(nestedComponentDefs).as("Incorrect number of inner components").hasSize(2);
PointcutComponentDefinition pcd = null;
for (ComponentDefinition componentDefinition : nestedComponentDefs) {
if (componentDefinition instanceof PointcutComponentDefinition) {
@@ -84,84 +84,77 @@ public class AopNamespaceHandlerEventTests {
}
}
assertThat(pcd).as("PointcutComponentDefinition not found").isNotNull();
assertThat(pcd.getBeanDefinitions().length).as("Incorrect number of BeanDefinitions").isEqualTo(1);
assertThat(pcd.getBeanDefinitions()).as("Incorrect number of BeanDefinitions").hasSize(1);
}
@Test
public void testAdvisorEventsWithPointcutRef() {
void advisorEventsWithPointcutRef() {
this.reader.loadBeanDefinitions(POINTCUT_REF_CONTEXT);
ComponentDefinition[] componentDefinitions = this.eventListener.getComponentDefinitions();
assertThat(componentDefinitions.length).as("Incorrect number of events fired").isEqualTo(2);
assertThat(componentDefinitions).as("Incorrect number of events fired").hasSize(2);
boolean condition1 = componentDefinitions[0] instanceof CompositeComponentDefinition;
assertThat(condition1).as("No holder with nested components").isTrue();
assertThat(componentDefinitions[0]).as("No holder with nested components").isInstanceOf(CompositeComponentDefinition.class);
CompositeComponentDefinition compositeDef = (CompositeComponentDefinition) componentDefinitions[0];
assertThat(compositeDef.getName()).isEqualTo("aop:config");
ComponentDefinition[] nestedComponentDefs = compositeDef.getNestedComponents();
assertThat(nestedComponentDefs.length).as("Incorrect number of inner components").isEqualTo(3);
assertThat(nestedComponentDefs).as("Incorrect number of inner components").hasSize(3);
AdvisorComponentDefinition acd = null;
for (int i = 0; i < nestedComponentDefs.length; i++) {
ComponentDefinition componentDefinition = nestedComponentDefs[i];
for (ComponentDefinition componentDefinition : nestedComponentDefs) {
if (componentDefinition instanceof AdvisorComponentDefinition) {
acd = (AdvisorComponentDefinition) componentDefinition;
break;
}
}
assertThat(acd).as("AdvisorComponentDefinition not found").isNotNull();
assertThat(acd.getBeanDefinitions().length).isEqualTo(1);
assertThat(acd.getBeanReferences().length).isEqualTo(2);
assertThat(acd.getBeanDefinitions()).hasSize(1);
assertThat(acd.getBeanReferences()).hasSize(2);
boolean condition = componentDefinitions[1] instanceof BeanComponentDefinition;
assertThat(condition).as("No advice bean found").isTrue();
assertThat(componentDefinitions[1]).as("No advice bean found").isInstanceOf(BeanComponentDefinition.class);
BeanComponentDefinition adviceDef = (BeanComponentDefinition) componentDefinitions[1];
assertThat(adviceDef.getBeanName()).isEqualTo("countingAdvice");
}
@Test
public void testAdvisorEventsWithDirectPointcut() {
void advisorEventsWithDirectPointcut() {
this.reader.loadBeanDefinitions(DIRECT_POINTCUT_EVENTS_CONTEXT);
ComponentDefinition[] componentDefinitions = this.eventListener.getComponentDefinitions();
assertThat(componentDefinitions.length).as("Incorrect number of events fired").isEqualTo(2);
assertThat(componentDefinitions).as("Incorrect number of events fired").hasSize(2);
boolean condition1 = componentDefinitions[0] instanceof CompositeComponentDefinition;
assertThat(condition1).as("No holder with nested components").isTrue();
assertThat(componentDefinitions[0]).as("No holder with nested components").isInstanceOf(CompositeComponentDefinition.class);
CompositeComponentDefinition compositeDef = (CompositeComponentDefinition) componentDefinitions[0];
assertThat(compositeDef.getName()).isEqualTo("aop:config");
ComponentDefinition[] nestedComponentDefs = compositeDef.getNestedComponents();
assertThat(nestedComponentDefs.length).as("Incorrect number of inner components").isEqualTo(2);
assertThat(nestedComponentDefs).as("Incorrect number of inner components").hasSize(2);
AdvisorComponentDefinition acd = null;
for (int i = 0; i < nestedComponentDefs.length; i++) {
ComponentDefinition componentDefinition = nestedComponentDefs[i];
for (ComponentDefinition componentDefinition : nestedComponentDefs) {
if (componentDefinition instanceof AdvisorComponentDefinition) {
acd = (AdvisorComponentDefinition) componentDefinition;
break;
}
}
assertThat(acd).as("AdvisorComponentDefinition not found").isNotNull();
assertThat(acd.getBeanDefinitions().length).isEqualTo(2);
assertThat(acd.getBeanReferences().length).isEqualTo(1);
assertThat(acd.getBeanDefinitions()).hasSize(2);
assertThat(acd.getBeanReferences()).hasSize(1);
boolean condition = componentDefinitions[1] instanceof BeanComponentDefinition;
assertThat(condition).as("No advice bean found").isTrue();
assertThat(componentDefinitions[1]).as("No advice bean found").isInstanceOf(BeanComponentDefinition.class);
BeanComponentDefinition adviceDef = (BeanComponentDefinition) componentDefinitions[1];
assertThat(adviceDef.getBeanName()).isEqualTo("countingAdvice");
}
@Test
public void testAspectEvent() {
void aspectEvent() {
this.reader.loadBeanDefinitions(CONTEXT);
ComponentDefinition[] componentDefinitions = this.eventListener.getComponentDefinitions();
assertThat(componentDefinitions.length).as("Incorrect number of events fired").isEqualTo(5);
assertThat(componentDefinitions).as("Incorrect number of events fired").hasSize(2);
boolean condition = componentDefinitions[0] instanceof CompositeComponentDefinition;
assertThat(condition).as("No holder with nested components").isTrue();
assertThat(componentDefinitions[0]).as("No holder with nested components").isInstanceOf(CompositeComponentDefinition.class);
CompositeComponentDefinition compositeDef = (CompositeComponentDefinition) componentDefinitions[0];
assertThat(compositeDef.getName()).isEqualTo("aop:config");
ComponentDefinition[] nestedComponentDefs = compositeDef.getNestedComponents();
assertThat(nestedComponentDefs.length).as("Incorrect number of inner components").isEqualTo(2);
assertThat(nestedComponentDefs).as("Incorrect number of inner components").hasSize(2);
AspectComponentDefinition acd = null;
for (ComponentDefinition componentDefinition : nestedComponentDefs) {
if (componentDefinition instanceof AspectComponentDefinition) {
@@ -172,9 +165,9 @@ public class AopNamespaceHandlerEventTests {
assertThat(acd).as("AspectComponentDefinition not found").isNotNull();
BeanDefinition[] beanDefinitions = acd.getBeanDefinitions();
assertThat(beanDefinitions.length).isEqualTo(5);
assertThat(beanDefinitions).hasSize(5);
BeanReference[] beanReferences = acd.getBeanReferences();
assertThat(beanReferences.length).isEqualTo(6);
assertThat(beanReferences).hasSize(6);
Set<String> expectedReferences = new HashSet<>();
expectedReferences.add("pc");
@@ -182,19 +175,16 @@ public class AopNamespaceHandlerEventTests {
for (BeanReference beanReference : beanReferences) {
expectedReferences.remove(beanReference.getBeanName());
}
assertThat(expectedReferences.size()).as("Incorrect references found").isEqualTo(0);
assertThat(expectedReferences).as("Incorrect references found").isEmpty();
for (int i = 1; i < componentDefinitions.length; i++) {
boolean condition1 = componentDefinitions[i] instanceof BeanComponentDefinition;
assertThat(condition1).isTrue();
}
Arrays.stream(componentDefinitions).skip(1).forEach(definition ->
assertThat(definition).isInstanceOf(BeanComponentDefinition.class));
ComponentDefinition[] nestedComponentDefs2 = acd.getNestedComponents();
assertThat(nestedComponentDefs2.length).as("Inner PointcutComponentDefinition not found").isEqualTo(1);
boolean condition1 = nestedComponentDefs2[0] instanceof PointcutComponentDefinition;
assertThat(condition1).isTrue();
assertThat(nestedComponentDefs2).as("Inner PointcutComponentDefinition not found").hasSize(1);
assertThat(nestedComponentDefs2[0]).isInstanceOf(PointcutComponentDefinition.class);
PointcutComponentDefinition pcd = (PointcutComponentDefinition) nestedComponentDefs2[0];
assertThat(pcd.getBeanDefinitions().length).as("Incorrect number of BeanDefinitions").isEqualTo(1);
assertThat(pcd.getBeanDefinitions()).as("Incorrect number of BeanDefinitions").hasSize(1);
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 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.
@@ -30,10 +30,10 @@ import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifie
* @author Mark Fisher
* @author Chris Beams
*/
public class AopNamespaceHandlerPointcutErrorTests {
class AopNamespaceHandlerPointcutErrorTests {
@Test
public void testDuplicatePointcutConfig() {
void duplicatePointcutConfig() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
assertThatExceptionOfType(BeanDefinitionStoreException.class).isThrownBy(() ->
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
@@ -42,7 +42,7 @@ public class AopNamespaceHandlerPointcutErrorTests {
}
@Test
public void testMissingPointcutConfig() {
void missingPointcutConfig() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
assertThatExceptionOfType(BeanDefinitionStoreException.class).isThrownBy(() ->
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 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.
@@ -30,10 +30,10 @@ import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifie
* @author Rob Harrop
* @author Chris Beams
*/
public class TopLevelAopTagTests {
class TopLevelAopTagTests {
@Test
public void testParse() {
void parse() {
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(beanFactory).loadBeanDefinitions(
qualifiedResource(TopLevelAopTagTests.class, "context.xml"));
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 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,6 +19,7 @@ package org.springframework.aop.framework;
import java.lang.reflect.Proxy;
import java.util.Arrays;
import java.util.List;
import java.util.function.Supplier;
import org.junit.jupiter.api.Test;
@@ -32,6 +33,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
/**
* @author Rod Johnson
* @author Chris Beams
* @author Sam Brannen
*/
public class AopProxyUtilsTests {
@@ -132,4 +134,61 @@ public class AopProxyUtilsTests {
AopProxyUtils.proxiedUserInterfaces(proxy));
}
@Test
void isLambda() {
assertIsLambda(AopProxyUtilsTests.staticLambdaExpression);
assertIsLambda(AopProxyUtilsTests::staticStringFactory);
assertIsLambda(this.instanceLambdaExpression);
assertIsLambda(this::instanceStringFactory);
}
@Test
void isNotLambda() {
assertIsNotLambda(new EnigmaSupplier());
assertIsNotLambda(new Supplier<String>() {
@Override
public String get() {
return "anonymous inner class";
}
});
assertIsNotLambda(new Fake$$LambdaSupplier());
}
private static void assertIsLambda(Supplier<String> supplier) {
assertThat(AopProxyUtils.isLambda(supplier.getClass())).isTrue();
}
private static void assertIsNotLambda(Supplier<String> supplier) {
assertThat(AopProxyUtils.isLambda(supplier.getClass())).isFalse();
}
private static final Supplier<String> staticLambdaExpression = () -> "static lambda expression";
private final Supplier<String> instanceLambdaExpression = () -> "instance lambda expressions";
private static String staticStringFactory() {
return "static string factory";
}
private String instanceStringFactory() {
return "instance string factory";
}
private static class EnigmaSupplier implements Supplier<String> {
@Override
public String get() {
return "enigma";
}
}
private static class Fake$$LambdaSupplier implements Supplier<String> {
@Override
public String get() {
return "fake lambda";
}
}
}
@@ -125,16 +125,7 @@ public class ConcurrencyThrottleInterceptorTests {
try {
this.proxy.exceptional(this.ex);
}
catch (RuntimeException ex) {
if (ex == this.ex) {
logger.debug("Expected exception thrown", ex);
}
else {
// should never happen
ex.printStackTrace();
}
}
catch (Error err) {
catch (RuntimeException | Error err) {
if (err == this.ex) {
logger.debug("Expected exception thrown", err);
}
@@ -16,12 +16,6 @@
</aop:aspect>
</aop:config>
<bean id="getNameCounter" class="org.springframework.aop.testfixture.advice.CountingBeforeAdvice"/>
<bean id="getAgeCounter" class="org.springframework.aop.testfixture.advice.CountingBeforeAdvice"/>
<bean id="testBean" class="org.springframework.beans.testfixture.beans.TestBean"/>
<bean id="countingAdvice" class="org.springframework.aop.config.CountingAspectJAdvice"/>
</beans>
@@ -12,10 +12,6 @@
</aop:aspect>
</aop:config>
<bean id="getAgeCounter" class="org.springframework.aop.testfixture.advice.CountingBeforeAdvice"/>
<bean id="testBean" class="org.springframework.beans.testfixture.beans.TestBean"/>
<bean id="countingAdvice" class="org.springframework.aop.config.CountingAspectJAdvice"/>
</beans>
@@ -12,10 +12,6 @@
</aop:aspect>
</aop:config>
<bean id="getAgeCounter" class="org.springframework.aop.testfixture.advice.CountingBeforeAdvice"/>
<bean id="testBean" class="org.springframework.beans.testfixture.beans.TestBean"/>
<bean id="countingAdvice" class="org.springframework.aop.config.CountingAspectJAdvice"/>
</beans>
@@ -537,10 +537,10 @@ public class AutowiredAnnotationBeanPostProcessor implements SmartInstantiationA
* @param ann the Autowired annotation
* @return whether the annotation indicates that a dependency is required
*/
@SuppressWarnings({"deprecation", "cast"})
@SuppressWarnings("deprecation")
protected boolean determineRequiredStatus(MergedAnnotation<?> ann) {
return determineRequiredStatus(
ann.asMap(mergedAnnotation -> new AnnotationAttributes(mergedAnnotation.getType())));
return determineRequiredStatus(ann.<AnnotationAttributes> asMap(
mergedAnnotation -> new AnnotationAttributes(mergedAnnotation.getType())));
}
/**
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2022 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.
@@ -1908,7 +1908,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
if (logger.isTraceEnabled()) {
logger.trace("Invoking init method '" + initMethodName + "' on bean with name '" + beanName + "'");
}
Method methodToInvoke = ClassUtils.getInterfaceMethodIfPossible(initMethod);
Method methodToInvoke = ClassUtils.getInterfaceMethodIfPossible(initMethod, bean.getClass());
if (System.getSecurityManager() != null) {
AccessController.doPrivileged((PrivilegedAction<Object>) () -> {
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -138,7 +138,7 @@ class DisposableBeanAdapter implements DisposableBean, Runnable, Serializable {
beanName + "' has a non-boolean parameter - not supported as destroy method");
}
}
destroyMethod = ClassUtils.getInterfaceMethodIfPossible(destroyMethod);
destroyMethod = ClassUtils.getInterfaceMethodIfPossible(destroyMethod, bean.getClass());
}
this.destroyMethod = destroyMethod;
}
@@ -252,9 +252,9 @@ class DisposableBeanAdapter implements DisposableBean, Runnable, Serializable {
invokeCustomDestroyMethod(this.destroyMethod);
}
else if (this.destroyMethodName != null) {
Method methodToInvoke = determineDestroyMethod(this.destroyMethodName);
if (methodToInvoke != null) {
invokeCustomDestroyMethod(ClassUtils.getInterfaceMethodIfPossible(methodToInvoke));
Method destroyMethod = determineDestroyMethod(this.destroyMethodName);
if (destroyMethod != null) {
invokeCustomDestroyMethod(ClassUtils.getInterfaceMethodIfPossible(destroyMethod, this.bean.getClass()));
}
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2022 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.
@@ -17,6 +17,7 @@
package org.springframework.beans.factory.support;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.springframework.beans.BeanMetadataElement;
@@ -53,6 +54,20 @@ public class ManagedList<E> extends ArrayList<E> implements Mergeable, BeanMetad
}
/**
* 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 List} containing the specified elements
* @since 5.3.16
*/
@SuppressWarnings("unchecked")
public static <E> ManagedList<E> of(E... elements) {
ManagedList<E> list = new ManagedList<>();
list.addAll(Arrays.asList(elements));
return list;
}
/**
* Set the configuration source {@code Object} for this metadata element.
* <p>The exact type of the object will depend on the configuration mechanism used.
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,6 +18,7 @@ package org.springframework.beans.factory.support;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
import org.springframework.beans.BeanMetadataElement;
import org.springframework.beans.Mergeable;
@@ -56,6 +57,25 @@ public class ManagedMap<K, V> extends LinkedHashMap<K, V> implements Mergeable,
}
/**
* Return a new instance containing keys and values extracted from the
* given entries. The entries themselves are not stored in the map.
* @param entries {@code Map.Entry}s containing the keys and values
* from which the map is populated
* @param <K> the {@code Map}'s key type
* @param <V> the {@code Map}'s value type
* @return a {@code Map} containing the specified mappings
* @since 5.3.16
*/
@SuppressWarnings("unchecked")
public static <K,V> ManagedMap<K,V> ofEntries(Entry<? extends K, ? extends V>... entries) {
ManagedMap<K,V > map = new ManagedMap<>();
for (Entry<? extends K, ? extends V> entry : entries) {
map.put(entry.getKey(), entry.getValue());
}
return map;
}
/**
* Set the configuration source {@code Object} for this metadata element.
* <p>The exact type of the object will depend on the configuration mechanism used.
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@
package org.springframework.beans.factory.support;
import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.Set;
@@ -52,6 +53,20 @@ public class ManagedSet<E> extends LinkedHashSet<E> implements Mergeable, BeanMe
}
/**
* 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 Set} containing the specified elements
* @since 5.3.16
*/
@SuppressWarnings("unchecked")
public static <E> ManagedSet<E> of(E... elements) {
ManagedSet<E> set = new ManagedSet<>();
set.addAll(Arrays.asList(elements));
return set;
}
/**
* Set the configuration source {@code Object} for this metadata element.
* <p>The exact type of the object will depend on the configuration mechanism used.
@@ -43,13 +43,13 @@ public abstract class AbstractPropertyValuesTests {
m.put("forname", "Tony");
m.put("surname", "Blair");
m.put("age", "50");
for (int i = 0; i < ps.length; i++) {
Object val = m.get(ps[i].getName());
for (PropertyValue element : ps) {
Object val = m.get(element.getName());
assertThat(val != null).as("Can't have unexpected value").isTrue();
boolean condition = val instanceof String;
assertThat(condition).as("Val i string").isTrue();
assertThat(val.equals(ps[i].getValue())).as("val matches expected").isTrue();
m.remove(ps[i].getName());
assertThat(val.equals(element.getValue())).as("val matches expected").isTrue();
m.remove(element.getName());
}
assertThat(m.size() == 0).as("Map size is 0").isTrue();
}
@@ -483,6 +483,7 @@ public class BeanFactoryUtilsTests {
return TestBean.class;
}
@Override
public TestBean getObject() {
// We don't really care if the actual instance is a singleton or prototype
// for the tests that use this factory.
@@ -48,8 +48,6 @@ import org.junit.jupiter.api.Test;
import org.springframework.beans.BeansException;
import org.springframework.beans.MutablePropertyValues;
import org.springframework.beans.NotWritablePropertyException;
import org.springframework.beans.PropertyEditorRegistrar;
import org.springframework.beans.PropertyEditorRegistry;
import org.springframework.beans.PropertyValue;
import org.springframework.beans.TypeConverter;
import org.springframework.beans.TypeMismatchException;
@@ -84,7 +82,6 @@ import org.springframework.beans.testfixture.beans.factory.DummyFactory;
import org.springframework.core.MethodParameter;
import org.springframework.core.ResolvableType;
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
import org.springframework.core.convert.converter.Converter;
import org.springframework.core.convert.support.DefaultConversionService;
import org.springframework.core.convert.support.GenericConversionService;
import org.springframework.core.io.Resource;
@@ -990,16 +987,13 @@ class DefaultListableBeanFactoryTests {
@Test
void customConverter() {
GenericConversionService conversionService = new DefaultConversionService();
conversionService.addConverter(new Converter<String, Float>() {
@Override
public Float convert(String source) {
try {
NumberFormat nf = NumberFormat.getInstance(Locale.GERMAN);
return nf.parse(source).floatValue();
}
catch (ParseException ex) {
throw new IllegalArgumentException(ex);
}
conversionService.addConverter(String.class, Float.class, source -> {
try {
NumberFormat nf = NumberFormat.getInstance(Locale.GERMAN);
return nf.parse(source).floatValue();
}
catch (ParseException ex) {
throw new IllegalArgumentException(ex);
}
});
lbf.setConversionService(conversionService);
@@ -1014,12 +1008,9 @@ class DefaultListableBeanFactoryTests {
@Test
void customEditorWithBeanReference() {
lbf.addPropertyEditorRegistrar(new PropertyEditorRegistrar() {
@Override
public void registerCustomEditors(PropertyEditorRegistry registry) {
NumberFormat nf = NumberFormat.getInstance(Locale.GERMAN);
registry.registerCustomEditor(Float.class, new CustomNumberEditor(Float.class, nf, true));
}
lbf.addPropertyEditorRegistrar(registry -> {
NumberFormat nf = NumberFormat.getInstance(Locale.GERMAN);
registry.registerCustomEditor(Float.class, new CustomNumberEditor(Float.class, nf, true));
});
MutablePropertyValues pvs = new MutablePropertyValues();
pvs.add("myFloat", new RuntimeBeanReference("myFloat"));
@@ -2307,9 +2298,7 @@ class DefaultListableBeanFactoryTests {
@Test
void prototypeWithArrayConversionForConstructor() {
List<String> list = new ManagedList<>();
list.add("myName");
list.add("myBeanName");
List<String> list = ManagedList.of("myName", "myBeanName");
RootBeanDefinition bd = new RootBeanDefinition(DerivedTestBean.class);
bd.setScope(BeanDefinition.SCOPE_PROTOTYPE);
bd.getConstructorArgumentValues().addGenericArgumentValue(list);
@@ -2325,9 +2314,7 @@ class DefaultListableBeanFactoryTests {
@Test
void prototypeWithArrayConversionForFactoryMethod() {
List<String> list = new ManagedList<>();
list.add("myName");
list.add("myBeanName");
List<String> list = ManagedList.of("myName", "myBeanName");
RootBeanDefinition bd = new RootBeanDefinition(DerivedTestBean.class);
bd.setScope(BeanDefinition.SCOPE_PROTOTYPE);
bd.setFactoryMethodName("create");
@@ -2718,8 +2705,12 @@ class DefaultListableBeanFactoryTests {
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
ConstructorDependency that = (ConstructorDependency) o;
return spouseAge == that.spouseAge &&
Objects.equals(spouse, that.spouse) &&
@@ -22,7 +22,6 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.ArrayList;
import java.util.Arrays;
@@ -3660,11 +3659,8 @@ public class AutowiredAnnotationBeanPostProcessorTests {
@SuppressWarnings("unchecked")
public <T> T createMock(Class<T> toMock) {
return (T) Proxy.newProxyInstance(AutowiredAnnotationBeanPostProcessorTests.class.getClassLoader(), new Class<?>[] {toMock},
new InvocationHandler() {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
throw new UnsupportedOperationException("mocked!");
}
(InvocationHandler) (proxy, method, args) -> {
throw new UnsupportedOperationException("mocked!");
});
}
}
@@ -29,7 +29,6 @@ import org.junit.jupiter.api.Test;
import org.springframework.beans.MutablePropertyValues;
import org.springframework.beans.PropertyEditorRegistrar;
import org.springframework.beans.PropertyEditorRegistry;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.beans.propertyeditors.CustomDateEditor;
@@ -50,12 +49,7 @@ public class CustomEditorConfigurerTests {
CustomEditorConfigurer cec = new CustomEditorConfigurer();
final DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, Locale.GERMAN);
cec.setPropertyEditorRegistrars(new PropertyEditorRegistrar[] {
new PropertyEditorRegistrar() {
@Override
public void registerCustomEditors(PropertyEditorRegistry registry) {
registry.registerCustomEditor(Date.class, new CustomDateEditor(df, true));
}
}});
registry -> registry.registerCustomEditor(Date.class, new CustomDateEditor(df, true))});
cec.postProcessBeanFactory(bf);
MutablePropertyValues pvs = new MutablePropertyValues();
@@ -113,7 +113,7 @@ public class MethodInvokingFactoryBeanTests {
mcfb = new MethodInvokingFactoryBean();
mcfb.setTargetClass(TestClass1.class);
mcfb.setTargetMethod("supertypes");
mcfb.setArguments(new ArrayList<>(), new ArrayList<Object>(), "hello");
mcfb.setArguments(new ArrayList<>(), new ArrayList<>(), "hello");
mcfb.afterPropertiesSet();
mcfb.getObjectType();
@@ -184,7 +184,7 @@ public class MethodInvokingFactoryBeanTests {
mcfb = new MethodInvokingFactoryBean();
mcfb.setTargetClass(TestClass1.class);
mcfb.setTargetMethod("supertypes");
mcfb.setArguments(new ArrayList<>(), new ArrayList<Object>(), "hello");
mcfb.setArguments(new ArrayList<>(), new ArrayList<>(), "hello");
// should pass
mcfb.afterPropertiesSet();
}
@@ -194,7 +194,7 @@ public class MethodInvokingFactoryBeanTests {
MethodInvokingFactoryBean mcfb = new MethodInvokingFactoryBean();
mcfb.setTargetClass(TestClass1.class);
mcfb.setTargetMethod("supertypes");
mcfb.setArguments(new ArrayList<>(), new ArrayList<Object>(), "hello", "bogus");
mcfb.setArguments(new ArrayList<>(), new ArrayList<>(), "hello", "bogus");
assertThatExceptionOfType(NoSuchMethodException.class).as(
"Matched method with wrong number of args").isThrownBy(
mcfb::afterPropertiesSet);
@@ -210,14 +210,14 @@ public class MethodInvokingFactoryBeanTests {
mcfb = new MethodInvokingFactoryBean();
mcfb.setTargetClass(TestClass1.class);
mcfb.setTargetMethod("supertypes2");
mcfb.setArguments(new ArrayList<>(), new ArrayList<Object>(), "hello", "bogus");
mcfb.setArguments(new ArrayList<>(), new ArrayList<>(), "hello", "bogus");
mcfb.afterPropertiesSet();
assertThat(mcfb.getObject()).isEqualTo("hello");
mcfb = new MethodInvokingFactoryBean();
mcfb.setTargetClass(TestClass1.class);
mcfb.setTargetMethod("supertypes2");
mcfb.setArguments(new ArrayList<>(), new ArrayList<Object>(), new Object());
mcfb.setArguments(new ArrayList<>(), new ArrayList<>(), new Object());
assertThatExceptionOfType(NoSuchMethodException.class).as(
"Matched method when shouldn't have matched").isThrownBy(
mcfb::afterPropertiesSet);
@@ -16,6 +16,7 @@
package org.springframework.beans.factory.config;
import java.util.AbstractMap.SimpleEntry;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -357,22 +358,18 @@ public class PropertyResourceConfigurerTests {
MutablePropertyValues pvs = new MutablePropertyValues();
pvs.add("stringArray", new String[] {"${os.name}", "${age}"});
List<Object> friends = new ManagedList<>();
friends.add("na${age}me");
friends.add(new RuntimeBeanReference("${ref}"));
List<Object> friends = ManagedList.of("na${age}me", new RuntimeBeanReference("${ref}"));
pvs.add("friends", friends);
Set<Object> someSet = new ManagedSet<>();
someSet.add("na${age}me");
someSet.add(new RuntimeBeanReference("${ref}"));
someSet.add(new TypedStringValue("${age}", Integer.class));
Set<Object> someSet = ManagedSet.of("na${age}me",
new RuntimeBeanReference("${ref}"), new TypedStringValue("${age}", Integer.class));
pvs.add("someSet", someSet);
Map<Object, Object> someMap = new ManagedMap<>();
someMap.put(new TypedStringValue("key${age}"), new TypedStringValue("${age}"));
someMap.put(new TypedStringValue("key${age}ref"), new RuntimeBeanReference("${ref}"));
someMap.put("key1", new RuntimeBeanReference("${ref}"));
someMap.put("key2", "${age}name");
Map<Object, Object> someMap = ManagedMap.ofEntries(
new SimpleEntry<>(new TypedStringValue("key${age}"), new TypedStringValue("${age}")),
new SimpleEntry<>(new TypedStringValue("key${age}ref"), new RuntimeBeanReference("${ref}")),
new SimpleEntry<>("key1", new RuntimeBeanReference("${ref}")),
new SimpleEntry<>("key2", "${age}name"));
MutablePropertyValues innerPvs = new MutablePropertyValues();
innerPvs.add("country", "${os.name}");
RootBeanDefinition innerBd = new RootBeanDefinition(TestBean.class);
@@ -17,7 +17,6 @@
package org.springframework.beans.factory.support;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.net.MalformedURLException;
import java.net.URI;
@@ -34,8 +33,6 @@ import java.util.stream.Collectors;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.springframework.beans.PropertyEditorRegistrar;
import org.springframework.beans.PropertyEditorRegistry;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.beans.factory.NoUniqueBeanDefinitionException;
import org.springframework.beans.factory.ObjectProvider;
@@ -409,12 +406,7 @@ class BeanFactoryGenericsTests {
@Test
void testGenericMapWithCollectionValueConstructor() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
bf.addPropertyEditorRegistrar(new PropertyEditorRegistrar() {
@Override
public void registerCustomEditors(PropertyEditorRegistry registry) {
registry.registerCustomEditor(Number.class, new CustomNumberEditor(Integer.class, false));
}
});
bf.addPropertyEditorRegistrar(registry -> registry.registerCustomEditor(Number.class, new CustomNumberEditor(Integer.class, false)));
RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class);
Map<String, AbstractCollection<?>> input = new HashMap<>();
@@ -568,12 +560,7 @@ class BeanFactoryGenericsTests {
@Test
void testGenericMapWithCollectionValueFactoryMethod() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
bf.addPropertyEditorRegistrar(new PropertyEditorRegistrar() {
@Override
public void registerCustomEditors(PropertyEditorRegistry registry) {
registry.registerCustomEditor(Number.class, new CustomNumberEditor(Integer.class, false));
}
});
bf.addPropertyEditorRegistrar(registry -> registry.registerCustomEditor(Number.class, new CustomNumberEditor(Integer.class, false)));
RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class);
rbd.setFactoryMethodName("createInstance");
@@ -1010,11 +997,8 @@ class BeanFactoryGenericsTests {
@SuppressWarnings("unchecked")
public <T> T createMock(Class<T> toMock) {
return (T) Proxy.newProxyInstance(BeanFactoryGenericsTests.class.getClassLoader(), new Class<?>[] {toMock},
new InvocationHandler() {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
throw new UnsupportedOperationException("mocked!");
}
(InvocationHandler) (proxy, method, args) -> {
throw new UnsupportedOperationException("mocked!");
});
}
}
@@ -18,8 +18,6 @@ package org.springframework.beans.factory.support;
import org.junit.jupiter.api.Test;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.ObjectFactory;
import org.springframework.beans.testfixture.beans.DerivedTestBean;
import org.springframework.beans.testfixture.beans.TestBean;
@@ -40,12 +38,7 @@ public class DefaultSingletonBeanRegistryTests {
beanRegistry.registerSingleton("tb", tb);
assertThat(beanRegistry.getSingleton("tb")).isSameAs(tb);
TestBean tb2 = (TestBean) beanRegistry.getSingleton("tb2", new ObjectFactory<Object>() {
@Override
public Object getObject() throws BeansException {
return new TestBean();
}
});
TestBean tb2 = (TestBean) beanRegistry.getSingleton("tb2", () -> new TestBean());
assertThat(beanRegistry.getSingleton("tb2")).isSameAs(tb2);
assertThat(beanRegistry.getSingleton("tb")).isSameAs(tb);
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 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,11 +34,8 @@ public class ManagedListTests {
@Test
public void mergeSunnyDay() {
ManagedList parent = new ManagedList();
parent.add("one");
parent.add("two");
ManagedList child = new ManagedList();
child.add("three");
ManagedList parent = ManagedList.of("one", "two");
ManagedList child = ManagedList.of("three");
child.setMergeEnabled(true);
List mergedList = child.merge(parent);
assertThat(mergedList.size()).as("merge() obviously did not work.").isEqualTo(3);
@@ -46,8 +43,7 @@ public class ManagedListTests {
@Test
public void mergeWithNullParent() {
ManagedList child = new ManagedList();
child.add("one");
ManagedList child = ManagedList.of("one");
child.setMergeEnabled(true);
assertThat(child.merge(null)).isSameAs(child);
}
@@ -61,8 +57,7 @@ public class ManagedListTests {
@Test
public void mergeWithNonCompatibleParentType() {
ManagedList child = new ManagedList();
child.add("one");
ManagedList child = ManagedList.of("one");
child.setMergeEnabled(true);
assertThatIllegalArgumentException().isThrownBy(() ->
child.merge("hello"));
@@ -70,9 +65,7 @@ public class ManagedListTests {
@Test
public void mergeEmptyChild() {
ManagedList parent = new ManagedList();
parent.add("one");
parent.add("two");
ManagedList parent = ManagedList.of("one", "two");
ManagedList child = new ManagedList();
child.setMergeEnabled(true);
List mergedList = child.merge(parent);
@@ -82,11 +75,8 @@ public class ManagedListTests {
@Test
public void mergeChildValuesOverrideTheParents() {
// doesn't make much sense in the context of a list...
ManagedList parent = new ManagedList();
parent.add("one");
parent.add("two");
ManagedList child = new ManagedList();
child.add("one");
ManagedList parent = ManagedList.of("one", "two");
ManagedList child = ManagedList.of("one");
child.setMergeEnabled(true);
List mergedList = child.merge(parent);
assertThat(mergedList.size()).as("merge() obviously did not work.").isEqualTo(3);
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@
package org.springframework.beans.factory.support;
import java.util.AbstractMap.SimpleEntry;
import java.util.Map;
import org.junit.jupiter.api.Test;
@@ -34,11 +35,9 @@ public class ManagedMapTests {
@Test
public void mergeSunnyDay() {
ManagedMap parent = new ManagedMap();
parent.put("one", "one");
parent.put("two", "two");
ManagedMap child = new ManagedMap();
child.put("three", "three");
ManagedMap parent = ManagedMap.ofEntries(new SimpleEntry<>("one", "one"),
new SimpleEntry<>("two", "two"));
ManagedMap child = ManagedMap.ofEntries(new SimpleEntry<>("tree", "three"));
child.setMergeEnabled(true);
Map mergedMap = (Map) child.merge(parent);
assertThat(mergedMap.size()).as("merge() obviously did not work.").isEqualTo(3);
@@ -67,9 +66,8 @@ public class ManagedMapTests {
@Test
public void mergeEmptyChild() {
ManagedMap parent = new ManagedMap();
parent.put("one", "one");
parent.put("two", "two");
ManagedMap parent = ManagedMap.ofEntries(new SimpleEntry<>("one", "one"),
new SimpleEntry<>("two", "two"));
ManagedMap child = new ManagedMap();
child.setMergeEnabled(true);
Map mergedMap = (Map) child.merge(parent);
@@ -78,11 +76,9 @@ public class ManagedMapTests {
@Test
public void mergeChildValuesOverrideTheParents() {
ManagedMap parent = new ManagedMap();
parent.put("one", "one");
parent.put("two", "two");
ManagedMap child = new ManagedMap();
child.put("one", "fork");
ManagedMap parent = ManagedMap.ofEntries(new SimpleEntry<>("one", "one"),
new SimpleEntry<>("two", "two"));
ManagedMap child = ManagedMap.ofEntries(new SimpleEntry<>("one", "fork"));
child.setMergeEnabled(true);
Map mergedMap = (Map) child.merge(parent);
// child value for 'one' must override parent value...
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 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,10 +34,8 @@ public class ManagedSetTests {
@Test
public void mergeSunnyDay() {
ManagedSet parent = new ManagedSet();
parent.add("one");
parent.add("two");
ManagedSet child = new ManagedSet();
ManagedSet parent = ManagedSet.of("one", "two");
ManagedSet child = ManagedSet.of("three");
child.add("three");
child.setMergeEnabled(true);
Set mergedSet = child.merge(parent);
@@ -46,8 +44,7 @@ public class ManagedSetTests {
@Test
public void mergeWithNullParent() {
ManagedSet child = new ManagedSet();
child.add("one");
ManagedSet child = ManagedSet.of("one");
child.setMergeEnabled(true);
assertThat(child.merge(null)).isSameAs(child);
}
@@ -60,8 +57,7 @@ public class ManagedSetTests {
@Test
public void mergeWithNonCompatibleParentType() {
ManagedSet child = new ManagedSet();
child.add("one");
ManagedSet child = ManagedSet.of("one");
child.setMergeEnabled(true);
assertThatIllegalArgumentException().isThrownBy(() ->
child.merge("hello"));
@@ -69,9 +65,7 @@ public class ManagedSetTests {
@Test
public void mergeEmptyChild() {
ManagedSet parent = new ManagedSet();
parent.add("one");
parent.add("two");
ManagedSet parent = ManagedSet.of("one", "two");
ManagedSet child = new ManagedSet();
child.setMergeEnabled(true);
Set mergedSet = child.merge(parent);
@@ -81,11 +75,8 @@ public class ManagedSetTests {
@Test
public void mergeChildValuesOverrideTheParents() {
// asserts that the set contract is not violated during a merge() operation...
ManagedSet parent = new ManagedSet();
parent.add("one");
parent.add("two");
ManagedSet child = new ManagedSet();
child.add("one");
ManagedSet parent = ManagedSet.of("one", "two");
ManagedSet child = ManagedSet.of("one");
child.setMergeEnabled(true);
Set mergedSet = child.merge(parent);
assertThat(mergedSet.size()).as("merge() obviously did not work.").isEqualTo(2);
@@ -40,8 +40,9 @@ public class MustBeInitialized implements InitializingBean {
* managed the bean's lifecycle correctly
*/
public void businessMethod() {
if (!this.inited)
if (!this.inited) {
throw new RuntimeException("Factory didn't call afterPropertiesSet() on MustBeInitialized object");
}
}
}
@@ -39,12 +39,18 @@ public class Pet {
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
final Pet pet = (Pet) o;
if (name != null ? !name.equals(pet.name) : pet.name != null) return false;
if (name != null ? !name.equals(pet.name) : pet.name != null) {
return false;
}
return true;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2022 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.
@@ -171,6 +171,7 @@ public class WorkManagerTaskExecutor extends JndiLocatorSupport
}
}
@Deprecated
@Override
public void execute(Runnable task, long startTimeout) {
execute(task);
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2022 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.
@@ -76,6 +76,7 @@ public class SimpleThreadPoolTaskExecutor extends SimpleThreadPool
}
}
@Deprecated
@Override
public void execute(Runnable task, long startTimeout) {
execute(task);
@@ -178,14 +178,11 @@ public class CaffeineCacheManagerTests {
@Test
public void cacheLoaderUseLoadingCache() {
CaffeineCacheManager cm = new CaffeineCacheManager("c1");
cm.setCacheLoader(new CacheLoader<Object, Object>() {
@Override
public Object load(Object key) throws Exception {
if ("ping".equals(key)) {
return "pong";
}
throw new IllegalArgumentException("I only know ping");
cm.setCacheLoader(key -> {
if ("ping".equals(key)) {
return "pong";
}
throw new IllegalArgumentException("I only know ping");
});
Cache cache1 = cm.getCache("c1");
Cache.ValueWrapper value = cache1.get("ping");
@@ -182,12 +182,9 @@ public class JavaMailSenderTests {
final List<Message> messages = new ArrayList<>();
MimeMessagePreparator preparator = new MimeMessagePreparator() {
@Override
public void prepare(MimeMessage mimeMessage) throws MessagingException {
mimeMessage.setRecipient(Message.RecipientType.TO, new InternetAddress("you@mail.org"));
messages.add(mimeMessage);
}
MimeMessagePreparator preparator = mimeMessage -> {
mimeMessage.setRecipient(Message.RecipientType.TO, new InternetAddress("you@mail.org"));
messages.add(mimeMessage);
};
sender.send(preparator);
@@ -208,19 +205,13 @@ public class JavaMailSenderTests {
final List<Message> messages = new ArrayList<>();
MimeMessagePreparator preparator1 = new MimeMessagePreparator() {
@Override
public void prepare(MimeMessage mimeMessage) throws MessagingException {
mimeMessage.setRecipient(Message.RecipientType.TO, new InternetAddress("he@mail.org"));
messages.add(mimeMessage);
}
MimeMessagePreparator preparator1 = mimeMessage -> {
mimeMessage.setRecipient(Message.RecipientType.TO, new InternetAddress("he@mail.org"));
messages.add(mimeMessage);
};
MimeMessagePreparator preparator2 = new MimeMessagePreparator() {
@Override
public void prepare(MimeMessage mimeMessage) throws MessagingException {
mimeMessage.setRecipient(Message.RecipientType.TO, new InternetAddress("she@mail.org"));
messages.add(mimeMessage);
}
MimeMessagePreparator preparator2 = mimeMessage -> {
mimeMessage.setRecipient(Message.RecipientType.TO, new InternetAddress("she@mail.org"));
messages.add(mimeMessage);
};
sender.send(preparator1, preparator2);
@@ -323,12 +314,7 @@ public class JavaMailSenderTests {
@Test
public void javaMailSenderWithParseExceptionOnMimeMessagePreparator() {
MockJavaMailSender sender = new MockJavaMailSender();
MimeMessagePreparator preparator = new MimeMessagePreparator() {
@Override
public void prepare(MimeMessage mimeMessage) throws MessagingException {
mimeMessage.setFrom(new InternetAddress(""));
}
};
MimeMessagePreparator preparator = mimeMessage -> mimeMessage.setFrom(new InternetAddress(""));
try {
sender.send(preparator);
}
@@ -0,0 +1,105 @@
/*
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.cache.interceptor;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.cache.Cache;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
/**
* A {@link CacheErrorHandler} implementation that logs error message. Can be
* used when underlying cache errors should be ignored.
*
* @author Adam Ostrožlík
* @author Stephane Nicoll
* @since 5.3.16
*/
public class LoggingCacheErrorHandler implements CacheErrorHandler {
private final Log logger;
private final boolean logStacktrace;
/**
* Create an instance with the {@link Log logger} to use.
* @param logger the logger to use
* @param logStacktrace whether to log stack trace
*/
public LoggingCacheErrorHandler(Log logger, boolean logStacktrace) {
Assert.notNull(logger, "Logger must not be null");
this.logger = logger;
this.logStacktrace = logStacktrace;
}
/**
* Create an instance that does not log stack traces.
*/
public LoggingCacheErrorHandler() {
this(LogFactory.getLog(LoggingCacheErrorHandler.class), false);
}
@Override
public void handleCacheGetError(RuntimeException exception, Cache cache, Object key) {
logCacheError(logger,
createMessage(cache, "failed to get entry with key '" + key + "'"),
exception);
}
@Override
public void handleCachePutError(RuntimeException exception, Cache cache, Object key, @Nullable Object value) {
logCacheError(logger,
createMessage(cache, "failed to put entry with key '" + key + "'"),
exception);
}
@Override
public void handleCacheEvictError(RuntimeException exception, Cache cache, Object key) {
logCacheError(logger,
createMessage(cache, "failed to evict entry with key '" + key + "'"),
exception);
}
@Override
public void handleCacheClearError(RuntimeException exception, Cache cache) {
logCacheError(logger, createMessage(cache, "failed to clear entries"), exception);
}
/**
* Log the specified message.
* @param logger the logger
* @param message the message
* @param ex the exception
*/
protected void logCacheError(Log logger, String message, RuntimeException ex) {
if (this.logStacktrace) {
logger.warn(message, ex);
}
else {
logger.warn(message);
}
}
private String createMessage(Cache cache, String reason) {
return String.format("Cache '%s' %s", cache.getName(), reason);
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2022 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.
@@ -24,10 +24,12 @@ import org.springframework.beans.factory.BeanInitializationException;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.config.PlaceholderConfigurerSupport;
import org.springframework.context.EnvironmentAware;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.ConfigurablePropertyResolver;
import org.springframework.core.env.Environment;
import org.springframework.core.env.MutablePropertySources;
import org.springframework.core.env.PropertiesPropertySource;
import org.springframework.core.env.PropertyResolver;
import org.springframework.core.env.PropertySource;
import org.springframework.core.env.PropertySources;
import org.springframework.core.env.PropertySourcesPropertyResolver;
@@ -57,6 +59,7 @@ import org.springframework.util.StringValueResolver;
*
* @author Chris Beams
* @author Juergen Hoeller
* @author Sam Brannen
* @since 3.1
* @see org.springframework.core.env.ConfigurableEnvironment
* @see org.springframework.beans.factory.config.PlaceholderConfigurerSupport
@@ -129,12 +132,25 @@ public class PropertySourcesPlaceholderConfigurer extends PlaceholderConfigurerS
if (this.propertySources == null) {
this.propertySources = new MutablePropertySources();
if (this.environment != null) {
PropertyResolver propertyResolver = this.environment;
// If the ignoreUnresolvablePlaceholders flag is set to true, we have to create a
// local PropertyResolver to enforce that setting, since the Environment is most
// likely not configured with ignoreUnresolvablePlaceholders set to true.
// See https://github.com/spring-projects/spring-framework/issues/27947
if (this.ignoreUnresolvablePlaceholders && (this.environment instanceof ConfigurableEnvironment)) {
ConfigurableEnvironment configurableEnvironment = (ConfigurableEnvironment) this.environment;
PropertySourcesPropertyResolver resolver =
new PropertySourcesPropertyResolver(configurableEnvironment.getPropertySources());
resolver.setIgnoreUnresolvableNestedPlaceholders(true);
propertyResolver = resolver;
}
PropertyResolver propertyResolverToUse = propertyResolver;
this.propertySources.addLast(
new PropertySource<Environment>(ENVIRONMENT_PROPERTIES_PROPERTY_SOURCE_NAME, this.environment) {
@Override
@Nullable
public String getProperty(String key) {
return this.source.getProperty(key);
return propertyResolverToUse.getProperty(key);
}
}
);
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2022 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.
@@ -147,6 +147,7 @@ public class ConcurrentTaskExecutor implements AsyncListenableTaskExecutor, Sche
this.adaptedExecutor.execute(task);
}
@Deprecated
@Override
public void execute(Runnable task, long startTimeout) {
this.adaptedExecutor.execute(task, startTimeout);
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2022 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.
@@ -340,6 +340,7 @@ public class ThreadPoolTaskExecutor extends ExecutorConfigurationSupport
}
}
@Deprecated
@Override
public void execute(Runnable task, long startTimeout) {
execute(task);
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2022 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.
@@ -282,6 +282,7 @@ public class ThreadPoolTaskScheduler extends ExecutorConfigurationSupport
}
}
@Deprecated
@Override
public void execute(Runnable task, long startTimeout) {
execute(task);
@@ -269,7 +269,14 @@ abstract class CronField {
int current = get(temporal);
ValueRange range = temporal.range(this.field);
long amount = range.getMaximum() - current + 1;
return this.field.getBaseUnit().addTo(temporal, amount);
T result = this.field.getBaseUnit().addTo(temporal, amount);
current = get(result);
range = result.range(this.field);
// adjust for daylight savings
if (current != range.getMinimum()) {
result = this.field.adjustInto(result, range.getMinimum());
}
return result;
}
/**
@@ -251,43 +251,46 @@ final class QuartzCronField extends CronField {
private static TemporalAdjuster weekdayNearestTo(int dayOfMonth) {
return temporal -> {
int current = Type.DAY_OF_MONTH.get(temporal);
int dayOfWeek = temporal.get(ChronoField.DAY_OF_WEEK);
DayOfWeek dayOfWeek = DayOfWeek.from(temporal);
if ((current == dayOfMonth && dayOfWeek < 6) || // dayOfMonth is a weekday
(dayOfWeek == 5 && current == dayOfMonth - 1) || // dayOfMonth is a Saturday, so Friday before
(dayOfWeek == 1 && current == dayOfMonth + 1) || // dayOfMonth is a Sunday, so Monday after
(dayOfWeek == 1 && dayOfMonth == 1 && current == 3)) { // dayOfMonth is the 1st, so Monday 3rd
if ((current == dayOfMonth && isWeekday(dayOfWeek)) || // dayOfMonth is a weekday
(dayOfWeek == DayOfWeek.FRIDAY && current == dayOfMonth - 1) || // dayOfMonth is a Saturday, so Friday before
(dayOfWeek == DayOfWeek.MONDAY && current == dayOfMonth + 1) || // dayOfMonth is a Sunday, so Monday after
(dayOfWeek == DayOfWeek.MONDAY && dayOfMonth == 1 && current == 3)) { // dayOfMonth is Saturday 1st, so Monday 3rd
return temporal;
}
int count = 0;
while (count++ < CronExpression.MAX_ATTEMPTS) {
temporal = Type.DAY_OF_MONTH.elapseUntil(cast(temporal), dayOfMonth);
temporal = atMidnight().adjustInto(temporal);
current = Type.DAY_OF_MONTH.get(temporal);
if (current == dayOfMonth) {
dayOfWeek = temporal.get(ChronoField.DAY_OF_WEEK);
dayOfWeek = DayOfWeek.from(temporal);
if (dayOfWeek == 6) { // Saturday
if (dayOfWeek == DayOfWeek.SATURDAY) {
if (dayOfMonth != 1) {
return temporal.minus(1, ChronoUnit.DAYS);
temporal = temporal.minus(1, ChronoUnit.DAYS);
}
else {
// exception for "1W" fields: execute on nearest Monday
return temporal.plus(2, ChronoUnit.DAYS);
// exception for "1W" fields: execute on next Monday
temporal = temporal.plus(2, ChronoUnit.DAYS);
}
}
else if (dayOfWeek == 7) { // Sunday
return temporal.plus(1, ChronoUnit.DAYS);
}
else {
return temporal;
else if (dayOfWeek == DayOfWeek.SUNDAY) {
temporal = temporal.plus(1, ChronoUnit.DAYS);
}
return atMidnight().adjustInto(temporal);
}
else {
temporal = Type.DAY_OF_MONTH.elapseUntil(cast(temporal), dayOfMonth);
current = Type.DAY_OF_MONTH.get(temporal);
}
}
return null;
};
}
private static boolean isWeekday(DayOfWeek dayOfWeek) {
return dayOfWeek != DayOfWeek.SATURDAY && dayOfWeek != DayOfWeek.SUNDAY;
}
/**
* Return a temporal adjuster that finds the last of the given doy-of-week
* in a month.
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2022 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 @@ import org.springframework.core.annotation.AliasFor;
* @see org.springframework.web.bind.annotation.RequestMapping
* @see org.springframework.context.annotation.ClassPathBeanDefinitionScanner
*/
@Target({ElementType.TYPE})
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Component
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2022 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.
@@ -55,7 +55,7 @@ import org.springframework.core.annotation.AliasFor;
* @see org.springframework.dao.DataAccessException
* @see org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor
*/
@Target({ElementType.TYPE})
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Component
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -41,7 +41,7 @@ import org.springframework.core.annotation.AliasFor;
* @see Component
* @see Repository
*/
@Target({ElementType.TYPE})
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Component
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2022 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,6 +19,7 @@ package org.springframework.aop.aspectj.autoproxy;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.reflect.Method;
import java.util.function.Supplier;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
@@ -27,6 +28,8 @@ import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import org.springframework.aop.MethodBeforeAdvice;
import org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator;
@@ -42,6 +45,11 @@ import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.beans.testfixture.beans.ITestBean;
import org.springframework.beans.testfixture.beans.TestBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.context.support.GenericApplicationContext;
import org.springframework.core.NestedRuntimeException;
@@ -292,6 +300,16 @@ public class AspectJAutoProxyCreatorTests {
assertThat(tb.getAge()).isEqualTo(68);
}
@ParameterizedTest(name = "[{index}] {0}")
@ValueSource(classes = {ProxyTargetClassFalseConfig.class, ProxyTargetClassTrueConfig.class})
void lambdaIsAlwaysProxiedWithJdkProxy(Class<?> configClass) {
try (ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(configClass)) {
Supplier<?> supplier = context.getBean(Supplier.class);
assertThat(AopUtils.isAopProxy(supplier)).as("AOP proxy").isTrue();
assertThat(AopUtils.isJdkDynamicProxy(supplier)).as("JDK Dynamic proxy").isTrue();
assertThat(supplier.get()).asString().isEqualTo("advised: lambda");
}
}
/**
* Returns a new {@link ClassPathXmlApplicationContext} for the file ending in <var>fileSuffix</var>.
@@ -557,12 +575,7 @@ class TestBeanAdvisor extends StaticMethodMatcherPointcutAdvisor {
public int count;
public TestBeanAdvisor() {
setAdvice(new MethodBeforeAdvice() {
@Override
public void before(Method method, Object[] args, @Nullable Object target) throws Throwable {
++count;
}
});
setAdvice((MethodBeforeAdvice) (method, args, target) -> ++count);
}
@Override
@@ -571,3 +584,35 @@ class TestBeanAdvisor extends StaticMethodMatcherPointcutAdvisor {
}
}
abstract class AbstractProxyTargetClassConfig {
@Bean
Supplier<String> stringSupplier() {
return () -> "lambda";
}
@Bean
SupplierAdvice supplierAdvice() {
return new SupplierAdvice();
}
@Aspect
static class SupplierAdvice {
@Around("execution(public * org.springframework.aop.aspectj.autoproxy..*.*(..))")
Object aroundSupplier(ProceedingJoinPoint joinPoint) throws Throwable {
return "advised: " + joinPoint.proceed();
}
}
}
@Configuration(proxyBeanMethods = false)
@EnableAspectJAutoProxy(proxyTargetClass = false)
class ProxyTargetClassFalseConfig extends AbstractProxyTargetClassConfig {
}
@Configuration(proxyBeanMethods = false)
@EnableAspectJAutoProxy(proxyTargetClass = true)
class ProxyTargetClassTrueConfig extends AbstractProxyTargetClassConfig {
}
@@ -372,17 +372,14 @@ public abstract class AbstractAopProxyTests {
private void testContext(final boolean context) throws Throwable {
final String s = "foo";
// Test return value
MethodInterceptor mi = new MethodInterceptor() {
@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
if (!context) {
assertNoInvocationContext();
}
else {
assertThat(ExposeInvocationInterceptor.currentInvocation()).as("have context").isNotNull();
}
return s;
MethodInterceptor mi = invocation -> {
if (!context) {
assertNoInvocationContext();
}
else {
assertThat(ExposeInvocationInterceptor.currentInvocation()).as("have context").isNotNull();
}
return s;
};
AdvisedSupport pc = new AdvisedSupport(ITestBean.class);
if (context) {
@@ -422,11 +419,8 @@ public abstract class AbstractAopProxyTests {
public void testDeclaredException() throws Throwable {
final Exception expectedException = new Exception();
// Test return value
MethodInterceptor mi = new MethodInterceptor() {
@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
throw expectedException;
}
MethodInterceptor mi = invocation -> {
throw expectedException;
};
AdvisedSupport pc = new AdvisedSupport(ITestBean.class);
pc.addAdvice(ExposeInvocationInterceptor.INSTANCE);
@@ -453,11 +447,8 @@ public abstract class AbstractAopProxyTests {
public void testUndeclaredCheckedException() throws Throwable {
final Exception unexpectedException = new Exception();
// Test return value
MethodInterceptor mi = new MethodInterceptor() {
@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
throw unexpectedException;
}
MethodInterceptor mi = invocation -> {
throw unexpectedException;
};
AdvisedSupport pc = new AdvisedSupport(ITestBean.class);
pc.addAdvice(ExposeInvocationInterceptor.INSTANCE);
@@ -477,11 +468,8 @@ public abstract class AbstractAopProxyTests {
public void testUndeclaredUncheckedException() throws Throwable {
final RuntimeException unexpectedException = new RuntimeException();
// Test return value
MethodInterceptor mi = new MethodInterceptor() {
@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
throw unexpectedException;
}
MethodInterceptor mi = invocation -> {
throw unexpectedException;
};
AdvisedSupport pc = new AdvisedSupport(ITestBean.class);
pc.addAdvice(ExposeInvocationInterceptor.INSTANCE);
@@ -660,12 +648,7 @@ public abstract class AbstractAopProxyTests {
NopInterceptor di = new NopInterceptor();
pc.addAdvice(di);
final long ts = 37;
pc.addAdvice(new DelegatingIntroductionInterceptor(new TimeStamped() {
@Override
public long getTimeStamp() {
return ts;
}
}));
pc.addAdvice(new DelegatingIntroductionInterceptor((TimeStamped) () -> ts));
ITestBean proxied = (ITestBean) createProxy(pc);
assertThat(proxied.getName()).isEqualTo(name);
@@ -1039,17 +1022,14 @@ public abstract class AbstractAopProxyTests {
ProxyFactory pc = new ProxyFactory(tb);
pc.addInterface(ITestBean.class);
MethodInterceptor twoBirthdayInterceptor = new MethodInterceptor() {
@Override
public Object invoke(MethodInvocation mi) throws Throwable {
// Clone the invocation to proceed three times
// "The Moor's Last Sigh": this technology can cause premature aging
MethodInvocation clone1 = ((ReflectiveMethodInvocation) mi).invocableClone();
MethodInvocation clone2 = ((ReflectiveMethodInvocation) mi).invocableClone();
clone1.proceed();
clone2.proceed();
return mi.proceed();
}
MethodInterceptor twoBirthdayInterceptor = mi -> {
// Clone the invocation to proceed three times
// "The Moor's Last Sigh": this technology can cause premature aging
MethodInvocation clone1 = ((ReflectiveMethodInvocation) mi).invocableClone();
MethodInvocation clone2 = ((ReflectiveMethodInvocation) mi).invocableClone();
clone1.proceed();
clone2.proceed();
return mi.proceed();
};
@SuppressWarnings("serial")
StaticMethodMatcherPointcutAdvisor advisor = new StaticMethodMatcherPointcutAdvisor(twoBirthdayInterceptor) {
@@ -1082,16 +1062,13 @@ public abstract class AbstractAopProxyTests {
/**
* Changes the name, then changes it back.
*/
MethodInterceptor nameReverter = new MethodInterceptor() {
@Override
public Object invoke(MethodInvocation mi) throws Throwable {
MethodInvocation clone = ((ReflectiveMethodInvocation) mi).invocableClone();
String oldName = ((ITestBean) mi.getThis()).getName();
clone.getArguments()[0] = oldName;
// Original method invocation should be unaffected by changes to argument list of clone
mi.proceed();
return clone.proceed();
}
MethodInterceptor nameReverter = mi -> {
MethodInvocation clone = ((ReflectiveMethodInvocation) mi).invocableClone();
String oldName = ((ITestBean) mi.getThis()).getName();
clone.getArguments()[0] = oldName;
// Original method invocation should be unaffected by changes to argument list of clone
mi.proceed();
return clone.proceed();
};
class NameSaver implements MethodInterceptor {
@@ -1347,8 +1324,9 @@ public abstract class AbstractAopProxyTests {
@Override
public void before(Method m, Object[] args, Object target) throws Throwable {
super.before(m, args, target);
if (m.getName().startsWith("set"))
if (m.getName().startsWith("set")) {
throw rex;
}
}
};
@@ -1563,13 +1541,10 @@ public abstract class AbstractAopProxyTests {
@SuppressWarnings("serial")
protected static class StringSetterNullReplacementAdvice extends DefaultPointcutAdvisor {
private static MethodInterceptor cleaner = new MethodInterceptor() {
@Override
public Object invoke(MethodInvocation mi) throws Throwable {
// We know it can only be invoked if there's a single parameter of type string
mi.getArguments()[0] = "";
return mi.proceed();
}
private static MethodInterceptor cleaner = mi -> {
// We know it can only be invoked if there's a single parameter of type string
mi.getArguments()[0] = "";
return mi.proceed();
};
public StringSetterNullReplacementAdvice() {
@@ -1601,7 +1576,9 @@ public abstract class AbstractAopProxyTests {
@Override
public boolean matches(Method m, @Nullable Class<?> targetClass, Object... args) {
boolean run = m.getName().contains(pattern);
if (run) ++count;
if (run) {
++count;
}
return run;
}
});
@@ -1620,7 +1597,9 @@ public abstract class AbstractAopProxyTests {
@Override
public boolean matches(Method m, @Nullable Class<?> targetClass, Object... args) {
boolean run = m.getName().contains(pattern);
if (run) ++count;
if (run) {
++count;
}
return run;
}
@Override
@@ -1924,8 +1903,9 @@ public abstract class AbstractAopProxyTests {
*/
@Override
public void releaseTarget(Object pTarget) throws Exception {
if (pTarget != this.target)
if (pTarget != this.target) {
throw new RuntimeException("Released wrong target");
}
++releases;
}
@@ -1934,8 +1914,9 @@ public abstract class AbstractAopProxyTests {
*
*/
public void verify() {
if (gets != releases)
if (gets != releases) {
throw new RuntimeException("Expectation failed: " + gets + " gets and " + releases + " releases");
}
}
/**
@@ -198,10 +198,16 @@ public class JdkDynamicProxyTests extends AbstractAopProxyTests implements Seria
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Person person = (Person) o;
if (!name.equals(person.name)) return false;
if (!name.equals(person.name)) {
return false;
}
return true;
}
@@ -304,11 +304,8 @@ public class ProxyFactoryBeanTests {
final Exception ex = new UnsupportedOperationException("invoke");
// Add evil interceptor to head of list
config.addAdvice(0, new MethodInterceptor() {
@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
throw ex;
}
config.addAdvice(0, (MethodInterceptor) invocation -> {
throw ex;
});
assertThat(config.getAdvisors().length).as("Have correct advisor count").isEqualTo(2);
@@ -691,12 +688,9 @@ public class ProxyFactoryBeanTests {
}
public PointcutForVoid() {
setAdvice(new MethodInterceptor() {
@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
methodNames.add(invocation.getMethod().getName());
return invocation.proceed();
}
setAdvice((MethodInterceptor) invocation -> {
methodNames.add(invocation.getMethod().getName());
return invocation.proceed();
});
setPointcut(new DynamicMethodMatcherPointcut() {
@Override
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2022 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.
@@ -17,8 +17,6 @@
package org.springframework.aop.framework.autoproxy;
import java.io.Serializable;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import org.aopalliance.intercept.MethodInterceptor;
@@ -434,6 +432,7 @@ public class AutoProxyCreatorTests {
@SuppressWarnings("serial")
public static class IntroductionTestAutoProxyCreator extends TestAutoProxyCreator {
@Override
protected Object[] getAdvicesAndAdvisors() {
DefaultIntroductionAdvisor advisor = new DefaultIntroductionAdvisor(this.testInterceptor);
advisor.addInterface(Serializable.class);
@@ -491,12 +490,8 @@ public class AutoProxyCreatorTests {
@Override
public ITestBean getObject() {
return (ITestBean) Proxy.newProxyInstance(CustomProxyFactoryBean.class.getClassLoader(), new Class<?>[]{ITestBean.class}, new InvocationHandler() {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
return ReflectionUtils.invokeMethod(method, tb, args);
}
});
return (ITestBean) Proxy.newProxyInstance(CustomProxyFactoryBean.class.getClassLoader(), new Class<?>[]{ITestBean.class},
(proxy, method, args) -> ReflectionUtils.invokeMethod(method, tb, args));
}
@Override
@@ -158,8 +158,8 @@ class CommonsPool2TargetSourceTests {
pooledInstances[9] = targetSource.getTarget();
// release all objects
for (int i = 0; i < pooledInstances.length; i++) {
targetSource.releaseTarget(pooledInstances[i]);
for (Object element : pooledInstances) {
targetSource.releaseTarget(element);
}
}
@@ -0,0 +1,76 @@
/*
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.cache.interceptor;
import org.apache.commons.logging.Log;
import org.junit.jupiter.api.Test;
import org.springframework.cache.support.NoOpCache;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
/**
* Tests for {@link LoggingCacheErrorHandler}.
*
* @author Adam Ostrožlík
* @author Stephane Nicoll
*/
public class LoggingCacheErrorHandlerTests {
@Test
void handleGetCacheErrorLogsAppropriateMessage() {
Log logger = mock(Log.class);
LoggingCacheErrorHandler handler = new LoggingCacheErrorHandler(logger, false);
handler.handleCacheGetError(new RuntimeException(), new NoOpCache("NOOP"), "key");
verify(logger).warn("Cache 'NOOP' failed to get entry with key 'key'");
}
@Test
void handlePutCacheErrorLogsAppropriateMessage() {
Log logger = mock(Log.class);
LoggingCacheErrorHandler handler = new LoggingCacheErrorHandler(logger, false);
handler.handleCachePutError(new RuntimeException(), new NoOpCache("NOOP"), "key", new Object());
verify(logger).warn("Cache 'NOOP' failed to put entry with key 'key'");
}
@Test
void handleEvictCacheErrorLogsAppropriateMessage() {
Log logger = mock(Log.class);
LoggingCacheErrorHandler handler = new LoggingCacheErrorHandler(logger, false);
handler.handleCacheEvictError(new RuntimeException(), new NoOpCache("NOOP"), "key");
verify(logger).warn("Cache 'NOOP' failed to evict entry with key 'key'");
}
@Test
void handleClearErrorLogsAppropriateMessage() {
Log logger = mock(Log.class);
LoggingCacheErrorHandler handler = new LoggingCacheErrorHandler(logger, false);
handler.handleCacheClearError(new RuntimeException(), new NoOpCache("NOOP"));
verify(logger).warn("Cache 'NOOP' failed to clear entries");
}
@Test
void handleCacheErrorWithStacktrace() {
Log logger = mock(Log.class);
LoggingCacheErrorHandler handler = new LoggingCacheErrorHandler(logger, true);
RuntimeException exception = new RuntimeException();
handler.handleCacheGetError(exception, new NoOpCache("NOOP"), "key");
verify(logger).warn("Cache 'NOOP' failed to get entry with key 'key'", exception);
}
}
@@ -33,21 +33,24 @@ public class LifecycleContextBean extends LifecycleBean implements ApplicationCo
@Override
public void setBeanFactory(BeanFactory beanFactory) {
super.setBeanFactory(beanFactory);
if (this.owningContext != null)
if (this.owningContext != null) {
throw new RuntimeException("Factory called setBeanFactory after setApplicationContext");
}
}
@Override
public void afterPropertiesSet() {
super.afterPropertiesSet();
if (this.owningContext == null)
if (this.owningContext == null) {
throw new RuntimeException("Factory didn't call setApplicationContext before afterPropertiesSet on lifecycle bean");
}
}
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
if (this.owningFactory == null)
if (this.owningFactory == null) {
throw new RuntimeException("Factory called setApplicationContext before setBeanFactory");
}
this.owningContext = applicationContext;
}
@@ -544,19 +544,24 @@ class TestBean {
@Override
public boolean equals(Object obj) {
if (this == obj)
if (this == obj) {
return true;
if (obj == null)
}
if (obj == null) {
return false;
if (getClass() != obj.getClass())
}
if (getClass() != obj.getClass()) {
return false;
}
TestBean other = (TestBean) obj;
if (name == null) {
if (other.name != null)
if (other.name != null) {
return false;
}
}
else if (!name.equals(other.name))
else if (!name.equals(other.name)) {
return false;
}
return true;
}
@@ -215,12 +215,7 @@ public class CommonAnnotationBeanPostProcessorTests {
bf.registerBeanDefinition("testBean4", tbd);
bf.registerResolvableDependency(BeanFactory.class, bf);
bf.registerResolvableDependency(INestedTestBean.class, new ObjectFactory<Object>() {
@Override
public Object getObject() throws BeansException {
return new NestedTestBean();
}
});
bf.registerResolvableDependency(INestedTestBean.class, (ObjectFactory<Object>) () -> new NestedTestBean());
@SuppressWarnings("deprecation")
org.springframework.beans.factory.config.PropertyPlaceholderConfigurer ppc = new org.springframework.beans.factory.config.PropertyPlaceholderConfigurer();
@@ -18,10 +18,8 @@ package org.springframework.context.annotation;
import org.junit.jupiter.api.Test;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.testfixture.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;
@@ -72,11 +70,8 @@ public class ConfigurationClassAndBFPPTests {
@Bean
public BeanFactoryPostProcessor bfpp() {
return new BeanFactoryPostProcessor() {
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
// no-op
}
return beanFactory -> {
// no-op
};
}
}
@@ -88,11 +83,8 @@ public class ConfigurationClassAndBFPPTests {
@Bean
public static final BeanFactoryPostProcessor bfpp() {
return new BeanFactoryPostProcessor() {
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
// no-op
}
return beanFactory -> {
// no-op
};
}
}
@@ -291,7 +291,9 @@ public class ConfigurationClassWithConditionTests {
static class ImportsNotCreated {
static {
if (true) throw new RuntimeException();
if (true) {
throw new RuntimeException();
}
}
}
@@ -299,14 +301,18 @@ public class ConfigurationClassWithConditionTests {
static class ConfigurationNotCreated {
static {
if (true) throw new RuntimeException();
if (true) {
throw new RuntimeException();
}
}
}
static class RegistrarNotCreated implements ImportBeanDefinitionRegistrar {
static {
if (true) throw new RuntimeException();
if (true) {
throw new RuntimeException();
}
}
@Override
@@ -318,7 +324,9 @@ public class ConfigurationClassWithConditionTests {
static class ImportSelectorNotCreated implements ImportSelector {
static {
if (true) throw new RuntimeException();
if (true) {
throw new RuntimeException();
}
}
@Override
@@ -136,10 +136,7 @@ public class ConfigurationClassAspectIntegrationTests {
@Bean
Runnable fromInnerClass() {
return new Runnable() {
@Override
public void run() {
}
return () -> {
};
}
@@ -39,7 +39,6 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.config.DependencyDescriptor;
import org.springframework.beans.factory.config.ListFactoryBean;
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException;
@@ -559,12 +558,9 @@ public class ConfigurationClassProcessingTests {
// @Bean
public BeanFactoryPostProcessor beanFactoryPostProcessor() {
return new BeanFactoryPostProcessor() {
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) {
BeanDefinition bd = beanFactory.getBeanDefinition("beanPostProcessor");
bd.getPropertyValues().addPropertyValue("nameSuffix", "-processed-" + myProp);
}
return beanFactory -> {
BeanDefinition bd = beanFactory.getBeanDefinition("beanPostProcessor");
bd.getPropertyValues().addPropertyValue("nameSuffix", "-processed-" + myProp);
};
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,7 +20,6 @@ import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.Executor;
import org.aopalliance.intercept.MethodInvocation;
import org.junit.jupiter.api.Test;
@@ -141,12 +140,9 @@ public class ApplicationContextEventTests extends AbstractApplicationEventListen
ApplicationEvent evt = new ContextClosedEvent(new StaticApplicationContext());
SimpleApplicationEventMulticaster smc = new SimpleApplicationEventMulticaster();
smc.setTaskExecutor(new Executor() {
@Override
public void execute(Runnable command) {
command.run();
command.run();
}
smc.setTaskExecutor(command -> {
command.run();
command.run();
});
smc.addApplicationListener(listener);
@@ -429,12 +425,7 @@ public class ApplicationContextEventTests extends AbstractApplicationEventListen
public void anonymousClassAsListener() {
final Set<MyEvent> seenEvents = new HashSet<>();
StaticApplicationContext context = new StaticApplicationContext();
context.addApplicationListener(new ApplicationListener<MyEvent>() {
@Override
public void onApplicationEvent(MyEvent event) {
seenEvents.add(event);
}
});
context.addApplicationListener((MyEvent event) -> seenEvents.add(event));
context.refresh();
MyEvent event1 = new MyEvent(context);
@@ -65,7 +65,7 @@ public class PayloadApplicationEventTests {
public void testProgrammaticPayloadListener() {
List<String> events = new ArrayList<>();
ApplicationListener<PayloadApplicationEvent<String>> listener = ApplicationListener.forPayload(events::add);
ApplicationListener<PayloadApplicationEvent<Integer>> mismatch = ApplicationListener.forPayload(payload -> payload.intValue());
ApplicationListener<PayloadApplicationEvent<Integer>> mismatch = ApplicationListener.forPayload(Integer::intValue);
ConfigurableApplicationContext ac = new GenericApplicationContext();
ac.addApplicationListener(listener);
@@ -36,8 +36,12 @@ public abstract class AbstractIdentifiable implements Identifiable {
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
AbstractIdentifiable that = (AbstractIdentifiable) o;
@@ -38,8 +38,12 @@ public class GenericEventPojo<T> implements ResolvableTypeProvider {
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
GenericEventPojo<?> that = (GenericEventPojo<?>) o;
@@ -50,8 +50,12 @@ public abstract class IdentifiableApplicationEvent extends ApplicationEvent impl
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
IdentifiableApplicationEvent that = (IdentifiableApplicationEvent) o;
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 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.
@@ -99,8 +99,7 @@ public class ConversionServiceFactoryBeanTests {
Set<Object> converters = new HashSet<>();
converters.add("bogus");
factory.setConverters(converters);
assertThatIllegalArgumentException().isThrownBy(
factory::afterPropertiesSet);
assertThatIllegalArgumentException().isThrownBy(factory::afterPropertiesSet);
}
@Test
@@ -21,9 +21,14 @@ import java.util.Properties;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.beans.factory.BeanDefinitionStoreException;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.testfixture.beans.TestBean;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.convert.support.DefaultConversionService;
import org.springframework.core.env.MutablePropertySources;
import org.springframework.core.env.PropertySource;
@@ -40,8 +45,11 @@ import static org.springframework.beans.factory.support.BeanDefinitionBuilder.ge
import static org.springframework.beans.factory.support.BeanDefinitionBuilder.rootBeanDefinition;
/**
* Tests for {@link PropertySourcesPlaceholderConfigurer}.
*
* @author Chris Beams
* @author Juergen Hoeller
* @author Sam Brannen
* @since 3.1
*/
public class PropertySourcesPlaceholderConfigurerTests {
@@ -159,8 +167,11 @@ public class PropertySourcesPlaceholderConfigurerTests {
PropertySourcesPlaceholderConfigurer ppc = new PropertySourcesPlaceholderConfigurer();
//pc.setIgnoreUnresolvablePlaceholders(false); // the default
assertThatExceptionOfType(BeanDefinitionStoreException.class).isThrownBy(() ->
ppc.postProcessBeanFactory(bf));
assertThatExceptionOfType(BeanDefinitionStoreException.class)
.isThrownBy(() -> ppc.postProcessBeanFactory(bf))
.havingCause()
.isExactlyInstanceOf(IllegalArgumentException.class)
.withMessage("Could not resolve placeholder 'my.name' in value \"${my.name}\"");
}
@Test
@@ -177,6 +188,38 @@ public class PropertySourcesPlaceholderConfigurerTests {
assertThat(bf.getBean(TestBean.class).getName()).isEqualTo("${my.name}");
}
@Test
// https://github.com/spring-projects/spring-framework/issues/27947
public void ignoreUnresolvablePlaceholdersInAtValueAnnotation__falseIsDefault() {
MockPropertySource mockPropertySource = new MockPropertySource("test");
mockPropertySource.setProperty("my.key", "${enigma}");
@SuppressWarnings("resource")
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
context.getEnvironment().getPropertySources().addLast(mockPropertySource);
context.register(IgnoreUnresolvablePlaceholdersFalseConfig.class);
assertThatExceptionOfType(BeanCreationException.class)
.isThrownBy(context::refresh)
.havingCause()
.isExactlyInstanceOf(IllegalArgumentException.class)
.withMessage("Could not resolve placeholder 'enigma' in value \"${enigma}\"");
}
@Test
// https://github.com/spring-projects/spring-framework/issues/27947
public void ignoreUnresolvablePlaceholdersInAtValueAnnotation_true() {
MockPropertySource mockPropertySource = new MockPropertySource("test");
mockPropertySource.setProperty("my.key", "${enigma}");
@SuppressWarnings("resource")
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
context.getEnvironment().getPropertySources().addLast(mockPropertySource);
context.register(IgnoreUnresolvablePlaceholdersTrueConfig.class);
context.refresh();
IgnoreUnresolvablePlaceholdersTrueConfig config = context.getBean(IgnoreUnresolvablePlaceholdersTrueConfig.class);
assertThat(config.value).isEqualTo("${enigma}");
}
@Test
@SuppressWarnings("serial")
public void nestedUnresolvablePlaceholder() {
@@ -402,4 +445,30 @@ public class PropertySourcesPlaceholderConfigurerTests {
}
}
@Configuration
static class IgnoreUnresolvablePlaceholdersFalseConfig {
@Value("${my.key}")
String value;
@Bean
static PropertySourcesPlaceholderConfigurer pspc() {
return new PropertySourcesPlaceholderConfigurer();
}
}
@Configuration
static class IgnoreUnresolvablePlaceholdersTrueConfig {
@Value("${my.key}")
String value;
@Bean
static PropertySourcesPlaceholderConfigurer pspc() {
PropertySourcesPlaceholderConfigurer pspc = new PropertySourcesPlaceholderConfigurer();
pspc.setIgnoreUnresolvablePlaceholders(true);
return pspc;
}
}
}
@@ -30,7 +30,6 @@ import org.springframework.core.convert.support.DefaultConversionService;
import org.springframework.format.annotation.NumberFormat;
import org.springframework.format.annotation.NumberFormat.Style;
import org.springframework.format.support.FormattingConversionService;
import org.springframework.util.StringValueResolver;
import org.springframework.validation.DataBinder;
import static org.assertj.core.api.Assertions.assertThat;
@@ -49,15 +48,12 @@ public class NumberFormattingTests {
@BeforeEach
public void setUp() {
DefaultConversionService.addDefaultConverters(conversionService);
conversionService.setEmbeddedValueResolver(new StringValueResolver() {
@Override
public String resolveStringValue(String strVal) {
if ("${pattern}".equals(strVal)) {
return "#,##.00";
}
else {
return strVal;
}
conversionService.setEmbeddedValueResolver(strVal -> {
if ("${pattern}".equals(strVal)) {
return "#,##.00";
}
else {
return strVal;
}
});
conversionService.addFormatterForFieldType(Number.class, new NumberStyleFormatter());
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 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.
@@ -189,24 +189,14 @@ public class FormattingConversionServiceFactoryBeanTests {
public Printer<?> getPrinter(SpecialInt annotation, Class<?> fieldType) {
assertThat(annotation.value()).isEqualTo("aliased");
assertThat(annotation.alias()).isEqualTo("aliased");
return new Printer<Integer>() {
@Override
public String print(Integer object, Locale locale) {
return ":" + object.toString();
}
};
return (object, locale) -> ":" + object.toString();
}
@Override
public Parser<?> getParser(SpecialInt annotation, Class<?> fieldType) {
assertThat(annotation.value()).isEqualTo("aliased");
assertThat(annotation.alias()).isEqualTo("aliased");
return new Parser<Integer>() {
@Override
public Integer parse(String text, Locale locale) throws ParseException {
return Integer.parseInt(text.substring(1));
}
};
return (text, locale) -> Integer.parseInt(text.substring(1));
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2022 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,6 @@ import org.springframework.jmx.IJmxTestBean;
import org.springframework.jmx.JmxTestBean;
import org.springframework.jmx.export.MBeanExporter;
import org.springframework.jmx.export.assembler.AbstractReflectiveMBeanInfoAssembler;
import org.springframework.util.SocketUtils;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
@@ -177,7 +176,8 @@ class MBeanClientInterceptorTests extends AbstractMBeanServerTests {
void lazyConnectionToRemote() throws Exception {
assumeTrue(runTests);
final int port = SocketUtils.findAvailableTcpPort();
@SuppressWarnings("deprecation")
final int port = org.springframework.util.SocketUtils.findAvailableTcpPort();
JMXServiceURL url = new JMXServiceURL("service:jmx:jmxmp://localhost:" + port);
JMXConnectorServer connector = JMXConnectorServerFactory.newJMXConnectorServer(url, null, getServer());
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 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,8 +28,6 @@ import javax.management.remote.JMXServiceURL;
import org.junit.jupiter.api.AfterEach;
import org.springframework.util.SocketUtils;
/**
* @author Rob Harrop
* @author Chris Beams
@@ -37,7 +35,8 @@ import org.springframework.util.SocketUtils;
*/
class RemoteMBeanClientInterceptorTests extends MBeanClientInterceptorTests {
private final int servicePort = SocketUtils.findAvailableTcpPort();
@SuppressWarnings("deprecation")
private final int servicePort = org.springframework.util.SocketUtils.findAvailableTcpPort();
private final String serviceUrl = "service:jmx:jmxmp://localhost:" + servicePort;
@@ -27,7 +27,6 @@ import org.junit.jupiter.api.Test;
import org.springframework.jmx.AbstractMBeanServerTests;
import org.springframework.jmx.JmxTestBean;
import org.springframework.jmx.export.naming.ObjectNamingStrategy;
import org.springframework.jmx.support.ObjectNameManager;
import static org.assertj.core.api.Assertions.assertThat;
@@ -74,12 +73,7 @@ class MBeanExporterOperationsTests extends AbstractMBeanServerTests {
MBeanExporter exporter = new MBeanExporter();
exporter.setServer(getServer());
exporter.setNamingStrategy(new ObjectNamingStrategy() {
@Override
public ObjectName getObjectName(Object managedBean, String beanKey) {
return objectNameTemplate;
}
});
exporter.setNamingStrategy((managedBean, beanKey) -> objectNameTemplate);
JmxTestBean bean1 = new JmxTestBean();
JmxTestBean bean2 = new JmxTestBean();
@@ -101,12 +95,7 @@ class MBeanExporterOperationsTests extends AbstractMBeanServerTests {
MBeanExporter exporter = new MBeanExporter();
exporter.setServer(getServer());
exporter.setEnsureUniqueRuntimeObjectNames(false);
exporter.setNamingStrategy(new ObjectNamingStrategy() {
@Override
public ObjectName getObjectName(Object managedBean, String beanKey) {
return objectNameTemplate;
}
});
exporter.setNamingStrategy((managedBean, beanKey) -> objectNameTemplate);
JmxTestBean bean1 = new JmxTestBean();
JmxTestBean bean2 = new JmxTestBean();
@@ -90,11 +90,8 @@ public class MBeanExporterTests extends AbstractMBeanServerTests {
@Test
void testRegisterNotificationListenerForNonExistentMBean() throws Exception {
Map<String, NotificationListener> listeners = new HashMap<>();
NotificationListener dummyListener = new NotificationListener() {
@Override
public void handleNotification(Notification notification, Object handback) {
throw new UnsupportedOperationException();
}
NotificationListener dummyListener = (notification, handback) -> {
throw new UnsupportedOperationException();
};
// the MBean with the supplied object name does not exist...
listeners.put("spring:type=Test", dummyListener);
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2022 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,6 @@ import javax.management.Attribute;
import javax.management.AttributeChangeNotification;
import javax.management.MalformedObjectNameException;
import javax.management.Notification;
import javax.management.NotificationFilter;
import javax.management.NotificationListener;
import javax.management.ObjectName;
@@ -117,7 +116,7 @@ public class NotificationListenerTests extends AbstractMBeanServerTests {
MBeanExporter exporter = new MBeanExporter();
exporter.setServer(server);
exporter.setBeans(beans);
exporter.setNotificationListeners(new NotificationListenerBean[] { listenerBean });
exporter.setNotificationListeners(listenerBean);
start(exporter);
// update the attribute
@@ -145,7 +144,7 @@ public class NotificationListenerTests extends AbstractMBeanServerTests {
MBeanExporter exporter = new MBeanExporter();
exporter.setServer(server);
exporter.setBeans(beans);
exporter.setNotificationListeners(new NotificationListenerBean[] { listenerBean });
exporter.setNotificationListeners(listenerBean);
start(exporter);
// update the attribute
@@ -168,23 +167,20 @@ public class NotificationListenerTests extends AbstractMBeanServerTests {
NotificationListenerBean listenerBean = new NotificationListenerBean();
listenerBean.setNotificationListener(listener);
listenerBean.setNotificationFilter(new NotificationFilter() {
@Override
public boolean isNotificationEnabled(Notification notification) {
if (notification instanceof AttributeChangeNotification) {
AttributeChangeNotification changeNotification = (AttributeChangeNotification) notification;
return "Name".equals(changeNotification.getAttributeName());
}
else {
return false;
}
listenerBean.setNotificationFilter(notification -> {
if (notification instanceof AttributeChangeNotification) {
AttributeChangeNotification changeNotification = (AttributeChangeNotification) notification;
return "Name".equals(changeNotification.getAttributeName());
}
else {
return false;
}
});
MBeanExporter exporter = new MBeanExporter();
exporter.setServer(server);
exporter.setBeans(beans);
exporter.setNotificationListeners(new NotificationListenerBean[] { listenerBean });
exporter.setNotificationListeners(listenerBean);
start(exporter);
// update the attributes
@@ -83,9 +83,9 @@ public abstract class AbstractJmxAssemblerTests extends AbstractJmxTests {
MBeanAttributeInfo[] inf = info.getAttributes();
assertThat(inf).as("Invalid number of Attributes returned").hasSize(getExpectedAttributeCount());
for (int x = 0; x < inf.length; x++) {
assertThat(inf[x]).as("MBeanAttributeInfo should not be null").isNotNull();
assertThat(inf[x].getDescription()).as("Description for MBeanAttributeInfo should not be null").isNotNull();
for (MBeanAttributeInfo element : inf) {
assertThat(element).as("MBeanAttributeInfo should not be null").isNotNull();
assertThat(element.getDescription()).as("Description for MBeanAttributeInfo should not be null").isNotNull();
}
}
@@ -95,9 +95,9 @@ public abstract class AbstractJmxAssemblerTests extends AbstractJmxTests {
MBeanOperationInfo[] inf = info.getOperations();
assertThat(inf).as("Invalid number of Operations returned").hasSize(getExpectedOperationCount());
for (int x = 0; x < inf.length; x++) {
assertThat(inf[x]).as("MBeanOperationInfo should not be null").isNotNull();
assertThat(inf[x].getDescription()).as("Description for MBeanOperationInfo should not be null").isNotNull();
for (MBeanOperationInfo element : inf) {
assertThat(element).as("MBeanOperationInfo should not be null").isNotNull();
assertThat(element.getDescription()).as("Description for MBeanOperationInfo should not be null").isNotNull();
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,7 +31,6 @@ import javax.management.remote.JMXServiceURL;
import org.junit.jupiter.api.Test;
import org.springframework.jmx.AbstractMBeanServerTests;
import org.springframework.util.SocketUtils;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
@@ -47,7 +46,8 @@ class ConnectorServerFactoryBeanTests extends AbstractMBeanServerTests {
private static final String OBJECT_NAME = "spring:type=connector,name=test";
private final String serviceUrl = "service:jmx:jmxmp://localhost:" + SocketUtils.findAvailableTcpPort();
@SuppressWarnings("deprecation")
private final String serviceUrl = "service:jmx:jmxmp://localhost:" + org.springframework.util.SocketUtils.findAvailableTcpPort();
@Test
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 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.
@@ -25,7 +25,6 @@ import org.junit.jupiter.api.Test;
import org.springframework.aop.support.AopUtils;
import org.springframework.jmx.AbstractMBeanServerTests;
import org.springframework.util.SocketUtils;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
@@ -39,7 +38,8 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
*/
class MBeanServerConnectionFactoryBeanTests extends AbstractMBeanServerTests {
private final String serviceUrl = "service:jmx:jmxmp://localhost:" + SocketUtils.findAvailableTcpPort();
@SuppressWarnings("deprecation")
private final String serviceUrl = "service:jmx:jmxmp://localhost:" + org.springframework.util.SocketUtils.findAvailableTcpPort();
@Test
@@ -27,7 +27,6 @@ import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.awaitility.Awaitility;
import org.junit.jupiter.api.Test;
@@ -613,16 +612,13 @@ public class AsyncExecutionTests {
public DynamicAsyncInterfaceBean() {
ProxyFactory pf = new ProxyFactory(new HashMap<>());
DefaultIntroductionAdvisor advisor = new DefaultIntroductionAdvisor(new MethodInterceptor() {
@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
boolean condition = !Thread.currentThread().getName().equals(originalThreadName);
assertThat(condition).isTrue();
if (Future.class.equals(invocation.getMethod().getReturnType())) {
return new AsyncResult<>(invocation.getArguments()[0].toString());
}
return null;
DefaultIntroductionAdvisor advisor = new DefaultIntroductionAdvisor((MethodInterceptor) invocation -> {
boolean condition = !Thread.currentThread().getName().equals(originalThreadName);
assertThat(condition).isTrue();
if (Future.class.equals(invocation.getMethod().getReturnType())) {
return new AsyncResult<>(invocation.getArguments()[0].toString());
}
return null;
});
advisor.addInterface(AsyncInterface.class);
pf.addAdvisor(advisor);
@@ -686,16 +682,13 @@ public class AsyncExecutionTests {
public DynamicAsyncMethodsInterfaceBean() {
ProxyFactory pf = new ProxyFactory(new HashMap<>());
DefaultIntroductionAdvisor advisor = new DefaultIntroductionAdvisor(new MethodInterceptor() {
@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
boolean condition = !Thread.currentThread().getName().equals(originalThreadName);
assertThat(condition).isTrue();
if (Future.class.equals(invocation.getMethod().getReturnType())) {
return new AsyncResult<>(invocation.getArguments()[0].toString());
}
return null;
DefaultIntroductionAdvisor advisor = new DefaultIntroductionAdvisor((MethodInterceptor) invocation -> {
boolean condition = !Thread.currentThread().getName().equals(originalThreadName);
assertThat(condition).isTrue();
if (Future.class.equals(invocation.getMethod().getReturnType())) {
return new AsyncResult<>(invocation.getArguments()[0].toString());
}
return null;
});
advisor.addInterface(AsyncMethodsInterface.class);
pf.addAdvisor(advisor);
@@ -16,7 +16,6 @@
package org.springframework.scheduling.config;
import java.util.concurrent.Callable;
import java.util.concurrent.Executor;
import java.util.concurrent.FutureTask;
@@ -59,12 +58,7 @@ public class ExecutorBeanDefinitionParserTests {
assertThat(getKeepAliveSeconds(executor)).isEqualTo(60);
assertThat(getAllowCoreThreadTimeOut(executor)).isFalse();
FutureTask<String> task = new FutureTask<>(new Callable<String>() {
@Override
public String call() throws Exception {
return "foo";
}
});
FutureTask<String> task = new FutureTask<>(() -> "foo");
executor.execute(task);
assertThat(task.get()).isEqualTo("foo");
}
@@ -16,13 +16,13 @@
package org.springframework.scheduling.support;
import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.Year;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.temporal.ChronoField;
import java.time.temporal.Temporal;
import org.assertj.core.api.Condition;
@@ -30,6 +30,7 @@ import org.junit.jupiter.api.Test;
import static java.time.DayOfWeek.FRIDAY;
import static java.time.DayOfWeek.MONDAY;
import static java.time.DayOfWeek.SATURDAY;
import static java.time.DayOfWeek.SUNDAY;
import static java.time.DayOfWeek.THURSDAY;
import static java.time.DayOfWeek.TUESDAY;
@@ -46,8 +47,8 @@ class CronExpressionTests {
@Override
public boolean matches(Temporal value) {
int dayOfWeek = value.get(ChronoField.DAY_OF_WEEK);
return dayOfWeek != 6 && dayOfWeek != 7;
DayOfWeek dayOfWeek = DayOfWeek.from(value);
return dayOfWeek != SATURDAY && dayOfWeek != SUNDAY;
}
};
@@ -958,6 +959,24 @@ class CronExpressionTests {
assertThat(actual).isNotNull();
assertThat(actual).isEqualTo(expected);
assertThat(actual).is(weekday);
last = LocalDateTime.of(2022, 1, 1, 0, 0);
assertThat(last.getDayOfWeek()).isEqualTo(SATURDAY);
expected = LocalDateTime.of(2022, 1, 3, 0, 0);
assertThat(expected.getDayOfWeek()).isEqualTo(MONDAY);
actual = expression.next(last);
assertThat(actual).isNotNull();
assertThat(actual).isEqualTo(expected);
assertThat(actual).is(weekday);
last = LocalDateTime.of(2021, 8, 1, 0,0);
assertThat(last.getDayOfWeek()).isEqualTo(SUNDAY);
expected = LocalDateTime.of(2021, 8, 2, 0, 0);
assertThat(expected.getDayOfWeek()).isEqualTo(MONDAY);
actual = expression.next(last);
assertThat(actual).isNotNull();
assertThat(actual).isEqualTo(expected);
assertThat(actual).is(weekday);
}
@Test
@@ -1317,6 +1336,14 @@ class CronExpressionTests {
actual = cronExpression.next(last);
assertThat(actual).isNotNull();
assertThat(actual).isEqualTo(expected);
cronExpression = CronExpression.parse("0 5 0 * * *");
last = ZonedDateTime.parse("2021-03-28T01:00:00+01:00[Europe/Amsterdam]");
expected = ZonedDateTime.parse("2021-03-29T00:05+02:00[Europe/Amsterdam]");
actual = cronExpression.next(last);
assertThat(actual).isNotNull();
assertThat(actual).isEqualTo(expected);
}
@Test
@@ -26,7 +26,7 @@ import org.codehaus.groovy.control.BytecodeProcessor;
*/
public class MyBytecodeProcessor implements BytecodeProcessor {
public final Set<String> processed = new HashSet<String>();
public final Set<String> processed = new HashSet<>();
@Override
public byte[] processBytecode(String name, byte[] original) {
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 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.
@@ -17,8 +17,6 @@
package org.springframework.ui;
import java.io.Serializable;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.ArrayList;
import java.util.Collection;
@@ -281,12 +279,7 @@ public class ModelMapTests {
Object proxy = Proxy.newProxyInstance(
getClass().getClassLoader(),
new Class<?>[] {Map.class},
new InvocationHandler() {
@Override
public Object invoke(Object proxy, Method method, Object[] args) {
return "proxy";
}
});
(proxy1, method, args) -> "proxy");
map.addAttribute(proxy);
assertThat(map.get("map")).isSameAs(proxy);
}
@@ -61,8 +61,9 @@ public class LockMixin extends DelegatingIntroductionInterceptor implements Lock
*/
@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
if (locked() && invocation.getMethod().getName().indexOf("set") == 0)
if (locked() && invocation.getMethod().getName().indexOf("set") == 0) {
throw new LockedException();
}
return super.invoke(invocation);
}
@@ -19,7 +19,6 @@ package org.springframework.context.testfixture;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -75,8 +74,7 @@ public class SimpleMapScope implements Scope, Serializable {
}
public void close() {
for (Iterator<Runnable> it = this.callbacks.iterator(); it.hasNext();) {
Runnable runnable = it.next();
for (Runnable runnable : this.callbacks) {
runnable.run();
}
}
+1
View File
@@ -76,6 +76,7 @@ jar {
dependsOn cglibRepackJar
from(zipTree(cglibRepackJar.archivePath)) {
include "org/springframework/cglib/**"
exclude "org/springframework/cglib/beans/BeanMap*.class"
exclude "org/springframework/cglib/core/AbstractClassGenerator*.class"
exclude "org/springframework/cglib/core/AsmApi*.class"
exclude "org/springframework/cglib/core/KeyFactory.class"
@@ -0,0 +1,331 @@
/*
* Copyright 2003,2004 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.cglib.beans;
import java.security.ProtectionDomain;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.springframework.asm.ClassVisitor;
import org.springframework.cglib.core.AbstractClassGenerator;
import org.springframework.cglib.core.KeyFactory;
import org.springframework.cglib.core.ReflectUtils;
/**
* A <code>Map</code>-based view of a JavaBean. The default set of keys is the
* union of all property names (getters or setters). An attempt to set
* a read-only property will be ignored, and write-only properties will
* be returned as <code>null</code>. Removal of objects is not a
* supported (the key set is fixed).
* @author Chris Nokleberg
*/
@SuppressWarnings({"rawtypes", "unchecked"})
abstract public class BeanMap implements Map {
/**
* Limit the properties reflected in the key set of the map
* to readable properties.
* @see BeanMap.Generator#setRequire
*/
public static final int REQUIRE_GETTER = 1;
/**
* Limit the properties reflected in the key set of the map
* to writable properties.
* @see BeanMap.Generator#setRequire
*/
public static final int REQUIRE_SETTER = 2;
/**
* Helper method to create a new <code>BeanMap</code>. For finer
* control over the generated instance, use a new instance of
* <code>BeanMap.Generator</code> instead of this static method.
* @param bean the JavaBean underlying the map
* @return a new <code>BeanMap</code> instance
*/
public static BeanMap create(Object bean) {
Generator gen = new Generator();
gen.setBean(bean);
return gen.create();
}
public static class Generator extends AbstractClassGenerator {
private static final Source SOURCE = new Source(BeanMap.class.getName());
private static final BeanMapKey KEY_FACTORY =
(BeanMapKey)KeyFactory.create(BeanMapKey.class, KeyFactory.CLASS_BY_NAME);
interface BeanMapKey {
public Object newInstance(Class type, int require);
}
private Object bean;
private Class beanClass;
private int require;
public Generator() {
super(SOURCE);
}
/**
* Set the bean that the generated map should reflect. The bean may be swapped
* out for another bean of the same type using {@link #setBean}.
* Calling this method overrides any value previously set using {@link #setBeanClass}.
* You must call either this method or {@link #setBeanClass} before {@link #create}.
* @param bean the initial bean
*/
public void setBean(Object bean) {
this.bean = bean;
if (bean != null) {
beanClass = bean.getClass();
setContextClass(beanClass);
}
}
/**
* Set the class of the bean that the generated map should support.
* You must call either this method or {@link #setBeanClass} before {@link #create}.
* @param beanClass the class of the bean
*/
public void setBeanClass(Class beanClass) {
this.beanClass = beanClass;
}
/**
* Limit the properties reflected by the generated map.
* @param require any combination of {@link #REQUIRE_GETTER} and
* {@link #REQUIRE_SETTER}; default is zero (any property allowed)
*/
public void setRequire(int require) {
this.require = require;
}
protected ClassLoader getDefaultClassLoader() {
return beanClass.getClassLoader();
}
protected ProtectionDomain getProtectionDomain() {
return ReflectUtils.getProtectionDomain(beanClass);
}
/**
* Create a new instance of the <code>BeanMap</code>. An existing
* generated class will be reused if possible.
*/
public BeanMap create() {
if (beanClass == null)
throw new IllegalArgumentException("Class of bean unknown");
setNamePrefix(beanClass.getName());
return (BeanMap)super.create(KEY_FACTORY.newInstance(beanClass, require));
}
public void generateClass(ClassVisitor v) throws Exception {
new BeanMapEmitter(v, getClassName(), beanClass, require);
}
protected Object firstInstance(Class type) {
return ((BeanMap)ReflectUtils.newInstance(type)).newInstance(bean);
}
protected Object nextInstance(Object instance) {
return ((BeanMap)instance).newInstance(bean);
}
}
/**
* Create a new <code>BeanMap</code> instance using the specified bean.
* This is faster than using the {@link #create} static method.
* @param bean the JavaBean underlying the map
* @return a new <code>BeanMap</code> instance
*/
abstract public BeanMap newInstance(Object bean);
/**
* Get the type of a property.
* @param name the name of the JavaBean property
* @return the type of the property, or null if the property does not exist
*/
abstract public Class getPropertyType(String name);
protected Object bean;
protected BeanMap() {
}
protected BeanMap(Object bean) {
setBean(bean);
}
public Object get(Object key) {
return get(bean, key);
}
public Object put(Object key, Object value) {
return put(bean, key, value);
}
/**
* Get the property of a bean. This allows a <code>BeanMap</code>
* to be used statically for multiple beans--the bean instance tied to the
* map is ignored and the bean passed to this method is used instead.
* @param bean the bean to query; must be compatible with the type of
* this <code>BeanMap</code>
* @param key must be a String
* @return the current value, or null if there is no matching property
*/
abstract public Object get(Object bean, Object key);
/**
* Set the property of a bean. This allows a <code>BeanMap</code>
* to be used statically for multiple beans--the bean instance tied to the
* map is ignored and the bean passed to this method is used instead.
* @param key must be a String
* @return the old value, if there was one, or null
*/
abstract public Object put(Object bean, Object key, Object value);
/**
* Change the underlying bean this map should use.
* @param bean the new JavaBean
* @see #getBean
*/
public void setBean(Object bean) {
this.bean = bean;
}
/**
* Return the bean currently in use by this map.
* @return the current JavaBean
* @see #setBean
*/
public Object getBean() {
return bean;
}
public void clear() {
throw new UnsupportedOperationException();
}
public boolean containsKey(Object key) {
return keySet().contains(key);
}
public boolean containsValue(Object value) {
for (Iterator it = keySet().iterator(); it.hasNext();) {
Object v = get(it.next());
if (((value == null) && (v == null)) || (value != null && value.equals(v)))
return true;
}
return false;
}
public int size() {
return keySet().size();
}
public boolean isEmpty() {
return size() == 0;
}
public Object remove(Object key) {
throw new UnsupportedOperationException();
}
public void putAll(Map t) {
for (Iterator it = t.keySet().iterator(); it.hasNext();) {
Object key = it.next();
put(key, t.get(key));
}
}
public boolean equals(Object o) {
if (o == null || !(o instanceof Map)) {
return false;
}
Map other = (Map)o;
if (size() != other.size()) {
return false;
}
for (Iterator it = keySet().iterator(); it.hasNext();) {
Object key = it.next();
if (!other.containsKey(key)) {
return false;
}
Object v1 = get(key);
Object v2 = other.get(key);
if (!((v1 == null) ? v2 == null : v1.equals(v2))) {
return false;
}
}
return true;
}
public int hashCode() {
int code = 0;
for (Iterator it = keySet().iterator(); it.hasNext();) {
Object key = it.next();
Object value = get(key);
code += ((key == null) ? 0 : key.hashCode()) ^
((value == null) ? 0 : value.hashCode());
}
return code;
}
// TODO: optimize
public Set entrySet() {
HashMap copy = new HashMap();
for (Iterator it = keySet().iterator(); it.hasNext();) {
Object key = it.next();
copy.put(key, get(key));
}
return Collections.unmodifiableMap(copy).entrySet();
}
public Collection values() {
Set keys = keySet();
List values = new ArrayList(keys.size());
for (Iterator it = keys.iterator(); it.hasNext();) {
values.add(get(it.next()));
}
return Collections.unmodifiableCollection(values);
}
/*
* @see java.util.AbstractMap#toString
*/
public String toString()
{
StringBuffer sb = new StringBuffer();
sb.append('{');
for (Iterator it = keySet().iterator(); it.hasNext();) {
Object key = it.next();
sb.append(key);
sb.append('=');
sb.append(get(key));
if (it.hasNext()) {
sb.append(", ");
}
}
sb.append('}');
return sb.toString();
}
}
@@ -0,0 +1,10 @@
/**
* Spring's repackaging of the
* <a href="http://cglib.sourceforge.net">CGLIB</a> beans package
* (for internal use only).
*
* <p>As this repackaging happens at the class file level, sources
* and javadocs are not available here... except for a few files
* that have been patched for Spring's purposes on JDK 9-17.
*/
package org.springframework.cglib.beans;
@@ -5,6 +5,6 @@
*
* <p>As this repackaging happens at the class file level, sources
* and javadocs are not available here... except for a few files
* that have been patched for Spring's purposes on JDK 9/10/11.
* that have been patched for Spring's purposes on JDK 9-17.
*/
package org.springframework.cglib.core;
@@ -5,6 +5,6 @@
*
* <p>As this repackaging happens at the class file level, sources
* and javadocs are not available here... except for a few files
* that have been patched for Spring's purposes on JDK 9/10/11.
* that have been patched for Spring's purposes on JDK 9-17.
*/
package org.springframework.cglib.proxy;
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2022 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.
@@ -25,6 +25,7 @@ import kotlin.jvm.JvmClassMappingKt;
import kotlin.reflect.KClassifier;
import kotlin.reflect.KFunction;
import kotlin.reflect.full.KCallables;
import kotlin.reflect.jvm.KCallablesJvm;
import kotlin.reflect.jvm.ReflectJvmMapping;
import kotlinx.coroutines.BuildersKt;
import kotlinx.coroutines.CoroutineStart;
@@ -70,6 +71,9 @@ public abstract class CoroutinesUtils {
*/
public static Publisher<?> invokeSuspendingFunction(Method method, Object target, Object... args) {
KFunction<?> function = Objects.requireNonNull(ReflectJvmMapping.getKotlinFunction(method));
if (method.isAccessible() && !KCallablesJvm.isAccessible(function)) {
KCallablesJvm.setAccessible(function, true);
}
KClassifier classifier = function.getReturnType().getClassifier();
Mono<Object> mono = MonoKt.mono(Dispatchers.getUnconfined(), (scope, continuation) ->
KCallables.callSuspend(function, getSuspendedFunctionArgs(target, args), continuation))

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