Commit Graph

24987 Commits

Author SHA1 Message Date
Sébastien Deleuze f6db2cc35f Use serializerOrNull in Kotlin Serialization support
Closes gh-29068
2022-09-04 16:05:37 +02:00
Sam Brannen ef7784f85e Register runtime hints for @TestPropertySource#locations
This commit introduces automatic registration of runtime hints for
classpath resources configured via the `locations` attribute in
@TestPropertySource as well as for detected default properties files.

Closes gh-29025
2022-09-04 15:19:56 +02:00
Sam Brannen dcf160e427 Consistently include leading slash for classpath: resources in the TCF 2022-09-04 15:19:56 +02:00
Sam Brannen 920fbb34c8 Register runtime hints for @ContextConfiguration#locations
This commit introduces automatic registration of runtime hints for
classpath resources configured via the `locations` attribute in
@ContextConfiguration.

Closes gh-29021
2022-09-03 17:25:46 +02:00
Sam Brannen c0040b9024 Polishing 2022-09-03 17:25:00 +02:00
Sam Brannen 36a2a62294 Polishing 2022-09-03 16:55:28 +02:00
Andy Wilkinson 0daaa1c38a Make QDox an implementation detail of spring-core-test
Previously, com.thoughtworks.qdox:qdox was declared as an api
dependency of spring-core-test despite it only being used in the
module's internals. This resulted in it unnecessarily appearing on the
compile classpath of consuming projects.

This commit moves qdox to be an implementation dependency, removing it
from the compile classpath of consuming projects but ensuring that it's
still available at runtime.

Closes gh-29066
2022-09-03 16:45:05 +02:00
Sébastien Deleuze f50c301387 Change BindingReflectionHintsRegistrar package
Move it to org.springframework.aot.hint.

See gh-28979
2022-09-02 19:31:26 +02:00
Brian Clozel 7ace1f9dc5 Align RuntimeHintsPredicates with new FieldMode
Closes gh-29063
2022-09-02 18:16:43 +02:00
Brian Clozel 4368e2563f Reinstate RuntimeHintsAgent tests
Closes gh-29062
2022-09-02 18:16:43 +02:00
Sébastien Deleuze 044f3728a3 Introduce @RegisterReflectionForBinding
This annotation and the related processor allows to
register reflection hints for data binding purpose
(class, fields, properties, record components for
the whole type hierarchy)

Closes gh-28979
2022-09-02 17:31:43 +02:00
Sébastien Deleuze aaffb8b27e Move BindingReflectionHintsRegistrar to spring-core
See gh-28979
2022-09-02 17:31:43 +02:00
Sam Brannen 6475523a53 Merge branch '5.3.x' 2022-09-02 16:42:07 +02:00
Sam Brannen 0389fcca7e Fix sporadically failing SpEL test 2022-09-02 16:41:44 +02:00
Sébastien Deleuze cc555d2ff4 Avoid shipping AWT classes in native images
This commit provides an alternative
java.beans.Introspector#findCustomizerClass implementation
via a GraalVM substitution that avoids to include thousands
of unused AWT classes in the native image.

Closes gh-29060
2022-09-02 15:06:50 +02:00
Sam Brannen cced3cba09 Register runtime hints for @TestExecutionListeners
Closes gh-29024
2022-09-02 14:53:49 +02:00
Sam Brannen 34635d7751 Register runtime hints for TestContextBootstrappers
This commit automatically registers runtime hints for
TestContextBootstrapper classes, including default bootstrappers as
well as any bootstrapper configured via @BootstrapWith.

Closes gh-29023
2022-09-02 14:40:09 +02:00
Sam Brannen 1cae054cf5 Polishing 2022-09-02 14:27:58 +02:00
Sam Brannen 549f4e7933 Register runtime hints for ApplicationContextInitializers in the TCF
This commit introduces automatic registration of runtime hints for
ApplicationContextInitializers configured via the `initializers`
attribute in @ContextConfiguration.

See gh-29021
2022-09-02 14:20:22 +02:00
Sam Brannen 51daeac86b Register runtime hints for ContextLoaders automatically in the TCF
This commit moves the registration of runtime hints for ContextLoaders
from TestContextRuntimeHints to TestContextAotGenerator.

