Commit Graph

2907 Commits

Author SHA1 Message Date
Brian Clozel 17f7a24118 Add application/graphql+json mime and media types
Closes gh-28271
2022-04-01 19:24:55 +02:00
Sam Brannen 02d3e00d33 Merge branch '5.3.x'
# Conflicts:
#	spring-core/src/main/java/org/springframework/util/SerializationUtils.java
2022-03-29 15:28:19 +02:00
Sam Brannen 3811cd4c0a Introduce warnings in documentation of SerializationUtils
Closes gh-28246
2022-03-29 15:22:30 +02:00
Sam Brannen c8d0146bcc Polish contribution
See gh-28075
2022-03-29 13:39:40 +02:00
Loïc Ledoyen 7f7fb58dd0 Deprecate SerializationUtils#deserialize
Since SerializationUtils#deserialize is based on Java's serialization
mechanism, it can be the source of Remote Code Execution (RCE)
vulnerabilities.

Closes gh-28075
2022-03-29 13:07:36 +02:00
Sébastien Deleuze e681e713d4 Initialize NativeDetector at build time
Closes gh-28244
2022-03-29 08:50:41 +02:00
Sébastien Deleuze 77a8cbcbec Remove outdated comment in NativeDetector
`-H:+InlineBeforeAnalysis` is enabled by default as of
GraalVM 21.3.
2022-03-29 08:32:02 +02:00
Juergen Hoeller 12d8010395 Merge branch '5.3.x' 2022-03-25 18:08:55 +01:00
Juergen Hoeller cb36ca31f6 Upgrade to ASM master 2022-03-25 18:07:12 +01:00
Sam Brannen 42a61b966b Remove TYPE_HIERARCHY_AND_ENCLOSING_CLASSES strategy for MergedAnnotations
This commit removes the deprecated TYPE_HIERARCHY_AND_ENCLOSING_CLASSES
search strategy from the MergedAnnotations model.

As a direct replacement for the TYPE_HIERARCHY_AND_ENCLOSING_CLASSES
search strategy, users can use the new fluent search API as follows.

MergedAnnotations mergedAnnotations =
   MergedAnnotations.search(TYPE_HIERARCHY)
      .withEnclosingClasses(clazz -> true) // always search enclosing classes
      .from(MyClass.class);

Note, however, that users are highly encouraged to use
ClassUtils::isInnerClass, ClassUtils::isStaticClass, or a custom
predicate other than `clazz -> true`.

Closes gh-28080
2022-03-24 16:31:12 +01:00
Sam Brannen 1fe394f11d Introduce predicate for searching enclosing classes in MergedAnnotations
Due to the deprecation of the TYPE_HIERARCHY_AND_ENCLOSING_CLASSES
search strategy (see gh-28079), this commit introduces a way for users
to provide a Predicate<Class<?>> that is used to decide when the
enclosing class for the class supplied to the predicate should be
searched.

This gives the user complete control over the "enclosing classes"
aspect of the search algorithm in MergedAnnotations.

- To achieve the same behavior as TYPE_HIERARCHY_AND_ENCLOSING_CLASSES,
  a user can provide `clazz -> true` as the predicate.

- To limit the enclosing class search to inner classes, a user can
  provide `ClassUtils::isInnerClass` as the predicate.

- To limit the enclosing class search to static nested classes, a user
  can provide `ClassUtils::isStaticClass` as the predicate.

- For more advanced use cases, the user can provide a custom predicate.

For example, the following performs a search on MyInnerClass within the
entire type hierarchy and enclosing class hierarchy of that class.

MergedAnnotations mergedAnnotations =
   MergedAnnotations.search(TYPE_HIERARCHY)
      .withEnclosingClasses(ClassUtils::isInnerClass)
      .from(MyInnerClass.class);

In addition, TestContextAnnotationUtils in spring-test has been
revised to use this new feature where feasible.

Closes gh-28207
2022-03-24 15:40:44 +01:00
Brian Clozel 7161940b53 Merge branch '5.3.x' 2022-03-24 13:44:38 +01:00
Yanming Zhou acf2955b96 Ban jetbrains annotations imports
Closes gh-28226
2022-03-24 13:31:36 +01:00
Sam Brannen c23edf7da6 Introduce fluent API for searches in MergedAnnotations
Prior to this commit, searching for merged annotations on an
AnnotatedElement in the MergedAnnotations model was only supported via
various overloaded from(...) factory methods. In addition, it was not
possible to provide a custom AnnotationFilter without providing an
instance of RepeatableContainers.

This commit introduces a fluent API for searches in MergedAnnotations
to address these issues and improve the programming model for users of
MergedAnnotations.

To begin a search, invoke MergedAnnotations.search(SearchStrategy) with
the desired search strategy. Optional configuration can then be
provided via one of the with(...) methods. To perform a search, invoke
from(AnnotatedElement), supplying the element from which to begin the
search -- for example, a Class or a Method.

For example, the following performs a search on MyClass within the
entire type hierarchy of that class while ignoring repeatable
annotations.

MergedAnnotations mergedAnnotations =
    MergedAnnotations.search(SearchStrategy.TYPE_HIERARCHY)
        .withRepeatableContainers(RepeatableContainers.none())
        .from(MyClass.class);

To reuse search configuration to perform the same type of search on
multiple elements, you can save the Search instance as demonstrated in
the following example.

Search search = MergedAnnotations.search(SearchStrategy.TYPE_HIERARCHY)
                    .withRepeatableContainers(RepeatableContainers.none());

MergedAnnotations mergedAnnotations = search.from(MyClass.class);
// do something with the MergedAnnotations for MyClass
mergedAnnotations = search.from(AnotherClass.class);
// do something with the MergedAnnotations for AnotherClass

In addition, this fluent search API paves the way for introducing
support for a predicate that controls the search on enclosing classes
(gh-28207) and subsequently for completely removing the
TYPE_HIERARCHY_AND_ENCLOSING_CLASSES search strategy (gh-28080).

Closes gh-28208
2022-03-22 20:01:24 +01:00
Sam Brannen 23d0240dc7 Introduce ClassUtils.isStaticClass() utility method
The impetus for this is to be able to use ClassUtils::isStaticClass
or the existing ClassUtils::isInnerClass as a method reference for
class-based predicates that need to differentiate between static
nested types and inner classes.

See gh-28207
2022-03-22 16:18:14 +01:00
Stephane Nicoll 52d5452381 Validate class name input in SimpleTypeReference
Closes gh-28213
2022-03-22 13:30:55 +01:00
Sébastien Deleuze e7e843cae2 Fix formatting errors
See gh-28212
2022-03-22 10:56:37 +01:00
Sébastien Deleuze 1ffc96be8c Fix queriedMethods handling in ReflectionHintsSerializer
Closes gh-28212
2022-03-22 09:59:55 +01:00
Sam Brannen 5c540e5390 Apply "instanceof pattern matching" in core annotation support 2022-03-18 17:24:01 +01:00
Sam Brannen 2fb1dd177b Remove obsolete org.springframework.core.NestedIOException
This commit removes Spring's custom NestedIOException and replaces its
usage with the standard IOException which has supported a root cause
since Java 6.

