Commit Graph

24828 Commits

Author SHA1 Message Date
Juergen Hoeller 38c9e7f629 Polishing 2022-08-10 23:30:27 +02:00
Juergen Hoeller b31a15851e Support for pre-generated CGLIB proxy classes (in AOT scenarios)
Includes runtime storing of generated classes to a directory specified by the "cglib.generatedClasses" system property. Avoids lazy CGLIB fast-class generation and replaces generated Enhancer and MethodWrapper key classes with equivalent record types. Introduces support for early type determination in InstantiationStrategy, AopProxy and SmartInstantiationAwareBeanPostProcessor - in order to trigger CGLIB class generation in refreshForAotProcessing (through early determineBeanType calls for bean definitions).

Closes gh-28115
2022-08-10 23:30:19 +02:00
Stephane Nicoll 496b1879ab Merge branch '5.3.x' 2022-08-09 15:32:27 +02:00
Stephane Nicoll 22029b4487 Merge pull request #28944 from wilkinsona
* pr/28944:
  Correct description of @RequestParam with WebFlux

Closes gh-28944
2022-08-09 15:32:17 +02:00
Andy Wilkinson d6b60046ce Correct description of @RequestParam with WebFlux
See gh-28944
2022-08-09 15:30:08 +02:00
Stephane Nicoll 005713066c Freeze configuration before invoking MBDPP instances
This commit updates refresh for AOT processing so that the configuration
is frozen before invoking MergedBeanDefinitionPostProcessor instances.
This makes sure that post-processed MergedBeanDefinitions are kept in
cache and not lost if a component attempts to clear the metadata cache.

Closes gh-28941
2022-08-09 13:29:14 +02:00
Stephane Nicoll 0a9db7cc47 Revert "Make sure inferred destroy method is set on the original bean definition"
This reverts commit 2e1538a20b.
2022-08-09 11:31:56 +02:00
Stephane Nicoll cd2b7afc87 Avoid reflection on OptionalValidatorFactoryBean
Closes gh-28939
2022-08-08 16:53:53 +02:00
Stephane Nicoll 2e1538a20b Make sure inferred destroy method is set on the original bean definition
This commit updates InitDestroyAnnotationBeanPostProcessor to mutate
the original bean definition rather than the merged one that can be
recreated without it if the cache gets stale.

See gh-28215
2022-08-08 14:33:00 +02:00
Stephane Nicoll 3c76437868 Update RegisteredBean to take a ConfigurableListableBeanFactory
This allows to have access to `getBeanDefinition` if the original
bean definition needs to be retrieved.

See gh-28936
2022-08-08 14:00:49 +02:00
Stephane Nicoll 832889d801 Polish 2022-08-08 11:31:38 +02:00
Sam Brannen a875db4692 Document limitations of @CompileWithTargetClassAccess
Specifically, @CompileWithTargetClassAccess cannot be used with
@RepeatedTest and @ParameterizedTest methods since the
CompileWithTargetClassAccessExtension cannot support @TestTemplate
invocations.
2022-08-06 14:57:35 +03:00
Sam Brannen 1e8bc1b0fb Polishing 2022-08-06 14:42:19 +03:00
Sam Brannen 7d364bba72 Clean up warnings 2022-08-06 14:41:54 +03:00
Sam Brannen 0944c9a99c Remove `throws IOException` from DefaultGenerationContext.writeGeneratedContent()
The `throws` declaration is unnecessary since writeGeneratedContent()
will never throw an IOException.
2022-08-06 14:34:04 +03:00
Sam Brannen a466179bc8 Polish and sync TestGenerationContext implementations
- new constructor for providing InMemoryGeneratedFiles
- writeGeneratedContent() now throws UncheckedIOException
2022-08-06 14:08:49 +03:00
Sam Brannen 1de0207874 Rename tests due to change in gh-28927 2022-08-05 13:59:14 +03:00
Sam Brannen 853407b6f8 Polishing 2022-08-05 13:57:28 +03:00
Stephane Nicoll 2cc4486e3d Rename ApplicationContextAotGenerator entry point
Closes gh-28927
2022-08-05 10:19:06 +02:00
Stephane Nicoll 2475523e19 Merge branch '5.3.x' 2022-08-05 10:10:16 +02:00
Stephane Nicoll 6685e78c36 Deprecate NestedIOException
NestedIOException has been removed in Spring Framework 6 and this commit
marks it as deprecated in 5.x. Users that were relying on this exception
should use IOException directly.

