Commit Graph

25308 Commits

Author SHA1 Message Date
Brian Clozel 43d39d4e8a Enforce need for type reflection in RuntimeHintsAgent
Prior to this commit, the AOT infrastructure would rely on the fact that
native runtime reflection on a type would only consider
methods/fields/constructors that had specific hints contributed. When
listing them through the reflection API on the type, the native image
would only return those for which we had hints contributed.
This behavior will soon change in GraalVM and will better align with the
JVM behavior: when asking for all declared methods on a type in a native
image, we should get all existing methods, not just the ones registered
previously in the native image.

This commit aligns the behavior of the `RuntimeHintsAgent` and removes
the now misleading predicates as a consequence.

Closes gh-29205
2022-10-03 11:31:24 +02:00
Stephane Nicoll ce46170a04 Avoid using org.springframework.boot 2022-10-03 10:15:38 +02:00
Stephane Nicoll 0b5c3ec267 Polish javadoc 2022-10-03 10:05:27 +02:00
Brian Clozel 3d795ab986 Add Java 19 daily build to CI pipeline 2022-10-02 16:24:10 +02:00
Brian Clozel 94da3609af Ignore Blockhound tests on Java 19 2022-10-02 16:23:42 +02:00
Brian Clozel ee1afb864c Add Java 19 to CI image 2022-10-02 16:23:22 +02:00
Brian Clozel a18c692b53 Start RestTemplate observation wtih available request
Prior to this commit, the `RestTemplate` `ClientHttpObservation` would
be started before the request object is available. While this would also
measure the connection estalishment for some HTTP client libraries, this
arrangement is incompatible with a tracing approach where the request
must be available to propagate information through the request headers.

This commit ensures that the observation only starts when the request is
available.

Fixes gh-29234
2022-09-30 23:12:53 +02:00
Johnny Lim 380795e5b8 Polish observability changes
Closes gh-29235
2022-09-30 23:12:26 +02:00
Phillip Webb afac8dd8af Refine SourceFile record to class conversion
Update conversion logic to deal with annotations.

See gh-29236
2022-09-30 11:58:14 -07:00
Phillip Webb 7fd8e081bb Allow TestCompiler SourceFile to work with records
Update `SourceFile` to try a regex replace to make `record` files look
like regular classes.

Closes gh-29236
2022-09-30 11:18:43 -07:00
Brian Clozel 8c24e8c034 Add HttpOutcome for HTTP observations
Prior to this commit, the HTTP Observations would use
`HttpStatus.Series` as a value source for the "outcome" key value in
recorded observations. This would work for most cases, but would not
align in the 2xx HTTP status cases: the series would provide a
"SUCESSFUL" value whereas the heritage metrics support in Spring Boot
would give "SUCESS".

This commit introduces a dedicated `HttpOutcome` concept for this and
applies it to all HTTP observations.

Fixes gh-29232
2022-09-30 18:17:23 +02:00
Brian Clozel b9070ae752 Add contextualName to HTTP Observations
This commit ensures that all HTTP `ObservationConvention`
implementations provide a consistent contextual name for observations.
This name should be like "http get" where only the HTTP verb changes
depending on the request.

Fixes gh-29231
2022-09-30 18:17:23 +02:00
Stephane Nicoll 0cc3c6b5d1 Add entry point for processing an application ahead-of-time
This commit adds the necessary infrastructure to process an application
using the AOT engine, similar to the existing TestAotProcessor for
processing tests.

This can be used by frameworks built on top of Spring Framework, for
instance by providing a main method that can be triggered by build
tools.

Close gh-29181
2022-09-30 16:18:27 +02:00
Arjen Poutsma 0293e22910 Trying to fix flaky CoroutinesIntegrationTests 2022-09-30 15:54:01 +02:00
Stephane Nicoll 7e7e4efb01 Merge pull request #29230 from izeye
* pr/29230:
  Polish ReflectionHintsPredicates

Closes gh-29230
2022-09-30 15:30:49 +02:00
Johnny Lim 89db4efb67 Polish ReflectionHintsPredicates
See gh-29230
2022-09-30 15:23:35 +02:00
Brian Clozel 377d719b5f Add opens for Gradle test workers
After our upgrade to Gradle 7.5.1, our test suite requires changes to
our test configuration. See:

https://docs.gradle.org/7.5/userguide/upgrading_version_7.html#removes_implicit_add_opens_for_test_workers
2022-09-30 15:13:46 +02:00
Brian Clozel 8e24797d37 Merge branch '5.3.x' 2022-09-30 14:42:00 +02:00
Brian Clozel 777caef4f7 Upgrade to Gradle 7.5.1 2022-09-30 14:35:31 +02:00
rstoyanchev 5d2c9d946a Clean up conditional use of ChannelOperationsId
Closes gh-29224
2022-09-30 13:04:02 +01:00
Violeta Georgieva e81d30160c Remove useless constant reactorNettyRequestChannelOperationsIdPresent
`reactor.netty.ChannelOperationsId` is available in Reactor Netty 1.1.x from the very beginning.
2022-09-30 13:04:02 +01:00
rstoyanchev bc13d2b558 Remove unnecessary suppressing of deprecation
Closes gh-28870
2022-09-30 13:04:02 +01:00
Sam Brannen 2606557483 Polishing 2022-09-30 13:32:33 +02:00
Sam Brannen d21eea7de4 Fix recent regression in PathMatchingResourcePatternResolver
Commit 0eb66789ed which introduced generic FileSystem support in
PathMatchingResourcePatternResolver also introduced a regression in that
a matching folder is now returned in the results.

This commit address this by additionally using Files#isRegularFile() in
the predicate used to filter candidates.

Closes gh-29163
2022-09-30 13:05:31 +02:00
Sébastien Deleuze 7a2110d8a5 Refine Kotlin bean DSL for AOT use case
Before this commit, beans registered with the Kotlin bean DSL
typically added via SpringApplication#addInitializers
were registered 2 times: by the code generated AOT and by
the listener executed at runtime.

After this commit, such beans are only registered 1 time when
AOT generation is involved, and does not require specific
reflection hints on native execution anymore.

Closes gh-29211
2022-09-30 12:25:43 +02:00
Brian Clozel d98e27cf79 Upgrade to Kotlin 1.7.20
This commit also temporarily changes a test assertion for the Jackson
Kotlin module.
As of https://youtrack.jetbrains.com/issue/KT-52932, Kotlin enhanced the
`IntRange` and this change is not supported yet by the Jackson Kotlin
module. An issue has been reported here:
FasterXML/jackson-module-kotlin#582

Closes gh-29225
2022-09-30 11:24:55 +02:00
Stephane Nicoll e4940149d9 Polish "Replace AotApplicationContextInitializer with interface"
Closes gh-29157
2022-09-30 07:46:00 +02:00
Phillip Webb f2568f2dda Remove unused import
See gh-29157
2022-09-29 16:50:15 -07:00
Phillip Webb 86ad29a7d6 Drop getAotInitializers method
See gh-29157
2022-09-29 15:43:13 -07:00
Phillip Webb 192bc1eb13 Fix factory method return type
See gh-29157
2022-09-29 15:38:37 -07:00
Phillip Webb ac13d26077 Replace AotApplicationContextInitializer with interface
Replace the `ApplicationContextAotInitializer` class with an
`AotApplicationContextInitializer` interface so that its use can be
detected using a simple `instanceof` check. The existing functionality
has been moved to a factory method on the interface allowing:

	`new ApplicationContextAotInitializer()
		.initialize(context, names);`

To now be written as:

	`AotApplicationContextInitializer.forInitializerClasses(names)
		.initialize(context);`

See gh-29157
2022-09-29 14:43:25 -07:00
Sébastien Deleuze 3eaf326997 Refine ConstantFieldSubstitutionProcessor error handling
The upgrade to SLF4J 2 via gh-29152 has broken
ConstantFieldSubstitutionProcessor when the class processed
has both a static boolean field to make constant at build
time and a static logger.

This issue is about catching and logging those errors,
skipping the processing of such fields which will be
then evaluated at runtime.

Closes gh-29219
2022-09-29 12:52:30 +02:00
Sébastien Deleuze 9b577a8955 Upgrade to SLF4J 2.0.2 and Log4j 2.19.0
Closes gh-29152
Closes gh-29217
2022-09-29 10:27:40 +02:00
rstoyanchev 9eaae0fe04 Polishing contribution and Theme deprecation notices
Closes gh-28870
2022-09-28 16:22:45 +01:00
Vedran Pavic cde92f5e1d Deprecate CookieGenerator
This commit deprecates CookieGenerator in favor of the more modern
alternative, ResponseCookie.