Closes gh-28198
2022-03-18 16:56:56 +01:00
Sam Brannen b570f60560 Merge branch '5.3.x'
# Conflicts:
#	spring-aop/src/main/java/org/springframework/aop/support/AopUtils.java
#	spring-aop/src/main/java/org/springframework/aop/support/annotation/AnnotationClassFilter.java
#	spring-aop/src/main/java/org/springframework/aop/support/annotation/AnnotationMatchingPointcut.java
#	spring-aop/src/main/java/org/springframework/aop/support/annotation/AnnotationMethodMatcher.java
#	spring-beans/src/main/java/org/springframework/beans/factory/annotation/RequiredAnnotationBeanPostProcessor.java
#	spring-context/src/main/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessor.java
#	spring-context/src/main/java/org/springframework/jmx/export/annotation/ManagedNotification.java
#	spring-context/src/main/java/org/springframework/jmx/export/annotation/ManagedOperationParameter.java
#	spring-core/src/main/java/org/springframework/javapoet/support/package-info.java
#	spring-core/src/main/java/org/springframework/util/TypeUtils.java
#	spring-web/src/main/java/org/springframework/http/HttpMethod.java
2022-03-18 16:47:12 +01:00
Sam Brannen 64b64d9ba0 Stop referring to features as "Java 5" features
With a Java 8 baseline in place for quite some time now, it no longer
makes sense to refer to features such as annotations as "Java 5
annotations".

This commit also removes old `Tiger*Tests` classes, thereby avoiding
duplicate execution of various tests.
2022-03-18 16:32:30 +01:00
Sam Brannen fc8f31ccfb Deprecate "enclosing classes" search strategy for MergedAnnotations
This commit deprecates the TYPE_HIERARCHY_AND_ENCLOSING_CLASSES search
strategy for MergedAnnotations in 6.0 M3, allowing consumers of 6.0
milestones and release candidates to provide feedback before
potentially completely removing the search strategy or providing an
alternate mechanism for achieving the same goal prior to 6.0 GA.

Closes gh-28079
See gh-28080
2022-03-16 19:34:38 +01:00
Sam Brannen fd34533a3e Merge branch '5.3.x' 2022-03-16 19:24:37 +01:00
Sam Brannen 29d98285be Add warning to "enclosing classes" search strategy for MergedAnnotations
This commit adds a warning to the Javadoc for the
TYPE_HIERARCHY_AND_ENCLOSING_CLASSES search strategy in
MergedAnnotations with regard to the scope of the search
algorithm.

See gh-28079
2022-03-16 19:23:27 +01:00
Sam Brannen ad708780ed Polish Javadoc for MergedAnnotations 2022-03-16 19:23:27 +01:00
Sébastien Deleuze 77e0100f42 Implement GraalVM native JSON configuration generation
This commit implements 4 package private Json serializers
for JavaSerializationHints, ProxyHints, ReflectionHints
and ResourceHints to serialize GraalVM native JSON configuration
as documented in
https://www.graalvm.org/22.0/reference-manual/native-image/BuildConfiguration/.

It exposes the related functionality via
NativeConfigurationGenerator which allows to generate the
relevant files on the filesystem via the
FileNativeConfigurationGenerator implementation.

The generated *-config.json files have been validated working
with GraalVM 22.0.

Closes gh-27991
2022-03-16 16:15:58 +01:00
Sam Brannen bb9cf7cce1 Merge branch '5.3.x' 2022-03-16 15:29:22 +01:00
Sam Brannen c9cd53f469 Revert "Deprecate "enclosing classes" search strategy for MergedAnnotations"
This reverts commit 5689395678.

See gh-28079
2022-03-16 15:27:52 +01:00
Sam Brannen ae51ca9bca Revert "Remove deprecated "enclosing classes" search strategy for MergedAnnotations"
This reverts commit 819d4256b7.

See gh-28080
2022-03-16 15:18:34 +01:00
Sam Brannen 9764f0e59b Merge branch '5.3.x'
# Conflicts:
#	spring-test/src/test/java/org/springframework/mock/http/server/reactive/MockServerHttpRequestTests.java
#	spring-web/src/test/java/org/springframework/http/server/reactive/HeadersAdaptersTests.java
#	spring-web/src/test/java/org/springframework/web/client/RestTemplateIntegrationTests.java
#	spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientIntegrationTests.java
#	spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/SseIntegrationTests.java
#	spring-webmvc/src/test/java/org/springframework/web/servlet/handler/MappedInterceptorTests.java
#	spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/HandlerMethodAnnotationDetectionTests.java
#	spring-websocket/src/test/java/org/springframework/web/socket/AbstractWebSocketIntegrationTests.java
2022-03-16 15:07:53 +01:00
Sam Brannen c462fe30ed Use Named arguments in parameterized tests 2022-03-16 14:45:47 +01:00
Juergen Hoeller c3aed75b92 Merge branch '5.3.x'
# Conflicts:
#	build.gradle
2022-03-16 11:24:24 +01:00
Juergen Hoeller c1261f2860 Fix accidental exclusion of BeanMapEmitter class
Closes gh-28110
2022-03-16 11:20:49 +01:00
rstoyanchev e7b97f5be7 Merge branch '5.3.x' into main 2022-03-16 09:27:43 +00:00
rstoyanchev cb39b07088 Polishing Jackson encoder tests 2022-03-16 05:55:23 +00:00
Stephane Nicoll da45bd2dfd Polish contribution
See gh-28057
2022-03-15 20:19:46 +01:00
Phillip Webb 12244b2e51 Provide more control over factory failure handling
Add an additional `FactoryInstantiationFailureHandler` strategy
interface to `SpringFactoriesLoader` to allows instantiation
failures to be handled on a per-factory bases.

For example, to log trace messages for only factories that can't
be created the following can be used:

	FactoryInstantiationFailureHandler.logging(logger);

If no `FactoryInstantiationFailureHandler` instance is supplied
then `FactoryInstantiationFailureHandler.throwing()` is used
which provides back-compatible behavior by throwing an
`IllegalArgumentException`.

See gh-28057

Co-authored-by: Madhura Bhave <bhavem@vmware.com>
Co-authored-by: Andy Wilkinson <wilkinsona@vmware.com>
2022-03-15 20:19:46 +01:00
Phillip Webb 0b716c4f90 Allow flexible constructor arguments in factory implementations
Update `SpringFactoriesLoader` so that factory implementation classes
can have a constructor with arguments that are resolved dynamically.

Arguments are resolved using a `ArgumentResolver` interface that is
passed to the `loadFactories` method. This strategy interface is
intentionally simple and only allows resolution based on the argument
type. A number of convenience methods are provided to allow resolvers
to be built. For example:

	ArgumentResolver.of(String.class, "tests")
			.and(Integer.class, 123);

Factory implementation classes must have a non-ambiguous constructor
in order to be instantiated. The `SpringFactoriesLoader` uses the same
algorithm as `BeanUtils.getResolvableConstructor`.

