Commit Graph

25945 Commits

Author SHA1 Message Date
Juergen Hoeller 0f8ca805e1 Move hints to dedicated top-level package (avoiding aot<->support cycle)
See gh-29026, gh-29069
2022-10-11 15:34:30 +02:00
Juergen Hoeller 4bb2e23239 Resolve CGLIB core<->transform package cycle
See gh-28955
2022-10-11 15:34:07 +02:00
Stephane Nicoll 45939720f2 Add native support for @ExceptionHandler
This commit makes sure that `@ExceptionHandler`-annotated methods can be
invoked via reflection in a native image. As most of the handling of
the parameter and the return type is shared with our generic
RequestMapping handling, the ReflectiveProcessor extends from it.

An `@ExceptionHandler`-annotated method can return a `ProblemDetail`. If
that's the case, reflection entries are contributed.

Closes gh-29297
2022-10-11 10:18:23 +02:00
Juergen Hoeller c94b676576 Specifically handle "java."/"javax." packages in SpringNamingPolicy
Closes gh-27622
2022-10-10 21:50:26 +02:00
Brian Clozel fbb8cdb948 Upgrade to Context Propagation 1.0.0-RC1
Closs gh-29273
2022-10-10 21:34:09 +02:00
Brian Clozel ac8c36a5c8 Upgrade to Micrometer 1.10.0-RC1
Closes gh-29241
2022-10-10 21:32:53 +02:00
Johnny Lim d4a08dae43 Fix typos in CorsConfiguration[Tests]
Closes gh-29292
2022-10-10 19:27:41 +02:00
Sam Brannen f00e4b230f Support method chaining in AbstractAotProcessor.Settings
See gh-29266
2022-10-10 19:09:41 +02:00
Sam Brannen 7ed42ca4ca Polish ContextAotProcessor 2022-10-10 18:58:27 +02:00
Sam Brannen cad7444afa Introduce Settings container in AbstractAotProcessor
See gh-29266
2022-10-10 18:58:27 +02:00
Sébastien Deleuze 7b4ff5ea74 Make BindingReflectionHintsRegistrar protected methods private
In order to keep the maximum of flexibility, this commit makes
shouldSkipType and shouldSkipMembers methods private.

That will allow for example to refactor
BindingReflectionHintsRegistrar in order to support skipping
custom classes specified via @RegisterReflectionForBinding
without having to subclass it.

See gh-29279
2022-10-10 18:18:36 +02:00
Stephane Nicoll 4eca87baa3 Handle hints for CGLIB proxies consistently
This commit makes sure that hints are registered for CGLIB proxies even
if the proxy itself is not created. This typically happens when AOT runs
on an existing classpath, and a previous run already created the proxy.

Closes gh-29295
2022-10-10 17:39:26 +02:00
Stephane Nicoll e8ce86a6f0 Relocate testfixtures 2022-10-10 17:36:11 +02:00
Juergen Hoeller a1daaf0c19 Revise CGLIB naming policy to only contain SpringCGLIB label once
See gh-29295
2022-10-10 17:34:31 +02:00
Sam Brannen de609e5d45 Polishing 2022-10-10 16:52:22 +02:00
Juergen Hoeller 26c6a742d9 Introduce setLoadedClassHandler method on CGLIB ReflectUtils
See gh-29295
2022-10-10 16:49:55 +02:00
Sam Brannen b2b3163fae Redesign AOT processors for consistency and simplification
There's currently a considerable amount of overlap between the
implementations of AotProcessor and TestAotProcessor. In addition
AotProcessor is abstract and does not include a main() method; whereas,
TestAotProcessor is concrete and does include a main() method.

To address these issues, this commit:

- Introduces an AbstractAotProcessor base class that AotProcessor and
  TestAotProcessor now both extend

- Moves common properties/functionality to AbstractAotProcessor

- Renames AotProcessor to ContextAotProcessor

- Makes TestAotProcessor abstract like ContextAotProcessor

- Removes the main() method from TestAotProcessor

Closes gh-29266
2022-10-10 16:27:04 +02:00
Stephane Nicoll 061fa475ee Avoid generated code in the javax package
This commit updates the existing logic to also exclude code generation
in the javax package.