See gh-28870
2022-09-28 16:04:38 +01:00
rstoyanchev e6c2d44646 Better integrate ResponseCookie in CookieLocaleResolver
Improve ResponseCookie to allow an existing instance to be mutated
and also to set the cookie value through the builder. This allows
CookieLocaleResolver to avoid duplicating all the fields of
ResponseCookie and to have only a ResponseCookie field instead.

Closes gh-28779
2022-09-28 16:00:33 +01:00
rstoyanchev 075fccca94 Polishing contribution
See gh-28779
2022-09-28 16:00:33 +01:00
Vedran Pavic 7ea49fa9f4 Refactor CookieLocaleResolver
At present, CookieLocaleResolver extends CookieGenerator instead of
AbstractLocale(Context)Resolver like other LocaleResolver
implementations. This means it duplicates some common aspects of
LocaleResolver hierarchy while also exposing some CookieGenerator
operations, such as #addCookie and #removeCookie.

Additionally, CookieGenerator's support for writing cookies is based
on Servlet support which at current baseline doesn't support SameSite
directive.

This commit refactors CookieLocaleResolver to make it extend
AbstractLocaleContextResolver and also replaces CookieGenerator's
cookie writing support with newer and more capable ResponseCookie.
Simplify creation of CookieLocaleResolver with custom cookie name

This commit introduces CookieLocaleResolver constructor that accepts
cookie name thus allowing for a simpler creation of an instance with
the desired cookie name.

See gh-28779
2022-09-28 16:00:33 +01:00
Sam Brannen f6d1806e30 Ensure DefaultListableBeanFactoryTests compiles in Eclipse IDE 2022-09-28 15:44:45 +02:00
Sam Brannen 6cb131ac76 Polishing 2022-09-28 14:27:36 +02:00
Sam Brannen 0eb66789ed Introduce generic FileSystem support in PathMatchingResourcePatternResolver
This commit introduces support in PathMatchingResourcePatternResolver
for resolving files in a generic fashion using the
java.nio.file.FileSystem API, including preliminary support for class
path scanning within a GraalVM native image.

See included commits for details.

Closes gh-29163
2022-09-28 13:53:31 +02:00
Sam Brannen ccff526454 Reintroduce logging and exception handling for file system resource scanning
See gh-29163
2022-09-28 13:47:55 +02:00
Sam Brannen 7cb54de985 Apply root dir cleanup only for GraalVM native image resource scheme
See gh-29163
2022-09-28 13:47:44 +02:00
Sam Brannen 7a15805f6c Polish contribution
See gh-29163
2022-09-28 13:47:44 +02:00
Sam Brannen 0e22c3d89d Convert `file:` URL to FileSystemResource for backward compatibility
See gh-29163
2022-09-28 13:47:44 +02:00
Sam Brannen 508be4e0fa Update Javadoc to reflect changes
See gh-29163
2022-09-28 13:47:44 +02:00
Sam Brannen 385292dc41 Fix Checkstyle violations
See gh-29163
2022-09-28 13:47:44 +02:00
Dave Syer f751b38795 Use java.nio and FileSystems to resolve files in PathMatchingResourcePatternResolver
The JDK has decent support for walking a file system (via the
FileSystem API in java.nio.file), but prior to this commit Spring still
used hand-rolled pre-Java 7 code. Also, in principle, FileSystem can be
an abstraction used to express any hierarchy of resources through their
URIs. This is a good fit with the Spring Resource abstraction, and for
instance would mean that GraalVM native images could potentially do
classpath scanning through a custom URI and FileSystem already provided
by GraalVM.

In light of the above, this commit overhauls the implementation of
PathMatchingResourcePatternResolver to use a java.nio.file.FileSystem
to find matching resources within a file system.

As a side effect, several obsolete `protected` methods have been
removed from PathMatchingResourcePatternResolver.

See gh-29163
2022-09-28 13:39:48 +02:00
Stephane Nicoll c5fc0a5ef3 Add shortcut in TestGenerationContext 2022-09-28 11:20:35 +02:00
Stephane Nicoll 737967f924 Polish 2022-09-28 11:16:07 +02:00