This allows for automatic registration of any ContextLoader used,
including custom loaders declared via the `loader` attribute in
@ContextConfiguration.

See gh-29021
2022-09-02 14:20:11 +02:00
Sam Brannen 41b6f4e351 Commit changes to test 2022-09-02 13:17:48 +02:00
Sam Brannen 52712cecce Document reasons for hint registration in the TestContext framework 2022-09-02 13:15:32 +02:00
Sam Brannen dadfdb91d9 Stop registering SynthesizedAnnotation proxies in spring-test
See gh-29059
2022-09-02 13:10:18 +02:00
Sam Brannen 69f23095b8 Deprecate SynthesizedAnnotation and related methods
Since Spring no longer adds the SynthesizedAnnotation interface to the
JDK dynamic proxy used to synthesize an annotation, this commit
officially deprecates SynthesizedAnnotation and related methods in
RuntimeHintsUtils.

See gh-29041, gh-29054
Closes gh-29053
2022-09-02 12:04:17 +02:00
Sam Brannen 0ec03a8dd6 Stop implementing SynthesizedAnnotation in annotation proxies
SynthesizedAnnotation was originally introduced as a convenience for
easily detecting if an annotation had been synthesized by Spring via a
simple `if (myAnnotation instanceof SynthesizedAnnotation)` check.

However, the introduction of SynthesizedAnnotation in the JDK dynamic
proxy for a synthesized annotation results in a separate proxy class
for each annotation synthesized by Spring, and this causes issues with
GraalVM native images since users and framework developers must always
ensure that the additional proxy classes are registered.

This commit completely removes the use of SynthesizedAnnotation in
synthesized annotation proxies. This change allows the proxy class for
an annotation to be reused for a synthesized annotation of the same
annotation type.

Consequently:

- Extra proxy classes are not generated on the JVM or in a native image.
- Extra proxy classes are not required to be registered for a native image.

Closes gh-29041
2022-09-02 11:27:00 +02:00
Sébastien Deleuze 7214b1e03c Merge branch '5.3.x' 2022-09-02 11:19:55 +02:00
junsu bb3ada4a67 Fix Kotlin Serialization converter registration logic
This commit fixes Kotlin Serialization converter
registration logic in RestTemplate,
AbstractMessageBrokerConfiguration and
AllEncompassingFormHttpMessageConverter classes
to be similar to the one in
WebMvcConfigurationSupport.

Closes gh-29008
2022-09-02 11:17:51 +02:00
Brian Clozel fc47d25bc7 Polish
See gh-26320
2022-09-02 10:55:40 +02:00
Sam Brannen 73abd58202 Polishing 2022-09-02 10:23:53 +02:00
Phillip Webb 505da5c602 Migrate hint registration to shortcuts
Migrate code to make use of the `MemberCategory` and `FieldMode`
shortcuts.

See gh-29011
2022-09-01 17:26:06 -07:00
Phillip Webb bc0bf1fac3 Add additional shortcuts for hint registration
Add `MemberCategory` and `FieldMode` shortcuts for type registration.
Helper `builtWith` methods have also been extracted to the Hint types
to allow general reuse (for example with `registerTypes`).

See gh-29011
2022-09-01 17:25:46 -07:00
Phillip Webb da1005cd66 Add FieldMode for field hints and ensure that it cannot be downgraded
Add a `FieldMode` enum analogous to `ExecutableHint` and update
`FieldHint` to ensure that registration cannot downgrade `WRITE`
to `READ`.