Closes gh-29123
2022-10-10 15:09:00 +02:00
Stephane Nicoll 76e87ad475 Polish 2022-10-10 15:09:00 +02:00
Sam Brannen 34e5aac0f5 Reintroduce factory method name in exception thrown from SimpleInstantiationStrategy 2022-10-10 14:28:35 +02:00
Arjen Poutsma 8227032a0f Improve exception message if MultipartParser can not find end of body
This commit improves the exception message thrown by MultipartParser
when it cannot find the end of the multipart body, by showing in the
message what the parser is looking for (CRLF--<boundary>).

Closes gh-28067
2022-10-10 13:26:46 +02:00
Sébastien Deleuze 8ed1906f43 Refine SQLErrorCodesFactory reachability on native images
SQLErrorCodeSQLExceptionTranslator#USER_PROVIDED_ERROR_CODES_FILE_PRESENT
evaluation at build time combined with the lazy
SQLErrorCodesFactory#instance initialization allow to
avoid making SQLErrorCodesFactory constructor reachable
when no custom sql-error-codes.xml is provided.

Closes gh-29294
2022-10-10 12:11:19 +02:00
Sébastien Deleuze 42c3ac64ff Remove spring.spel.ignore and spring.xml.ignore flags
This commit also removes ResourcePropertiesPersister which
was introduced in 5.3 specifically for spring.xml.ignore
flag and which is expected to be used only internally by
Spring Framework. DefaultPropertiesPersister should be used
instead.

Closes gh-29277
2022-10-10 12:11:19 +02:00
Sam Brannen bca35dc0a2 Generate direct mappings from AOT initializers to test classes
See gh-29289
2022-10-10 12:09:17 +02:00
Arjen Poutsma 3e33912624 Deprecate streaming mode in DefaultPartHttpMessageReader
This commit deprecates the streaming mode of
DefaultPartHttpMessageReader, in favor of PartEvent and
PartEventHttpMessageReader.

Closes gh-29293
2022-10-10 11:49:30 +02:00
Sam Brannen be70b675c6 Polishing 2022-10-10 11:01:04 +02:00
Sam Brannen 69e4cc5576 Ensure context caching works properly during AOT runtime in the TCF
Prior to this commit, the AOT runtime support in the Spring TestContext
Framework (TCF) relied on the MergedContextConfiguration for a given
test class being the same as during the AOT processing phase. However,
this is not always the case. For example, Spring Boot "disables"
selected `ContextCustomizer` implementations during AOT runtime
execution.

See 0f325f98b5

To address that, this commit ensures that context caching works
properly during AOT runtime execution even if the
MergedContextConfiguration differs from what was produced during the
AOT processing phase. Specifically, this commit introduces
AotMergedContextConfiguration which is a MergedContextConfiguration
implementation based on an AOT-generated ApplicationContextInitializer.

AotMergedContextConfiguration wraps the MergedContextConfiguration
built during AOT runtime execution.

Interactions with the ContextCache are performed using the
AotMergedContextConfiguration; whereas, the ApplicationContext is
loaded using the original MergedContextConfiguration.

This commit also introduces a ContextCustomizerFactory that emulates
the ImportsContextCustomizerFactory in Spring Boot's testing support.
BasicSpringJupiterImportedConfigTests uses @Import to verify that the
context customizer works, and AotIntegrationTests has been updated to
execute BasicSpringJupiterImportedConfigTests after test classes whose
MergedContextConfiguration is identical during AOT runtime execution.
Without the fix in this commit, BasicSpringJupiterImportedConfigTests
would fail in AOT runtime mode since its ApplicationContext would be
pulled from the cache using an inappropriate cache key.

Closes gh-29289
2022-10-09 16:17:43 +02:00
Sam Brannen cfa95c793b Ensure MergedContextConfigurationRuntimeHints is invoked once per config 2022-10-09 15:16:42 +02:00
Sam Brannen d4a5565340 Enable default TestExecutionListeners in JUnit 4 and TestNG base test classes
Prior to this commit, the abstract base test classes for JUnit 4 and
TestNG registered explicit sets of TestExecutionListeners. This
configuration was useful in the early years of the Spring TestContext
Framework. However, since the introduction of support for automatic
registration of "default" listeners in Spring Framework 4.1, these
predefined sets of TestExecutionListeners have become a hindrance to
using Spring's testing support with default listeners from Spring
portfolio projects (such as Spring Boot and Spring Security) as well as
third-party or project-specific default listeners.