See gh-28057

Co-authored-by: Madhura Bhave <bhavem@vmware.com>
Co-authored-by: Andy Wilkinson <wilkinsona@vmware.com>
2022-03-15 20:19:46 +01:00
Sam Brannen 1392b0f557 Merge branch '5.3.x' 2022-03-15 17:13:10 +01:00
Sam Brannen 9fbf5dc945 Use String#lastIndexOf(int) where possible 2022-03-15 17:03:20 +01:00
Sam Brannen 92d9aee3a2 Polish TestSocketUtils 2022-03-14 15:11:04 +01:00
Sam Brannen 389747f91c Make TestSocketUtils abstract 2022-03-13 15:58:53 +01:00
Sam Brannen 542b6427c3 Revise documentation for TestSocketUtils 2022-03-13 15:54:23 +01:00
Sam Brannen 2858c1efb5 Merge branch '5.3.x' 2022-03-12 14:04:29 +01:00
Lee, Kyutae 8a510db00d Polish Javadoc for Environment
Closes gh-28170
2022-03-12 14:02:26 +01:00
Stephane Nicoll e873715737 Fix detection of protected generic parameter
This commit fixes the algorithm used to analyze a generic parameter. If
a type in the generic signature is protected, the type is return rather
than the full signature. This makes sure that the appropriate package
is used. Previously, it would have incorrectly used the type of the
raw class.

Using a generic type for such a use case is wrong, and ProtectedElement
has been updated to expose a `Class` rather than a `ResolvableType`.

See gh-28030
2022-03-09 11:17:21 +01:00
Stephane Nicoll fd191d165b Add GeneratedType infrastructure
This commit adds an infrastructure for code that generate types with the
need to write to another package if privileged access is required. An
abstraction around types where methods can be easily added is also
available as part of this commit.

Closes gh-28149
2022-03-09 11:17:21 +01:00
Stephane Nicoll 14b147ce70 Add TypeReference implementation for generated code
This commit adds a TypeReference implementation that is suitable for
creating a reference to generated code.

