Commit Graph

24828 Commits

Author SHA1 Message Date
danthonywalker 50771237cc Fix ListableBeanFactory#findAnnotationOnBean extension return type
Closes gh-26908
2022-03-15 18:33:35 +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 4db2f8ea1b Remove obsolete Nashorn-based scripting tests
Since the Nashorn JavaScript engine was removed in Java 15, these tests
will never be run on a Java 17+ JDK which is required as of Spring
Framework 6.0.

See gh-27919
2022-03-15 16:33:52 +01:00
Stephane Nicoll e9655e8a7b Merge branch '5.3.x' 2022-03-15 16:04:38 +01:00
Stephane Nicoll a683e9e81b Upgrade to Reactor 2020.0.17
Closes gh-28064
2022-03-15 16:00:48 +01:00
Sam Brannen 5598f99816 Merge branch '5.3.x' 2022-03-14 20:27:05 +01:00
Sam Brannen 6e2e45d18f Apply @SafeVarargs to ManagedMap.ofEntries(...) 2022-03-14 20:24:57 +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 2ab871fbc3 Merge branch '5.3.x' 2022-03-12 18:16:26 +01:00
Sam Brannen 887389d341 Clarify behavior for generics support in BeanUtils.copyProperties()
Since Spring Framework 5.3, BeanUtils.copyProperties() honors generics
in the source and target property types (see gh-24187); however, this
refinement of the contract was not properly documented prior to this
commit. In addition, the refinement can be a breaking change for users
who were relying on the previous unreliable behavior.

This commit therefore clarifies the behavior for generics support in
BeanUtils.copyProperties() and introduces a table of example matches
and mismatches when generics are involved.

Closes gh-27259
2022-03-12 18:12:23 +01:00
Sam Brannen c249b578b5 Merge branch '5.3.x' 2022-03-12 16:05:39 +01:00
Sam Brannen d9c22e657f Document the effect of @DirtiesContext on test execution events
See gh-27757
2022-03-12 16:05:14 +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 672555a568 Add support of init and destroy methods
This commit updates InitDestroyBeanPostProcessor so that it contributes
init or destroy method names to the `RootBeanDefinition`. This is then
used by the generator to provide these methods to the optimized AOT
context.

Invocation of those init methods still happen using reflection so
dedicated hints are contributed for them.

Closes gh-28151
2022-03-12 13:35:56 +01:00
Stephane Nicoll 1b7892c559 Merge pull request #28171 from izeye
* pr/28171:
  Add Javadoc since for GenericApplicationContext.refreshForAotProcessing()

Closes gh-28171
2022-03-12 11:42:49 +01:00
izeye 2a9a1f1c3a Add Javadoc since for GenericApplicationContext.refreshForAotProcessing()
See gh-28171
2022-03-12 11:42:36 +01:00
Stephane Nicoll 7be6816129 Merge branch '5.3.x' 2022-03-11 16:22:18 +01:00
Stephane Nicoll 9eec6d0834 Start building against Reactor 2020.0.17 snapshots
See gh-28064
2022-03-11 16:18:28 +01:00
Arjen Poutsma 66d758d677 Downgrade Tomcat to 10.0.14
This commit downgrades Tomcat from 10.0.17 to 10.0.14. Later versions
will result in timeouts in MultipartIntegrationTests.
2022-03-11 12:53:17 +01:00
Arjen Poutsma 5abaf20a74 Merge branch '5.3.x' 2022-03-11 12:22:39 +01:00
Arjen Poutsma a3e23cd5fc Fix unwrapping logic for ResponseEntity<Flux>
This commit makes sure that the response returned by coroutine handler
methods that return ResponseEntity<Flux> is unwrapped correctly.

Closes gh-27809
2022-03-11 11:56:13 +01:00
Sam Brannen 0e7c7b444c Merge branch '5.3.x' 2022-03-10 19:28:51 +01:00
Sam Brannen af977c0891 Improve documentation for @EnabledIf and @DisabledIf test support
Closes gh-28157
2022-03-10 19:27:41 +01:00
Stephane Nicoll 1742e121e7 Update bean registration contribution tests to use TestCompiler 2022-03-10 16:06:52 +01:00
Stephane Nicoll 93a2651417 Make sure method injection handles ambiguous signatures
This commit updates InjectionGenerator to request a resolved attribute
with a dedicated type if multiple methods with the same name and the
same number of arguments exist. This was previously done already for
constructors and this commit harmonizes the algorithms to methods as
well