To address this issue, the four abstract base test classes for JUnit 4
and TestNG no longer declare listeners via @TestExecutionListeners and
instead now rely on registration of default listeners.

Closes gh-29149
2022-10-08 16:30:07 +02:00
Sam Brannen 3061a81b0f Merge branch '5.3.x' 2022-10-08 16:21:30 +02:00
Sam Brannen b71d95df71 Document how to switch to the default set of TestExecutionListeners
Closes gh-29281
2022-10-08 16:20:55 +02:00
Sam Brannen afd0443204 Merge branch '5.3.x'
# Conflicts:
#	spring-test/src/main/java/org/springframework/test/web/reactive/server/ExchangeResult.java
2022-10-08 16:03:52 +02:00
Sam Brannen b20de758b2 Support custom status code in ExchangeResult for WebTestClient
Prior to this commit, ExchangeResult.assertWithDiagnostics() threw an
IllegalArgumentException for a custom HTTP status code since toString()
invoked getStatus() without a try-catch block.

This commit addresses this issue by introducing a formatStatus() method
that defensively formats the response status, initially trying to
format the HttpStatus and falling back to formatting the raw integer
status code.

Closes gh-29283
2022-10-08 15:45:24 +02:00
Johnny Lim 371fd06ae2 Use AssertJ static imports consistently in main
Closes gh-29282
2022-10-08 14:07:27 +02:00
Sam Brannen ae368a20b8 Merge branch '5.3.x'
# Conflicts:
#	spring-web/src/test/kotlin/org/springframework/http/codec/json/KotlinSerializationJsonDecoderTests.kt
#	spring-web/src/test/kotlin/org/springframework/http/codec/json/KotlinSerializationJsonEncoderTests.kt
2022-10-08 14:06:41 +02:00
Johnny Lim 1c1a0afbed Use AssertJ static imports consistently in 5.3.x
Closes gh-29282
2022-10-08 13:57:21 +02:00
Sam Brannen c98ed17728 Polishing 2022-10-08 13:43:09 +02:00
Johnny Lim ced37d53b4 Polishing
Closes gh-29284
2022-10-08 13:43:09 +02:00
Sam Brannen c1ff812d84 Disable flaky ReactorNetty2StompBrokerRelayIntegrationTests
See gh-29287
2022-10-08 13:43:09 +02:00
rstoyanchev 16ea4692ba Drop Servlet 4 classpath check 2022-10-07 18:14:41 +01:00
rstoyanchev 1afc1fc90d Fix regression in AbstractJackson2Encoder
Closes gh-29274
2022-10-07 18:14:41 +01:00
Sam Brannen b3afafbf5a Merge branch '5.3.x' 2022-10-07 18:02:25 +02:00
Sam Brannen a599601dd9 Document how to switch to the default set of TestExecutionListeners
Closes gh-29281
2022-10-07 17:58:22 +02:00
Sébastien Deleuze a9cd45e7f2 Improve BindingReflectionHintsRegistrar extensibility
This commit introduces a shouldSkipType(Class<?> type) method
and changes shouldRegisterMembers(Class<?> type) to
shouldSkipMembers(Class<?> type).

Closes gh-29279
2022-10-07 17:50:15 +02:00
Sébastien Deleuze bbe285dd42 Polish RegisterReflectionForBinding support
Implementation and Javadoc refinements.

See gh-29279
2022-10-07 17:50:15 +02:00
Sam Brannen 1d052742d1 Throw IOException in FileSystemResource.getURI() for consistency
See gh-29275
2022-10-07 17:06:54 +02:00
Sam Brannen 72307bbb20 Polish contribution
See gh-28549
2022-10-07 16:35:55 +02:00
hebo 2434470457 Optimize SpEL and property placeholder support for @Async qualifiers
See gh-27818
Closes gh-28549
2022-10-07 16:22:18 +02:00
Sam Brannen 64412907f7 Merge branch '5.3.x'
# Conflicts:
#	spring-test/src/main/java/org/springframework/test/util/AopTestUtils.java
2022-10-07 16:12:21 +02:00
Sam Brannen 5eee4673c1 Document limitation of AopTestUtils.getUltimateTargetObject() regarding non-static TargetSource
Closes gh-29276
2022-10-07 16:09:39 +02:00