Commit Graph

25183 Commits

Author SHA1 Message Date
rstoyanchev fdfa7cbae6 Add docs for RSocket interface client
Closes gh-24456
2022-09-07 15:01:40 +01:00
rstoyanchev 8423b2cab7 Add support for RSocket interface client
See gh-24456
2022-09-07 15:01:40 +01:00
Sam Brannen ae861a2b3e Document leading slash semantics for ClassPathResource.getPath()
See gh-29094
2022-09-07 15:28:35 +02:00
Sam Brannen 0395fb4f5f Polish tests 2022-09-07 15:12:15 +02:00
Brian Clozel a425512025 Polish
See gh-29050
2022-09-07 15:02:10 +02:00
Kevin Yue 298c9a6f1b Redirect response wrapper should commit response
This commit ensures that when using `sendRedirect`, the response wrapper
behaves correctly with regards to the Servlet specification:

1. reset the response buffer to clear any partially written response
2. set the expected response HTTP headers
3. flush the buffer to commit the response

Closes gh-29050
2022-09-07 14:59:15 +02:00
Sam Brannen 1688becd73 Avoid questionable use of ClassPathResource#getPath() in tests
Prior to this commit, several tests used ClassPathResource#getPath()
based on the knowledge that the ClassPathResource had been created
using the ClassPathResource(String,Class) constructor. However, making
such an assumption seems ill advised in light of the abstraction that
ClassPathResource provides.