Closes gh-28148
2022-03-09 11:17:21 +01:00
Sam Brannen e85001f332 Clean up warnings in test fixture 2022-02-19 17:32:15 +01:00
Sam Brannen 819d4256b7 Remove deprecated "enclosing classes" search strategy for MergedAnnotations
Closes gh-28080
2022-02-19 17:25:50 +01:00
Sam Brannen ad3095f197 Merge branch '5.3.x' 2022-02-19 17:02:02 +01:00
Sam Brannen 5689395678 Deprecate "enclosing classes" search strategy for MergedAnnotations
The TYPE_HIERARCHY_AND_ENCLOSING_CLASSES search strategy for
MergedAnnotations was originally introduced to support @Nested test
classes in JUnit Jupiter (see #23378).

However, while implementing #19930, we determined that the
TYPE_HIERARCHY_AND_ENCLOSING_CLASSES search strategy unfortunately
could not be used since it does not allow the user to control when to
recurse up the enclosing class hierarchy. For example, this search
strategy will automatically search on enclosing classes for static
nested classes as well as for inner classes, when the user probably
only wants one such category of "enclosing class" to be searched.
Consequently, TestContextAnnotationUtils was introduced in the Spring
TestContext Framework to address the shortcomings of the
TYPE_HIERARCHY_AND_ENCLOSING_CLASSES search strategy.

Since this search strategy is unlikely to be useful to general users,
the team has decided to deprecate this search strategy in Spring
Framework 5.3.x and remove it in 6.0.

Closes gh-28079
2022-02-19 16:51:00 +01:00
Sam Brannen 8c6d59aaaf Polish contribution
See gh-28014
2022-02-19 14:43:26 +01:00
a.yazychyan c5c926726d Use enhanced switch expressions where feasible
Closes gh-28014
2022-02-19 14:34:05 +01:00
Sam Brannen 2cee63491d Remove deprecated SocketUtils
Closes gh-28052
2022-02-15 16:19:11 +01:00
Stephane Nicoll 5fbd01f28f Polish 2022-02-15 15:25:45 +01:00
Sam Brannen 7412625929 Merge branch '5.3.x'
# Conflicts:
#	spring-web/src/test/java/org/springframework/remoting/caucho/CauchoRemotingTests.java
#	spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientIntegrationTests.java
2022-02-15 14:35:25 +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 11de64d609 Merge branch '5.3.x' 2022-02-15 13:48:22 +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 5bbc7dbce2 Polish ProtectedAccess options
This commit improves how protected access analysis operates. Rather than
providing a static boolean, a function callback for the member to
analyse is used. This permits to change the decision whether reflection
can be used, or if the return type is assigned.

Both of those are already applicable, with InjectionGenerator relying
on reflection for private fields, and DefaultBeanInstanceGenerator
assigning the bean instance if additional contributors are present.

This commit also moves the logic of computing the options where the code
is actually generated.

See gh-28030
2022-02-15 13:16:39 +01:00
Stephane Nicoll c5e1a774a5 Add bean instance generator infrastructure
This commit provides the necessary infrastructure to let components
contribute statements that are used to fully instantiate a bean
instance.

To ease code generation, a dedicated infrastructure to register bean
definition is provided in the o.s.beans.factory.generator package.
BeanDefinitionRegistrar offers a builder style API that provides a way
to hide how injected elements are resolved at runtime and let
contributors provide code that may throw a checked exception.

BeanInstanceContributor is the interface that components can implement
to contribute to a bean instance setup. DefaultBeanInstanceGenerator
generates, for a particular bean definition, the necessary statements
to instantiate a bean.

Closes gh-28047
2022-02-14 17:01:32 +01:00
Sébastien Deleuze 5e64081ed1 Merge branch '5.3.x' 2022-02-14 10:51:46 +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
Sam Brannen e6ce328be4 Merge branch '5.3.x'
# Conflicts:
#	spring-core/src/test/java/org/springframework/core/annotation/AnnotationTypeMappingsTests.java
2022-02-13 00:00:11 +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 7b0443333d Merge branch '5.3.x'
# Conflicts:
#	build.gradle
2022-02-11 20:44:42 +01:00
Sam Brannen 4eaee1e738 Short circuit if-conditions in AttributeMethods 2022-02-11 20:41:23 +01:00
Sam Brannen a4e192e33d Merge branch '5.3.x'
# Conflicts:
#	spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsTests.java
2022-02-11 15:38:54 +01:00
Sam Brannen b60340b102 Simplify tests for synthesized annotation toString()
See gh-28015
2022-02-11 15:33:14 +01:00
Sam Brannen 5ae9217271 Merge branch '5.3.x'
# Conflicts:
#	spring-core/src/main/java/org/springframework/core/annotation/SynthesizedMergedAnnotationInvocationHandler.java
#	src/eclipse/org.eclipse.jdt.ui.prefs
2022-02-11 15:01:47 +01:00
Brian Clozel 6c42bcfaec Upgrade to Kotlin 1.6.20-M1
This commit upgrades the Kotlin dependencies to 1.6.20-M1 and configures
the build to generate Java 17 bytecode for Kotlin classes.

Closes gh-27814
2022-02-11 11:39:32 +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
Stephane Nicoll 1a4573641d Add code contribution infrastructure
This commit adds an API that lets individual components contribute code,
runtime hints, and protected access information. This ease the cases
where code need to be written in a privileged package if necessary and
let contributors provide hints for the code they generate.

Closes gh-28030
2022-02-10 15:54:43 +01:00
Stephane Nicoll b3ceb0f625 Add core JavaPoet utilities
This commit adds utilities that facilitate code generation patterns
used by the AOT engine.

Closes gh-28028
2022-02-10 14:58:04 +01:00
Stephane Nicoll dfae8effa8 Repackage Javapoet in org.springframework.javapoet
This commit repackages the Javapoet library into spring-core so that it
can be used by the AOT engine without requiring a specific version.

Closes gh-27828
2022-02-10 14:56:36 +01:00
Sam Brannen 1deb6b04b8 Apply "instanceof pattern matching" in SynthesizedMergedAnnotationInvocationHandler 2022-02-08 14:30:26 +01:00
Sam Brannen 839cc5f7f8 Remove unnecessary JDK 9+ check in MergedAnnotationsTests 2022-02-08 14:19:32 +01:00
Sam Brannen bf40033e86 Merge branch '5.3.x' 2022-02-08 14:15:25 +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
Stephane Nicoll a0c97e4c36 Polish
See gh-27829
2022-02-07 12:51:53 +01:00
Stephane Nicoll 6936f7e0cb Relocate runtime hints to aot package
See gh-27829
2022-02-07 12:51:43 +01:00
Juergen Hoeller b0bca7f5ae Merge branch '5.3.x'
# Conflicts:
#	build.gradle
2022-02-04 23:55:18 +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 3eb9886724 Merge branch '5.3.x'
# Conflicts:
#	spring-context-support/src/main/java/org/springframework/scheduling/commonj/WorkManagerTaskExecutor.java
#	spring-core/src/main/java/org/springframework/core/task/SimpleAsyncTaskExecutor.java
#	spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectivePropertyAccessor.java
#	spring-tx/src/main/java/org/springframework/jca/work/SimpleTaskWorkManager.java
#	spring-tx/src/main/java/org/springframework/jca/work/WorkManagerTaskExecutor.java
2022-02-04 23:24:21 +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 b3f786728e Use modern language features in tests 2022-02-03 15:35:32 +01:00
Sam Brannen 54565e95b5 Merge branch '5.3.x' 2022-02-03 14:58:36 +01:00
Sam Brannen f8a5a8d7be Use modern language features in tests 2022-02-03 14:50:10 +01:00
Stephane Nicoll 48ce714d15 Provide an API to record various runtime hints
This commit provides an API to record the need for reflection,
resources, serialization, and proxies so that the runtime can be
optimized accordingly.

`RuntimeHints` provides an entry point to register the following:

* Reflection hints: individual elements of a type can be defined, as
well as a predefined categories (identified by the `MemberCategory`
enum). A method or constructor hint can refine whether the executable
should only be introspected or also invoked.
* Resource hints: patterns using includes/excludes identify the
resources to include at runtime. Resource bundles are also supported.
* Java Serialization hints: types that use java serialization can be
registered.
* Proxy hints: both interfaces-based (JDK) proxy and class-based proxy
can be defined.

This commit also introduces a `TypeReference` abstraction that permits
to record hints for types that are not available on the classpath, or
not compiled yet (generated code).

Closes gh-27829
2022-01-25 15:45:40 +01:00
Sam Brannen 72fc706c22 Merge branch '5.3.x' 2022-01-25 10:03:51 +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 08daacfc1b Merge branch '5.3.x' 2022-01-24 20:33:51 +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
Juergen Hoeller 66732afc10 Merge branch '5.3.x'
# Conflicts:
#	build.gradle
#	spring-jms/src/main/java/org/springframework/jms/listener/AbstractPollingMessageListenerContainer.java
2022-01-19 13:56:37 +01:00
Juergen Hoeller 86be03945b Polishing 2022-01-19 13:54:03 +01:00
Sam Brannen 198576dbc5 Merge branch '5.3.x' 2022-01-13 16:21:16 +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
Sam Brannen 5aefcd2fdb Re-enable BlockHound integration tests
Prior to this commit, our BlockHound integration tests were disabled
after the migration to a JDK 17 baseline since the build now always
runs on JDK 14 or higher.

To re-enable the tests we now supply the deprecated
-XX:+AllowRedefinitionToAddDeleteMethods command-line argument to the JVM
for tests in the Gradle build. Users can also configure this manually
within an IDE to run SpringCoreBlockHoundIntegrationTests.

If that command-line argument is removed from the JVM at some point in
the future, we will need to investigate an alternative solution.

See https://github.com/reactor/BlockHound/issues/33 for details.
2022-01-11 14:54:59 +01:00
Sam Brannen f2fe8a87fa Polish contribution
See gh-27862
2022-01-11 14:11:07 +01:00
v_vyqyxiong 6ecb488327 Remove unnecessary check in isBridgedCandidateFor()
In BridgeMethodResolver#isBridgedCandidateFor, candidateMethod is never
not bridged, so it's unnecessary to judge whether candidateMethod and
bridgeMethod are the same.

Closes gh-27862
2022-01-11 14:03:57 +01:00
Sam Brannen d57bc176f2 Merge branch '5.3.x' 2022-01-10 14:21:25 +01:00
Sam Brannen df263d01b9 Use idiomatic AssertJ assertions for true, false, and null 2022-01-10 14:15:55 +01:00
Sam Brannen 4ebc53a424 Merge branch '5.3.x' 2022-01-10 13:28:31 +01:00
kuanghc1 2a80b64d40 Add tests for StringUtils matchesCharacter() method
Closes gh-27909
2022-01-10 13:27:15 +01:00
Sam Brannen 519fa60c25 Merge branch '5.3.x' 2022-01-09 17:12:49 +01:00
Sam Brannen 8087eb69bf Improve error message in ResolvableType.forClassWithGenerics()
Prior to this commit, the error message generated for a mismatched
number of generics did not include the information about the class in
question.

This commit improves the error message by providing more context,
specifically the result of invoking toGenericString() on the class.

For example, instead of throwing an IllegalArgumentException with the
error message "Mismatched number of generics specified", the error
message would now be "Mismatched number of generics specified for
public abstract interface java.util.Map<K,V>".

Closes gh-27847
2022-01-09 17:05:07 +01:00
Sam Brannen e41d865193 Polishing 2022-01-09 17:05:07 +01:00
Sam Brannen 5d508de2c0 Merge branch '5.3.x' 2022-01-09 16:17:42 +01:00
Sam Brannen d68bb4eecd Simplify StreamConverterTests 2022-01-09 16:15:32 +01:00
Sam Brannen 730ad4436f Polish contribution 2022-01-09 16:15:32 +01:00
kth496 23ab9ca8ca Refactor tests to use lambda expressions & method references
Closes gh-27386
2022-01-09 15:37:54 +01:00
Sam Brannen 202b7ea47b Merge branch '5.3.x' 2022-01-04 15:17:05 +01:00
Sam Brannen c3ce4f0f90 Polish contribution
See gh-27823
2022-01-04 15:12:29 +01:00
Marten Deinum e1200f34e7 Use try-with-resources for AutoClosables where feasible
Where unfeasible, this commit adds inline comments to explain why
try-with-resources must not be used in certain scenarios. The purpose
of the comments is to avoid accidental conversion to try-with-resources
at a later date.

Closes gh-27823
2022-01-04 15:12:29 +01:00
Marten Deinum 941b6af9ac Use Collection factory methods when applicable
This commit replaces the use of Collections.unmodifiableList/Set/Map
with the corresponding 'of(...)' factory methods introduced in Java 9.

Closes gh-27824
2022-01-04 12:01:13 +01:00
liuzhifei 7021eb5bb1 Apply "instanceof pattern matching" in additional locations
Closes gh-27696
2022-01-03 16:52:38 +01:00
Stephane Nicoll ca6911a532 Update copyright year of changed file
See gh-24636
2021-12-21 09:49:08 +01:00
陈其苗 dbbdd044cd Use Collections.addAll instead of Collection.addAll
See gh-24636
2021-12-21 09:47:30 +01:00
Juergen Hoeller 96e2fc69ed Merge branch '5.3.x'
# Conflicts:
#	build.gradle
#	spring-core/src/main/java/org/springframework/core/type/StandardAnnotationMetadata.java
#	spring-core/src/main/java/org/springframework/core/type/classreading/SimpleAnnotationMetadata.java
2021-12-15 18:03:51 +01:00
Juergen Hoeller 1885ab3e07 Polishing 2021-12-15 17:58:28 +01:00
Juergen Hoeller 50c7c84886 Introduce getDeclaredMethods() for MethodMetadata of all user-declared methods
Closes gh-27701
2021-12-15 13:32:42 +01:00
Juergen Hoeller bfdb93b406 Merge branch '5.3.x'
# Conflicts:
#	build.gradle
#	src/docs/asciidoc/integration.adoc
2021-12-14 16:51:00 +01:00
Juergen Hoeller ac581bed92 Avoid NPE against null value from toString call
Closes gh-27782
2021-12-14 16:46:42 +01:00
Juergen Hoeller 0802581aff Unit test for identifying type variable argument
See gh-27748
2021-12-14 16:46:26 +01:00
Juergen Hoeller aeff664cf9 Polishing 2021-12-14 09:46:52 +01:00
Rossen Stoyanchev 3a43ca3a34 Merge branch '5.3.x' into main 2021-12-08 11:41:02 +00:00
Rossen Stoyanchev 99c7608ffe Replace both EOL and control characters 2021-12-08 11:25:38 +00:00
Arjen Poutsma 81af7330f6 Deprecate StringUtils::trimWhitespace and variants
This commits deprecates
- StringUtils::trimWhitespace in favor of String::strip
- StringUtils::trimLeadingWhitespace in favor of String::stripLeading
- StringUtils::trimTrailingWhitespace in favor of String::stripTrailing

Closes gh-27769
2021-12-06 13:37:16 +01:00
liuzhifei 68cf95f499 Use String::strip in StringUtils::trimWhitespace
See gh-27703
2021-12-06 11:29:43 +01:00
Juergen Hoeller 7f43128a0e Merge branch '5.3.x'
# Conflicts:
#	build.gradle
#	spring-web/src/main/java/org/springframework/web/server/MediaTypeNotSupportedStatusException.java
#	spring-web/src/main/java/org/springframework/web/util/ContentCachingRequestWrapper.java
#	spring-webmvc/src/main/java/org/springframework/web/servlet/handler/HandlerMappingIntrospector.java
2021-12-03 22:42:05 +01:00
Juergen Hoeller 7c834d98c2 Upgrade to ASM master (including early support for Java 19 bytecode)
Closes gh-27740
2021-12-03 22:32:26 +01:00
Stephane Nicoll e986ff8d07 Update copyright year of changed files
See gh-27239
2021-12-02 11:32:46 +01:00
Frederick Zhang baed0785fd Replace XMLReaderFactory with SAXParserFactory
XMLReaderFactory has been marked as deprecated and without additional
configuration, and it's slower than SAXParserFactory.

Previously `XMLReaderFactory.createXMLReader()` is called upon every
request. This is an anti-pattern as mentioned in [1] and it can be very
slow since it loads the jar service file unless a parser has been
pre-assigned [2] (e.g. by setting org.xml.sax.driver).

SAXParserFactory uses a FactoryFinder [3] instead, which takes advantage
of a thread-local cache provided by ServiceLoader. Developers can still
pre-assign a factory by setting javax.xml.parsers.SAXParserFactory to
make it faster.

[1] https://bugs.openjdk.java.net/browse/JDK-6925410
[2] c8add223a1/src/java.xml/share/classes/org/xml/sax/helpers/XMLReaderFactory.java (L144-L148)
[3] 66c653c561/src/java.xml/share/classes/javax/xml/parsers/SAXParserFactory.java (L181-L185)

See gh-27239
2021-12-02 11:32:46 +01:00
Stephane Nicoll 46cb5ab135 Polish contribution
See gh-23813
2021-11-30 14:29:05 +01:00
Johnny Lim 5c4cde7853 Polish AbstractResource
See gh-23813
2021-11-30 14:25:40 +01:00
Arjen Poutsma 6d9136013e Refactor MimeType/MediaType specificity
This commit makes several changes to MimeType and MediaType
related to the topic of specificity.

This commit deprecates the MimeType and MediaType Comparators.
Comparators require a transitive relationship, and the desired order for
these types is not transitive (see #27488).

Instead, this commit introduces two new MimeType methods: isMoreSpecific
and isLessSpecific, both of which return booleans. MediaType overrides
these methods to include the quality factor (q) in the comparison.

All MediaType sorting methods have been deprecated in favor of
MimeTypeUtils::sortBySpecificity.  This sorting method now uses
MimeType::isLessSpecific in combination a bubble sort algorithm (which
does not require a transitive compare function).

Closes gh-27580
2021-11-23 11:49:01 +01:00
Juergen Hoeller 4750a9430c Early removal of 5.x-deprecated code
Closes gh-27686
2021-11-18 09:18:06 +01:00
Arjen Poutsma 17cdd97c37 Merge branch '5.3.x' 2021-11-17 16:57:02 +01:00
Arjen Poutsma 5fbdd6dcfe Throw exception using capturing patterns in AntPathMatcher
Closes gh-27688
2021-11-17 16:52:17 +01:00
SungMin 32af39d6e6
Use 'toString(Charset)' instead of 'toString(String)' for encodings (#27646)
Co-authored-by: 홍성민(SungMin Hong)/Platform Engineering팀/11ST <devmonster@11stcorp.com>
2021-11-10 15:11:33 +01:00
Rossen Stoyanchev ec947065a9 Merge branch '5.3.x' into main 2021-11-09 10:23:14 +00:00
Rossen Stoyanchev c5de5c9939 Update Javadoc of LogFormatUtils
Closes gh-27632
2021-11-08 21:21:54 +00:00
Sam Brannen 56fd97184c Avoid generic type parameter hiding in UnmodifiableValueCollection 2021-10-29 11:32:44 +02:00
Sam Brannen 4464468465 Clean up warnings in UnmodifiableMultiValueMapTests 2021-10-29 11:27:38 +02:00
최유진(Yujin Choi)/Platform Engineering팀/11ST 8dd385b440 Use toUnmodifiableSet and toList instead of collectingAndThen
Since Spring Framework 6 uses JDK 17 for its baseline, we can make use
of toList() and toUnmodifiableSet() which were introduced in JDK 16 and
JDK 10, respectively.

Closes gh-27618
2021-10-28 16:37:41 +02:00
Arjen Poutsma 0a58419df4 Add immutable MultiValueMap wrapper
This commit introduces UnmodifiableMultiValueMap, an immutable wrapper
around a MultiValueMap, similar to what is returned by
Collections.unmodifiable*.
CollectionUtils::unmodifiableMultiValueMap now returns
UnmodifiableMultiValueMap.

Closes gh-27608
2021-10-26 15:31:34 +02:00
Sam Brannen 170d6dd5f2 Merge branch '5.3.x' 2021-10-22 13:17:59 +02:00
Sam Brannen 9af11ad5ce Fix Javadoc formatting issues 2021-10-22 11:08:45 +02:00
Arjen Poutsma e4b493456b Remove custom EnumerationIterator
This commit removes our custom EnumerationIterator, in favor of
Enumeration::asIterator (since JDK 9).
2021-10-20 18:29:33 +02:00
Arjen Poutsma 9804e75051 Merge branch '5.3.x' 2021-10-19 11:59:53 +02:00
Arjen Poutsma a248a52575 Revert transitive MediaType comparators
The fix made for gh-27488 resulted in a change of the default order
of codecs. This commit reverts these changes, so that the previous
order is restored.

Closes gh-27573
2021-10-19 11:53:22 +02:00
Arjen Poutsma 2a3c9e403f Revert "Polishing"
This reverts commit bfa01b35df.
2021-10-19 10:16:27 +02:00
Rossen Stoyanchev 24b0035369 Merge branch '5.3.x' into main 2021-10-18 16:56:02 +01:00
Rossen Stoyanchev 346b755802 Fix assertion message in DefaultDataBuffer
Closes gh-27567
2021-10-18 16:54:24 +01:00
Sam Brannen cb17441780 Apply "instanceof pattern matching" Eclipse clean-up in spring-core
This commit also applies additional clean-up tasks such as the following.

- final fields
- diamond operator (<>) for anonymous inner classes

This has only been applied to `src/main/java`.
2021-10-14 18:30:06 +02:00
Rossen Stoyanchev 3633b2a24f Merge branch '5.3.x' into main 2021-10-13 21:22:34 +01:00
Rossen Stoyanchev a178bbe86f DefaultResponseErrorHandler shows full error details
Closes gh-27552
2021-10-13 20:51:34 +01:00
Juergen Hoeller da457abd5b Merge branch '5.3.x' 2021-10-12 15:19:40 +02:00
Juergen Hoeller 715f300fa1 Avoid expensive isReadable() check during classpath scan
Closes gh-25741
See gh-21372
2021-10-12 15:15:51 +02:00
Juergen Hoeller b53275f2d2 Add efficient existence check to ClassPathResource.isReadable()
Includes reduced isReadable() check in PathResourceLookupFunction, aligned with PathResourceResolver.

Closes gh-27538
See gh-21372
2021-10-12 15:13:05 +02:00
Stephane Nicoll d16574f807 Merge branch '5.3.x' 2021-10-11 16:21:14 +02:00
Sam Brannen eb07dea795 Polish contribution
See gh-27544
2021-10-11 15:31:40 +02:00
Сергей Цыпанов 114fa47171 Use Arrays.hashCode() in ByteArrayResource.hashCode() 2021-10-11 15:28:50 +02:00
Rossen Stoyanchev bd85cb8bac Merge branch '5.3.x' into main 2021-10-11 11:20:14 +01:00
Rossen Stoyanchev e8f6cd10a5 Apply value formatting to resolved exceptions 2021-10-11 11:14:02 +01:00
Juergen Hoeller 56eefe2a13 Merge branch '5.3.x' 2021-10-08 20:42:54 +02:00
Juergen Hoeller 87aaf5049b Polishing 2021-10-08 20:41:51 +02:00
Rossen Stoyanchev 6eaaf294f3 Merge branch '5.3.x' into main 2021-10-06 21:32:01 +01:00
Rossen Stoyanchev 90fdcf88d8 Generalize formatValue
Provide an overload for additional control and compact output.
2021-10-06 21:27:56 +01:00
Sam Brannen 2d1e0d5e38 Merge branch '5.3.x' 2021-10-06 12:13:21 +02:00
Sam Brannen 41ae9632d1 Upgrade to Checkstyle 9.0 and spring-javaformat 0.0.29
This commit upgrades the Gradle build to use Checkstyle 9.0 and
spring-javaformat 0.0.29 (which internally uses Checkstyle 8.45.1).

Closes gh-27520
2021-10-06 12:11:19 +02:00
Sam Brannen 47b0da6b25 Polishing 2021-10-06 11:48:30 +02:00
Arjen Poutsma fb7eea9757 Merge branch '5.3.x' 2021-10-05 16:32:55 +02:00
Arjen Poutsma c99210c01f Propagate Reactor Context when using FluxSink
This commit makes sure that the Reactor context from a given mono or
flux is propagated to the Flux returned by a FluxSink. This change
affects both DataBufferUtils::write and internal classes used by the
DefaultPartHttpMessageReader.

Closes gh-27517
2021-10-05 16:30:49 +02:00
Sam Brannen 381b7d035a Merge branch '5.3.x' 2021-10-05 14:55:22 +02:00
Sam Brannen 48a507a993 Clean up warnings 2021-10-05 14:35:32 +02:00
Sam Brannen dabe823a4a Merge branch '5.3.x' 2021-10-05 14:24:36 +02:00
Sam Brannen be3bc4c164 Comment out unused fudgeFactor 2021-10-05 14:24:18 +02:00
Juergen Hoeller 5766855514 Merge branch '5.3.x'
# Conflicts:
#	build.gradle
2021-10-02 12:20:58 +02:00
Juergen Hoeller bf373c5065 Skip all flaky StopWatch time assertions 2021-10-02 12:04:13 +02:00
Sam Brannen cb9246e481 Merge branch '5.3.x' 2021-10-01 10:36:28 +02:00
Sam Brannen f0aa4f4857 Escape closing curly braces in regular expressions for Android support
PR gh-24470 introduced a regression for Android users by no longer
escaping closing curly braces in regular expressions.

This commit therefore partially reverts the changes made in 273812f9c5
for closing curly braces (`}`).

Closes gh27467
2021-10-01 10:35:28 +02:00
Juergen Hoeller ad873617d2 Note on ClassLoader.defineClass being used as a fallback only 2021-09-30 18:26:01 +02:00
Juergen Hoeller f6a392c5ae Merge branch '5.3.x' 2021-09-30 18:14:15 +02:00
Juergen Hoeller 24bcb52b2f Polishing 2021-09-30 18:09:07 +02:00
Juergen Hoeller dc5807ea51 Merge branch '5.3.x'
# Conflicts:
#	spring-core/src/main/java/org/springframework/cglib/core/ReflectUtils.java
2021-09-30 17:37:28 +02:00
Juergen Hoeller a295a28e4b Defensively handle fast class generation failure for individual methods
Includes rethrowing of last actual defineClass exception encountered.

Closes gh-27490
2021-09-30 17:33:58 +02:00
Arjen Poutsma a4b74a320e Merge branch '5.3.x' 2021-09-30 17:12:41 +02:00
Arjen Poutsma bfa01b35df Polishing
See gh-27488
2021-09-30 17:09:03 +02:00
Arjen Poutsma 4f61e9cdee Merge branch '5.3.x' 2021-09-30 16:17:36 +02:00
Arjen Poutsma 388c8e4aa5 Make sure that MediaType comparators are transitive
Previous to this commit, the specificity and quality comparators
(used by MediaType::sortByQualityValue and MediaType::sortBySpecificity)
could result in IllegalArgumentExceptions when used for sorting.
The underlying reason was that the comparators were not transitive, and
both media types with the same type, and types with the same amount of
parameters, would be considered identical by the comparator (result 0).

This commit ensures that the comparators are transitive.

Closes gh-27488
2021-09-30 16:15:38 +02:00
Sam Brannen 030ba52805 Merge branch '5.3.x' 2021-09-29 16:56:33 +02:00
Sam Brannen 96e4d3a530 Fail Gradle build for Javadoc warnings
In order to catch Javadoc errors in the build, we now enable the
`Xwerror` flag for the `javadoc` tool. In addition, we now use
`Xdoclint:syntax` instead of `Xdoclint:none` in order to validate
syntax within our Javadoc.

This commit fixes all resulting Javadoc errors and warnings.

This commit also upgrades to Undertow 2.2.12.Final and fixes the
artifact names for exclusions for the Servlet and annotations APIs.

The incorrect exclusion of the Servlet API resulted in the Servlet API
being on the classpath twice for the javadoc task, which resulted in the
following warnings in previous builds.

javadoc: warning - Multiple sources of package comments found for package "javax.servlet"
javadoc: warning - Multiple sources of package comments found for package "javax.servlet.http"
javadoc: warning - Multiple sources of package comments found for package "javax.servlet.descriptor"
javadoc: warning - Multiple sources of package comments found for package "javax.servlet.annotation"

Closes gh-27480
2021-09-29 14:02:37 +02:00
Juergen Hoeller 4d7fa9a632 Merge branch '5.3.x'
# Conflicts:
#	spring-context/src/main/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessor.java
2021-09-28 18:18:23 +02:00
Juergen Hoeller 040445612f Polishing 2021-09-28 18:15:56 +02:00
Sam Brannen 08bce08018 Use text blocks with JUnit Jupiter 5.8.1
See gh-27450
2021-09-28 14:20:31 +02:00
Sam Brannen 93efb20a53 Fix broken links in Javadoc
This commit removes several links that were broken due to the removal
of various APIs in 6.0.

See gh-27480
2021-09-28 13:34:33 +02:00
Sam Brannen 3dc84c2d92 Merge branch '5.3.x' 2021-09-28 11:48:50 +02:00
Sam Brannen bfdc99ab79 Fix Javadoc errors
See gh-27480
2021-09-28 11:44:12 +02:00
Sam Brannen 16bf39ea1b Merge branch '5.3.x' 2021-09-28 10:35:18 +02:00
Sam Brannen 2567b20949 Upgrade to spring-javaformat 0.0.28 and downgrade to Checkstyle 8.41
In order to be able to use text blocks and other new Java language
features, we are upgrading to a recent version of Checkstyle.

The latest version of spring-javaformat-checkstyle (0.0.28) is built
against Checkstyle 8.32 which does not include support for language
features such as text blocks. Support for text blocks was added in
Checkstyle 8.36.

In addition, there is a binary compatibility issue between
spring-javaformat-checkstyle 0.0.28 and Checkstyle 8.42. Thus we cannot
use Checkstyle 8.42 or higher.

In this commit, we therefore upgrade to spring-javaformat-checkstyle
0.0.28 and downgrade to Checkstyle 8.41.

This change is being applied to `5.3.x` as well as `main` in order to
benefit from the enhanced checking provided in more recent versions of
Checkstyle.

Closes gh-27481
2021-09-28 10:29:31 +02:00
Juergen Hoeller b3f6d60dc9 Merge branch '5.3.x'
# Conflicts:
#	build.gradle
#	spring-core/src/main/java/org/springframework/core/ReactiveAdapterRegistry.java
#	spring-core/src/test/java/org/springframework/core/ReactiveAdapterRegistryTests.java
#	src/docs/asciidoc/web-reactive.adoc
2021-09-27 17:26:26 +02:00
Juergen Hoeller 119c78b1c9 Skip flaky StopWatch time assertions 2021-09-27 17:11:12 +02:00
Juergen Hoeller b0c424b376 Deprecate RxJava 2 in favor of RxJava 3
Closes gh-27474
2021-09-27 16:56:28 +02:00
Juergen Hoeller e6112344d2 Remove support for RxJava 2.x as well
Includes realignment of Reactor adapter registration.

Closes gh-27443
2021-09-27 13:01:32 +02:00
Juergen Hoeller 0241c5ebb3 Merge branch '5.3.x'
# Conflicts:
#	spring-core/spring-core.gradle
2021-09-23 15:59:32 +02:00
Juergen Hoeller e29cfa3501 Polishing 2021-09-23 15:57:43 +02:00
Juergen Hoeller 208fafa4a3 Fix contract violations in ConcurrentReferenceHashMap's EntrySet/Iterator
Closes gh-27454
2021-09-23 15:56:49 +02:00
Juergen Hoeller 8f96ca4a2d Merge branch '5.3.x'
# Conflicts:
#	spring-context/spring-context.gradle
#	spring-core/src/main/java/org/springframework/core/ReactiveAdapterRegistry.java
2021-09-21 17:47:27 +02:00
Juergen Hoeller 1f8c233dfc Polishing 2021-09-21 17:43:03 +02:00
Juergen Hoeller eabe946a53 Skip readStream optimization for compatibility with misbehaving InputStreams
Closes gh-27429
2021-09-21 17:41:56 +02:00
Juergen Hoeller 3beb074278 Remove support for RxJava 1.x
Also removes unnecessary flowPublisherPresent check on JDK 9+, depending on Reactor presence for its JDK Flow adapter instead.

Closes gh-27443
2021-09-21 09:13:06 +02:00
Brian Clozel cce61c3918 Merge branch '5.3.x' 2021-09-17 15:30:16 +02:00
Brian Clozel a50537fbaf Polish "Fix collectionToDelimitedString failure for null elements."
Fixes gh-27419
2021-09-17 15:15:51 +02:00
Koy 0d6cc12274 Fix collectionToDelimitedString failure for null elements.
Prior to this commit, calling `StringUtils#collectionToDelimitedString`
would fail with an NPE if the collection contains null elements.

This commit ensures that null elements are converted as `"null"` in the
resulting String without failure.

See gh-27419
2021-09-17 15:15:26 +02:00
Juergen Hoeller d84ca2ba90 Jakarta EE 9 migration
Upgrades many dependency declarations; removes old EJB 2.x support and outdated Servlet-based integrations (Commons FileUpload, FreeMarker JSP support, Tiles).

Closes gh-22093
Closes gh-25354
Closes gh-26185
Closes gh-27423
See gh-27424
2021-09-17 09:14:07 +02:00
Juergen Hoeller b74e93807e Remove JDK 9 workarounds etc
See gh-17778
2021-09-17 08:58:19 +02:00
Juergen Hoeller cf2429b0f0 Remove support for deprecated Java SecurityManager (-> JDK 17 build compatibility)
Includes hard JDK 9+ API dependency in CGLIB ReflectUtils (Lookup.defineClass) and removal of OutputStream spy proxy usage (avoiding invalid Mockito proxy on JDK 17)

Closes gh-26901
2021-09-15 15:30:25 +02:00
Juergen Hoeller 3baacedfd9 Alignment with other abstract utils classes 2021-09-14 21:49:12 +02:00
Sam Brannen 18ee308e4e Delete obsolete Assume test utility 2021-09-14 10:58:38 +02:00
Phillip Webb 52b03e3326 Migrate CoroutinesUtils to Java
Migrate `CoroutinesUtils` from Kotlin code to Java and drop the
`kotlin-coroutines` module.

This update removes the need for Kotlin tooling IDE plugins to be
installed.

Closes gh-27379
2021-09-13 17:39:45 +02:00
Brian Clozel cecc0849a8 Upgrade to Gradle 7.2
This commit upgrades Gradle to 7.2.
Gradle configuration names are updated accordingly.
This also upgrades Gradle build plugins.

See gh-26870
2021-09-13 09:37:35 +02:00
Rossen Stoyanchev 41ab268733 Polishing contribution
See gh-27331
2021-09-09 17:00:00 +01:00
hantsy 1dc128361f Add SmallRye Mutiny adapters
Closes gh-26222
2021-09-09 16:43:08 +01:00
Juergen Hoeller 164dcef6ae Tracking ASM master
See gh-27069
2021-09-02 22:19:57 +02:00
Brian Clozel cc026fcb8a Polish "Optimize allocation in StringUtils#cleanPath"
This commit also introduces JMH benchmarks related to the code
optimizations.

Closes gh-2631
2021-08-30 18:26:51 +02:00
Daniel Knittl-Frank 8d3e8ca3a2 Optimize allocation in StringUtils#cleanPath
This commit applies several optimizations to StringUtils#cleanPath and
related methods:

* pre-size pathElements deque in StringUtils#cleanPath with
  pathElements.length elements, since this this is the maximum size and
  the most likely case.
* optimize StringUtils#collectionToDelimitedString to calculate the size
  of the resulting String and avoid array auto-resizing in the
  StringBuilder.
* If the path did not contain any components that required cleaning,
  return the (normalized) path as-is. No need to concatenate the prefix
  and the trailing path.

See gh-26316
2021-08-30 18:09:52 +02:00
Stephane Nicoll af6fd6c303 Polish "Fix duplicate "the" in Javadoc and XSD"
See gh-27291
2021-08-19 08:54:38 +02:00
Sanghyuk Jung ac72277258 Fix duplicate "the" in Javadoc and XSD
See gh-27291
2021-08-19 08:44:03 +02:00
Stephane Nicoll 31b651a114 Polish contribution
See gh-27248
2021-08-08 11:33:26 +02:00
Syuziko eaf9deedfd Polish tests
See gh-27248
2021-08-07 18:53:47 +02:00
Sam Brannen 915f1027a5 Update copyright date
See gh-27223
2021-07-29 11:04:59 +02:00
Mateusz Swiatkowski f1b35f1593
Fix reference to Optional.isPresent() in ObjectUtils.isEmpty()
Closes gh-27223
2021-07-29 11:03:26 +02:00
Sam Brannen 3ccbf1edeb Increase fudge factor in StopWatchTests 2021-06-30 10:43:52 +02:00
Sam Brannen a2ef6badc4 Use StringBuilder.append(char) where possible
To slightly improve performance, this commit switches to
StringBuilder.append(char) instead of StringBuilder.append(String)
whenever we append a single character to a StringBuilder.

Closes gh-27098
2021-06-25 10:44:28 +02:00
Sam Brannen ddbb7c1b5b Avoid use of Supplier in MergedAnnotationReadingVisitor.get 2021-06-24 16:41:28 +02:00
Sam Brannen 2bc7a3aa0a Implement equals, hashCode, & toString in BeanMethod and *Metadata types
Prior to this commit, ConfigurationClass implemented equals(),
hashCode(), and toString(), but BeanMethod did not.

This commit introduces equals(), hashCode(), and toString()
implementations in BeanMethod for consistency with ConfigurationClass
to make it possible to use BeanMethod instances to index additional
metadata as well.

In order to properly implement equals() in BeanMethod, the method
argument types are required, but these are not directly available in
BeanMethod. However, they are available via ASM when processing @Bean
methods. This commit therefore implements equals(), hashCode(), and
toString() in SimpleMethodMetadata which BeanMethod delegates to.

For completeness, this commit also implements equals(), hashCode(), and
toString() in StandardClassMetadata, StandardMethodMetadata, and
SimpleAnnotationMetadata.

Closes gh-27076
2021-06-24 16:41:28 +02:00
Sam Brannen 882004fc9b Fix bug in SimpleMethodMetadataReadingVisitor.Source.toString()
Prior to this commit, the toString() implementation did not separate
method argument types with a comma or any form of separator, leading
to results such as:

    org.example.MyClass.myMethod(java.lang.Stringjava.lang.Integer)

instead of:

    org.example.MyClass.myMethod(java.lang.String,java.lang.Integer)

Closes gh-27095
2021-06-24 16:41:28 +02:00
Sam Brannen 1bc236785c Polishing 2021-06-24 15:47:24 +02:00
Sam Brannen d469f6215d Polishing 2021-06-22 19:54:05 +02:00
Juergen Hoeller edf0343cfe Upgrade to ASM master (including early support for Java 18 bytecode)
Closes gh-27069
2021-06-22 15:26:35 +02:00
Sam Brannen 782d7169e4 Polish Javadoc for MethodMetadata 2021-06-21 18:04:37 +02:00