Closes gh-28154
2022-03-10 15:34:53 +01:00
Arjen Poutsma f3181dc583 Upgrade to Tomcat 10.0.17
This commit upgrades to Tomcat 10.0.17, hopefully fixing multipart
integration tests as a result.
2022-03-10 14:43:33 +01:00
Stephane Nicoll a0061b7fb9 Remove cast on AbstractFactoryBean
Closes gh-28153
2022-03-10 11:50:24 +01:00
Stephane Nicoll 4184294835 Merge branch '5.3.x' 2022-03-10 10:10:57 +01:00
Stephane Nicoll 1bbcd706be Upgrade Ubuntu version in CI image 2022-03-10 10:09:55 +01:00
Stephane Nicoll 67b7c16bc0 Fix visibility of DefaultSockJsSchedulerContainer
Closes gh-28146
2022-03-09 16:38:10 +01:00
Stephane Nicoll 9809752c3c Stop generating unnecessary reference to field type
This commit updates the generator to stop specifying a field type when
reflection is necessary, or when a reference to a field should be
retrieved as its name alone suffices.

This could trigger package protected issues if the field type is not
public.

See gh-28047
2022-03-09 11:17:21 +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 9b07457d06 Introduce ApplicationContextAotGenerator
This commit introduces a way to process a GenericApplicationContext
ahead of time. Components that can contribute in that phase are
invoked, and their contributions are recorded in the
GeneratedTypeContext.

This commit also expands BeanFactoryContribution so that it can exclude
bean definitions that are no longer required.

Closes gh-28150
2022-03-09 11:17:21 +01:00
Stephane Nicoll 30cd14d61d Add module to support testing of generated code
Closes gh-28120
2022-03-09 11:17:21 +01:00
Stephane Nicoll b5695b9248 Add support for refreshing a GenericApplicationContext for AOT
This commit adds a way to refresh a GenericApplicationContext for ahead
of time processing: refreshForAotProcessing() processes the bean factory
up to a point where it is about to create bean instances.

MergedBeanDefinitionPostProcessor implementations are the only bean
post processors that are invoked during this phase.

Closes gh-28065
2022-03-09 11:17:21 +01:00
Stephane Nicoll 7255a8b48e Polish "Add module to support testing of generated code"
See gh-28120

Co-authored-by: Andy Wilkinson <wilkinsona@vmware.com>
2022-03-09 11:17:21 +01:00
Stephane Nicoll 9ba927215e Add support for ImportAware callback
This commit adds a way for a BeanFactoryPostProcessor to participate to
AOT optimizations by contributing code that replaces its runtime
behaviour.

ConfigurationClassPostProcessor does implement this new interface and
computes a mapping of the ImportAware configuration classes. The mapping
is generated for latter reuse by ImportAwareAotBeanPostProcessor.

Closes gh-2811
2022-03-09 11:17:21 +01:00
Phillip Webb 653dc5951d Add module to support testing of generated code
Add a new unpublished `spring-core-test` module to support testing of
generated code. The module include a `TestCompiler` class which can be
used to dynamically compile generated Java code. It also include an
AssertJ friendly `SourceFile` class which uses qdox to provide targeted
assertions on specific parts of a generated source file.

See gh-28120
2022-03-09 11:17:21 +01:00
Stephane Nicoll ec6a19fc6b Add BeanFactoryContribution for bean registrations
This commits adds an implementation that takes care of contributing
code for each bean definition in the bean factory, invoking
BeanRegistrationContributionProvider to determine the best candidate to
use.

Closes gh-28088
2022-03-09 11:17:21 +01:00
Stephane Nicoll 5bc701d4fe Introduce BeanFactoryContribution
This commit introduces an infrastructure to contribute generated code
ahead of time to initialize a BeanFactory. Code and hints can be
contributed to a BeanFactorInitialization, with the ability to write to
other packages if necessary.

An implementation of that new interface that registers a BeanDefinition
is also included in this commit. It delegates to a
BeanInstantiationGenerator for geenerating the instance supplier that
creates the bean instance.

For corner cases, a BeanRegistrationContributionProvider can be
implemented. It allows to return a custom BeanFactoryContribution for
a particualr bean definition. This usually uses the default
implementation with a custom instance supplier.

Note that this commit adds an temporary executable resolution that is
meant to be replaced by the use of ConstructorResolver

See gh-28088
2022-03-09 11:17:21 +01:00
Stephane Nicoll cc57b55c61 Expose a way to resolved a merged inner bean definition
This commit extracts the logic of resolving a merged bean definition for
an inner bean to a public method so that other components can reuse it.

Closes gh-28093
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
Stephane Nicoll c541bde513 Simplify the generation of inner bean definitions
See gh-28047
2022-03-09 11:17:21 +01:00
Stephane Nicoll 97986b368a Harmonize use of generate
This commit harmonizes the use of the "generate" keyword for anything
related to code generation. Previously, there was a mix of "generate"
and "write."

See gh-28047
2022-03-09 11:17:21 +01:00
Stephane Nicoll ea19b92deb Clarify the scope of AotContributingBeanPostProcessor
This commit updates AotContributingBeanPostProcessor so that it
explicitly extends from PriorityOrdered. This makes it more apparent
that AOT contributing bean post processors are meant to be invoked
early with the regular runtime, and shouldn't be post-processed
themselves.

See gh-28047
2022-03-09 11:17:20 +01:00