In light of that, this commit avoids questionable use of
ClassPathResource#getPath() in tests by refactoring those tests to use
the proper abstractions provided by ClassPathResource.
2022-09-07 14:59:05 +02:00
Arjen Poutsma 4cc91e46b2 Decode quoted pairs in ContentDisposition
This commit makes sure that quoted pairs, as used in Content-Disposition
header file names (i.e. \" and \\), are properly decoded, whereas before
they were stored as is.

Closes gh-28837
2022-09-07 10:22:19 +02:00
Sébastien Deleuze 9cfe79186d Stop using RuntimeHintsUtils
Due to gh-29053, we can stop using RuntimeHintsUtils to
register SynthesizedAnnotation proxies.

Closes gh-29059
2022-09-07 10:10:07 +02:00
Stephane Nicoll 1e8017107a Remove unnecessary workaround
See gh-29091
2022-09-07 07:50:49 +02:00
Brian Clozel 323d1907c1 Do not require full type reflection when listing methods/fields
Prior to this commit, the `RuntimeHintsAgent` and its testing
infrastructure would assume that calling `MyClass.class.getMethods()`
requires a reflection hint on the class for introspecting public/private
methods.

GraalVM does not require this, in fact this call only returns methods
that have reflection hints in the native image.

This commit refines the agent behavior for `Class.getMethods()`,
`Class.getDeclaredMethods()`, `Class.getFields()` and
`Class.getDeclaredFields()`. With this change, registering at least one
method/field for reflection is enough to match.

During the execution of Java tests, all methods and fields will be
provided, regardless of hints being registered or not. This could cause
false negatives where we're missing reflection hints on methods or
fields.
This risk is mitigated thanks to additional instrumentation on
`Method.getAnnotations()`, `Method.getParameterTypes()` and
`Method.invoke()`. If a method is found reflectively, chances are it
will be used for further reflection.

Closes gh-29091
2022-09-06 22:14:10 +02:00
Sam Brannen 6cce47176a Further clarify the semantics of ClassPathResource.getPath()
See gh-29094
2022-09-06 20:34:12 +02:00
Sam Brannen 018122f684 Update Javadoc for ResourceHints.registerResourceIfNecessary()
See gh-29094
2022-09-06 20:18:24 +02:00
Sam Brannen d57e061d3f Introduce getAbsolutePath() in ClassPathResource
Since getPath() returns a relative path if the resource was created
using the ClassPathResource(String,Class) constructor, there was
previously no way to consistently obtain the absolute path to the
resource within the class path.

This commit addresses this shortcoming by introducing a new
getAbsolutePath() for consistently obtaining the absolute path to the
resource within the class path.

See gh-29083
Closes gh-29094
2022-09-06 20:09:24 +02:00
Sam Brannen 1052f48eb6 Clarify semantics of ClassPathResource.getPath()
This commit also improves the overall Javadoc in ClassPathResource.

See gh-29094
2022-09-06 20:08:21 +02:00
Sébastien Deleuze b8c1fc9202 Revert "Remove RuntimeHintsUtils"
This reverts commit 3e327f5641.
2022-09-06 18:21:34 +02:00
Sébastien Deleuze 3e327f5641 Remove RuntimeHintsUtils
Due to gh-29053, we can stop using RuntimeHintsUtils to
register SynthesizedAnnotation proxies.

Closes gh-29058
Closes gh-29059
2022-09-06 15:31:02 +02:00
Stephane Nicoll 903078a5b2 Do not silently return null when no constructor candidate is found
This commit updates ConstructorOrFactoryMethodResolver to throw an
exception if no constructor or factory method can be found for a given
bean definition.

This prevents code generation to happen on an incomplete view of the
bean to instantiate.

Closes gh-29052
2022-09-06 15:26:39 +02:00
Sam Brannen 8fbd2141b7 Move registerResourceIfNecessary() to ResourceHints
See gh-29083
2022-09-06 15:22:18 +02:00
Sam Brannen 5c2859ffa7 Make fields in ClassPathResource final 2022-09-06 14:47:19 +02:00
Sam Brannen 28c492cbdd Introduce RuntimeHintsUtils.registerResourceIfNecessary
This commit introduces a new registerResourceIfNecessary() method in
RuntimeHintsUtils that simplifies the registration of hints for
`classpath:` resources.

Closes gh-29083
2022-09-06 14:36:28 +02:00
Brian Clozel dd1e6b9412 Revisit request parameters access with HtmlUnit
Prior to this commit, the `HtmlUnitRequestBuilder` would "translate"
HtmlUnit web requests into Servlet requests using APIs that were not
clearly defined and meant for internal usage.

HtmlUnit 2.64.0 introduced a new `.getParameters()` API for collecting
`NameValuePair` parsed from the request URI or request body, depending
on the nature of the request. This arrangement is much more stable and
in line with HtmlUnit's expectations.

This commit uses this new API and makes HtmlUnit 2.64.0 a new minimum
requirement for using HtmlUnit integration with Spring Framework.
This also removes tests that were previously testing HtmlUnit's behavior
and using the API now marked as internal.

Closes gh-28240
2022-09-06 13:40:28 +02:00
Sam Brannen 10ade235e3 Prevent resource hint registration for pattern with leading slash
Prior to this commit, if a ResourcePatternHint was created with a
resource pattern with a leading slash, the hint was registered and
eventually converted to configuration for the GraalVM native image
compiler.

However, such a resource pattern is invalid for GraalVM. Consequently,
the registered resources were not available within the compiled native
image.

This commit ensures that registered patterns are applicable in a native
image by preventing creation of a ResourcePatternHint with a pattern
with a leading slash.

Closes gh-29088
2022-09-06 12:53:31 +02:00
Sam Brannen 04bb336b0b Polish ResourcePatternHints Javadoc 2022-09-06 12:53:31 +02:00
Sam Brannen dc07ca1d36 Polish AsyncExecutionTests 2022-09-06 12:53:31 +02:00
Sam Brannen 97b98c3378 Support default package for TypeReference in ResourceHintsPredicates
Prior to this commit, if the TypeReference supplied to
ResourceHintsPredicates.forResource(TypeReference,String) was for a
class declared in the default package (i.e., without a package), the
resolveAbsoluteResourceName() method incorrectly prepended two leading
slashes (//) to the absolute resource name, causing correct matches to
fail.

This commit fixes this by adding special handling for a TypeReference
without a package name. In addition, this commit introduces lenient
handling of resource names by consistently removing a leading slash in
ResourceHintsPredicates.forResource(*) methods. The latter aligns with
absolute resource path handling in other places in the framework, such
as ClassPathResource.

Closes gh-29086
2022-09-06 12:53:31 +02:00
Janne Valkealahti 135f9070c5 Add jni-config generation
This commit adds support generating graalvm `jni-config.json` file.

Configuration format for jni/reflection in graalvm is documented
to be exactly same so we can re-use facilities for reflection hints
which should be relatively clean for a user as also graalvm uses same
classes for both jni/reflection.

Closes gh-29007
2022-09-06 12:22:13 +02:00
Sam Brannen 6902ff77d9 Fix resource registration hints in the TestContext framework
Resource patterns registered for inclusion in a GraalVM native image
must not start with a leading slash.
2022-09-05 18:38:38 +02:00
Stephane Nicoll 6e93f1187c Move TestCompiler from generator to generate
This commit harmonizes the package space by moving the TestCompiler
infrastructure from the now outdated "generator" package to "generate".

Closes gh-29082
2022-09-05 16:30:19 +02:00
Stephane Nicoll 58b0251af1 Relocate TestGenerationContext to spring-core-test
This commit moves the test implementation for GenerationContext in
spring-core-test. This also removes the copy we had in testfixtures

See gh-28877
2022-09-05 16:21:17 +02:00
Sam Brannen e57b5f1dfc Register runtime hints for @Sql scripts
SqlScriptsTestExecutionListener now implements AotTestExecutionListener
in order to register run-time hints for SQL scripts used by test
classes and test methods annotated with @Sql if the configured or
detected SQL scripts are classpath resources.

Closes gh-29027
2022-09-05 14:15:19 +02:00
Sam Brannen e85e769f1c Introduce @Sql tests for AOT processing 2022-09-05 12:54:55 +02:00
Sam Brannen 35bbe9f99d Polishing 2022-09-05 12:51:14 +02:00
Sam Brannen ea132388c5 Introduce AotTestExecutionListener API in the TestContext framework
This commit introduces an AotTestExecutionListener API that extends
TestExecutionListener and allows a TestExecutionListener to opt in for
AOT processing support, analogous to what the AotContextLoader API does
for a SmartContextLoader.

Closes gh-29070
2022-09-05 12:10:29 +02:00
Sam Brannen c2dd6667f1 Revise method signature in TestRuntimeHintsRegistrar 2022-09-05 12:10:29 +02:00
Stephane Nicoll 16ff05ed86 Polish 2022-09-05 11:55:19 +02:00
Stephane Nicoll 3b36171926 Merge branch '5.3.x' 2022-09-05 07:24:07 +02:00
Stephane Nicoll 8dcb2a75fa Merge pull request #29048 from 1993heqiang
* pr/29048:
  Fix typo in data-access section

Closes gh-29048
2022-09-05 07:23:56 +02:00
heqiang 111a9902ac Fix typo in data-access section
See gh-29048
2022-09-05 07:21:31 +02:00
Sam Brannen b0e723dbbb Delete obsolete test code
We no longer register reflection run-time hints for the SpringExtension
since that is covered by the JupiterConfigProvider in the GraalVM Native
Build Tools project.
2022-09-04 19:50:41 +02:00
Sam Brannen a68d4ae25c Register runtime hints for ActiveProfilesResolvers
This commit introduces automatic registration of runtime hints for
custom ActiveProfilesResolver implementations configured via the
`resolver` attribute in @ActiveProfiles.

Closes gh-29022
2022-09-04 18:59:12 +02:00
Sam Brannen 8d6d3f2698 Polishing 2022-09-04 17:51:48 +02:00
Sam Brannen afff849992 Add missing package-info.java file 2022-09-04 17:50:45 +02:00
Sam Brannen cbb30153fb Introduce StandardTestRuntimeHints in the TestContext framework
This commit introduces StandardTestRuntimeHints and migrates existing
hint registration from TestContextAotGenerator to this new class.

In addition, this commit removes a package cycle between context.aot and
context.web that was introduced in commit dc7c7ac22a.

See gh-29026, gh-29069
2022-09-04 17:44:19 +02:00
Sam Brannen bf0ac84a05 Introduce TestRuntimeHintsRegistrar in the TestContext framework
Although RuntimeHintsRegistrar can be implemented to register general
hints that should be applied for all testing infrastructure, certain
use cases require access to test classes and the
MergedContextConfiguration in order to register appropriate hints.

To address that, this commit introduces TestRuntimeHintsRegistrar as a
companion to the core RuntimeHintsRegistrar.

Closes gh-29069
2022-09-04 17:14:24 +02:00
Sam Brannen dc7c7ac22a Register runtime hint for @WebAppConfiguration's resource path
This commit introduces automatic registration of a runtime hint for
classpath resources configured via the `value` attribute in
@WebAppConfiguration.

Closes gh-29026
2022-09-04 16:45:06 +02:00
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