Closes gh-28929
2022-08-05 10:04:47 +02:00
Stephane Nicoll 9264d97880 Restore GeneratedTypeReference
Closes gh-28926
2022-08-04 16:30:59 +02:00
Vedran Pavic 7e719fe3f8 Use Jakarta EE XML namespaces instead of Java EE
Closes gh-28903
2022-08-04 13:24:30 +02:00
Sam Brannen 31503df415 Fix Javadoc link syntax plus polishing 2022-08-04 13:52:40 +03:00
Johnny Lim 9fea0be33e Upgrade to Dokka Gradle plugin 1.7.10
Closes gh-28912
2022-08-04 11:37:04 +02:00
Brian Clozel fea29ea4cd Upgrade Gradle plugins 2022-08-04 11:29:34 +02:00
Brian Clozel 9e71889ed9 Merge branch '5.3.x' 2022-08-04 11:02:52 +02:00
Chanhyeong Cho 8685b2f5bf Fix broken kdoc-api links in kotlin.adoc
Fixes gh-28908
2022-08-04 11:02:02 +02:00
Sam Brannen 843221b448 Fix broken Javadoc links
See gh-28906
2022-08-04 11:51:56 +03:00
Stephane Nicoll 6c81ac9454 Merge branch '5.3.x' 2022-08-04 10:04:00 +02:00
Stephane Nicoll 4af225405c Upgrade Java 18 version in CI image 2022-08-04 10:02:49 +02:00
Stephane Nicoll 51e594ae81 Upgrade Java 17 version in CI image 2022-08-04 10:02:15 +02:00
Stephane Nicoll c2554b2b27 Upgrade Java 11 version in CI image 2022-08-04 10:01:49 +02:00
Stephane Nicoll 86a762b5ee Upgrade Java 8 version in CI image 2022-08-04 10:01:23 +02:00
Stephane Nicoll 211241befe Upgrade Ubuntu version in CI image 2022-08-04 10:00:30 +02:00
Stephane Nicoll e50db8c8c5 Make sure that ImportAwareAotBeanPostProcessor has role infrastructure
See gh-28915
2022-08-04 09:37:17 +02:00
Stephane Nicoll 332d4a4c9c Apply same order than original BPP
This commit updates ImportAwareAotBeanPostProcessor to be priority
ordered, with the same order as its original BeanPostProcessor. This
makes sure that infrastructure beans can be post-processed if
necessary

See gh-28915
2022-08-04 09:35:11 +02:00
Stephane Nicoll e5f9574800 Fix test
Contribution was not applied on the actual use case

See gh-28915
2022-08-04 09:32:45 +02:00
Brian Clozel 34266f22c7 Merge branch '5.3.x' 2022-08-03 23:16:13 +02:00
Brian Clozel 0caa2ac696 Customize connection in UrlResource getInputStream
Prior to this commit, the `AbstractFileResolvingResource` would
provide a default implementation for `customizeConnection` which only
sets the HTTP request method as "HEAD".
While this is consistent with its usage within that class (in
`exists()`, `contentLength()` or `lastModified()`), this is not opened
for general usage by sub-classes.

`UrlResource` is an example of that, where its `getInputStream()` method
does not call this customization method.

This not only prevents implementations from calling
`customizeConnection` in various cases, but it also misleads developers
as they might think that customizations will be applied automatically.

This commit ensures that `customizeConnection` is called in all relevant
places and that the configuration of the HTTP method is instead done in
each method as it is use case specific.