Fixes gh-29055
2022-09-01 17:25:43 -07:00
Phillip Webb 0bd923b0a7 Polishing 2022-09-01 16:28:02 -07:00
Phillip Webb cea06e6a9e Polish ReflectionHints and TypeHint method order 2022-09-01 16:27:54 -07:00
Phillip Webb cfd37d948d Reduce visibility of hint factory methods
Reduce the visibility of hint factory methods that return a `Builder`.
Since the `build()` method of the `Builder` is package-private the
factory methods can also be package-private.
2022-09-01 13:37:08 -07:00
Sam Brannen a5584dcaa6 Merge branch '5.3.x'
# Conflicts:
#	spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsTests.java
2022-09-01 17:44:24 +02:00
Sam Brannen 66b9a52cec Suppress warning in test 2022-09-01 17:39:15 +02:00
Sam Brannen 6a68bd58f9 Introduce AnnotationUtils.isSynthesizedAnnotation(Annotation)
Since SynthesizedAnnotation will be deprecated (and potentially
completely removed) in Spring Framework 6.0, this commit introduces
AnnotationUtils.isSynthesizedAnnotation(Annotation) in 5.3.x to allow
people to migrate away from relying on SynthesizedAnnotation.

Closes gh-29054
2022-09-01 17:35:22 +02:00
Sam Brannen b1414bf15b Polishing 2022-09-01 17:23:04 +02:00
Brian Clozel 289d378aeb Polish
This fixes an additional case where invoked methods are public but the
declaring class is package private.

Fixes gh-29046
2022-09-01 15:14:58 +02:00
Brian Clozel c470262c8e Rewrite ConcurrentLruCache implementation
Prior to this commit, the `ConcurrentLruCache` implementation would not
perform well under certain conditions. As long as the cache capacity was
not reached, the cache would avoid maintaining an eviction queue
(reordering entries depending with least/most recently read). When the
cache capacity was reached, the LRU queue was updated for each
read/write operation. This decreased performance significantly under
contention when the capacity was reached.

This commit completely rewrites the internals of `ConcurrentLruCache`.
`ConcurrentLruCache` is now a specialized version of the
`ConcurrentLinkedHashMap` [1]. This change focuses on buferring read and
write operations, only processing them at certain times to avoid
contention.

When a cached entry is read, a read operation is queued and buffered
operations are drained if the buffer reached a fixed limit. When a new
cache entry is added or removed, a write operation is queued and
triggers a drain attempt. When the capacity is outgrown, the cache polls
items from the eviction queue, which maintains elements with the
least recently used ones first. Entries are removed until the capacity
is under control.

The behavior described here and the buffer sizes are optimized with the
number of available processors in mind. Work is localized as much as
possible on a per-thread basis to avoid contention on the eviction queue.

The new implementation has been tested with the JMH benchmark provided
here, comparing the former `COncurrentLruCache`, the new implementation
as well as the `ConcurrentLinkedHashMap` [1].

When testing with a cache reaching capacity, under contention, with a
10% cache miss, we're seeing a 40x improvement compared to the previous
implementation and performance on par with the reference.
See [2] for how to replicate the benchmark.

[1] https://github.com/ben-manes/concurrentlinkedhashmap
[2] https://github.com/spring-projects/spring-framework/wiki/Micro-Benchmarks

Closes gh-26320
2022-08-31 19:10:50 +02:00
Johnny Lim 706c1ec8dd Polish 2022-08-31 23:59:51 +09:00
Sam Brannen 2ecc37fbef Reintroduce exclusion of dom4j for findbugs
The removal of the exclusion prevented spring-webmvc from being imported
into Eclipse IDE due to conflicting versions of dom4j on the classpath.

See gh-29045
2022-08-31 16:35:13 +02:00
Sam Brannen b22d01f5f3 Polish TestContextRuntimeHints 2022-08-31 16:35:13 +02:00
Sam Brannen 40647bdaf6 Register hints for test execution event annotations in the TCF
See gh-29044
2022-08-31 16:35:13 +02:00
Sam Brannen 2d35bbd74e Move TestContextRuntimeHints to aot.hint package 2022-08-31 16:35:13 +02:00
Sam Brannen 98c74059e0 Polish Javadoc 2022-08-31 16:35:13 +02:00
Brian Clozel 5757429ea5 Upgrade Mockito to 4.7.0 2022-08-31 16:24:15 +02:00
Brian Clozel fa475d0b63 Upgrade kotlinx dependencies 2022-08-31 16:23:53 +02:00
Brian Clozel 7cb1a4e876 Upgrade to Reactor 2022.0.0-M5 2022-08-31 16:23:14 +02:00