Fixes gh-28909
2022-08-03 23:13:52 +02:00
Sam Brannen 855a3e5221 Polish ContextLoader support 2022-08-03 18:37:54 +03:00
Sam Brannen e3f4d810f6 Revise configurable refresh support in SmartContextLoader SPI
This commit revises 903e9f2a02 based on feedback from the Spring Boot
team.

- The original loadContext(MergedContextConfiguration) method is no
  longer deprecated.

- loadContext(MergedContextConfiguration, boolean) has been replaced by
  loadContextForAotProcessing(MergedContextConfiguration) which is
  implemented as a `default` method that throws an
  UnsupportedOperationException.

- Affected code has been refactored to adjust to these changes.

See gh-28906
2022-08-03 16:54:32 +03:00
Stephane Nicoll 3a890033b7 Fix custom bean definition to stop using reflection
See gh-28915
2022-08-03 14:51:52 +02:00
Sam Brannen 903e9f2a02 Introduce configurable refresh support in SmartContextLoader SPI
Prior to this commit, the contract of the loadContext() method in the
SmartContextLoader SPI required that the ApplicationContext be returned
in a fully refreshed state with a JVM shutdown hook registered for it.

However, in order to support AOT processing within the Spring
TestContext Framework (TCF), we need a way to signal to
SmartContextLoader implementations that they should load the test's
ApplicationContext without refreshing it or registering a JVM shutdown
hook.

To address this issue, this commit:

- Introduces a new loadContext(MergedContextConfiguration, boolean)
  method. The boolean `refresh` flag controls whether the returned
  ApplicationContext should be refreshed and have a JVM shutdown hook
  registered for it.

- Deprecates the existing loadContext(MergedContextConfiguration)
  method in favor of loadContext(MergedContextConfiguration, boolean).

- Removes all use of the deprecated method within the spring-test
  module, excluding the exception mentioned below.

Note that loadContext(MergedContextConfiguration, boolean) is
implemented as an interface `default` method which delegates to the
deprecated loadContext(MergedContextConfiguration) method for backward
compatibility. When migrating a SmartContextLoader to Spring Framework
6.0, implementations that directly implement the SmartContextLoader SPI
(instead of extending AbstractGenericContextLoader or
AbstractGenericWebContextLoader) will need to override the new
loadContext(MergedContextConfiguration, boolean) method in order to
honor the `refresh` flag for AOT processing support. See the
implementation in AbstractGenericContextLoader for an example of how
this can be achieved.

Closes gh-28906
2022-08-03 13:10:35 +03:00
Stephane Nicoll dcad3beeb9 Polish 2022-08-03 11:03:28 +02:00
Stephane Nicoll c9faff7491 Apply property hints to FactoryBean if necessary
This commit handles a BeanDefinition that configures the FactoryBean
as the "beanClass", while exposing the actual type in "resolvedType".
While unusual, this is required in certain cases when the factory
bean exposes generic information itself.

Previously, the hints for properties injection were applied on the
user type.

Closes gh-28913
2022-08-03 10:58:41 +02:00
Stephane Nicoll e79a8f6733 Polish 2022-08-03 10:53:57 +02:00
Stephane Nicoll 1fdd91eb30 Restore order of setImportMetadata in AOT optimized contexts
This commit adapts the generated code for handling ImportAware to
register a bean definition rather than adding the BeanPostProcessor
directly on the beanFactory. The previous arrangement put the
post processor handling import aware callbacks first on the list,
leading to inconsistent callback orders.

Tests have been adapted to validate this exact scenario.

Closes gh-28915
2022-08-03 10:16:20 +02:00
Stephane Nicoll 058b5fef6b Merge branch '5.3.x' 2022-08-02 16:11:16 +02:00
Stephane Nicoll 4eb8a5c082 Merge pull request #28914 from izeye
* pr/28914:
  Fix Javadoc since for new modules() and modulesToInstall()

Closes gh-28914
2022-08-02 16:11:04 +02:00