Commit Graph

29735 Commits

Author SHA1 Message Date
Felix
05b15812bb Apply instanceof pattern matching in RootBeanDefinition
Closes gh-32520
2024-03-23 09:09:25 +01:00
Sébastien Deleuze
0e7aba4179 Perform NullAway build-time checks in spring-webmvc
See gh-32475
2024-03-22 17:49:03 +01:00
Sébastien Deleuze
cf8810042a Merge branch '6.1.x' 2024-03-22 17:46:35 +01:00
Sébastien Deleuze
a16e8c34b2 Refine null-safety in spring-webmvc
See gh-32475
2024-03-22 17:44:35 +01:00
Sam Brannen
88bc3f270e Merge branch '6.1.x' 2024-03-22 17:18:38 +01:00
Sam Brannen
52b8c71dcd Retain null-safe syntax in AST representation of selection & projection
Prior to this commit, SpEL's CompoundExpression omitted the null-safe
syntax in AST string representations of the selection and projection
operators.

To address this, this commit implements isNullSafe() in Projection and
Selection.

Closes gh-32515
2024-03-22 17:05:48 +01:00
Sam Brannen
b695dbc2bf Merge branch '6.1.x' 2024-03-22 16:37:55 +01:00
Sam Brannen
f941754db6 Introduce isNullSafe() in SpelNodeImpl
Prior to this commit, MethodReference and PropertyOrFieldReference
already defined local isNullSafe() methods, but we need identical
methods in Selection, Projection, and Indexer, and we may potentially
need null-safe support for additional operators in the future.

To address the common need for an is-null-safe check, this commit
introduces an isNullSafe() method in SpelNodeImpl with a default
implementation that returns false.

Closes gh-32516
2024-03-22 16:37:08 +01:00
Sam Brannen
d4495a5654 Revise PropertyOrFieldReference since isNullSafe() is not final 2024-03-22 16:37:08 +01:00
Stéphane Nicoll
cf4ac96688 Merge branch '6.1.x' 2024-03-22 16:33:17 +01:00
Stéphane Nicoll
c7c61e13e1 Merge pull request #32514 from izeye
* pr/32514:
  Apply UnnecessarySemicolonInEnumeration Checkstyle module

Closes gh-32514
2024-03-22 16:31:54 +01:00
Johnny Lim
4d722414da Apply UnnecessarySemicolonInEnumeration Checkstyle module
This commit also fixes its violation.

See gh-32514
2024-03-22 16:30:06 +01:00
Sébastien Deleuze
0a50854e1a Perform NullAway build-time checks in spring-webflux
See gh-32475
2024-03-22 16:09:18 +01:00
Sébastien Deleuze
637aa9f71f Merge branch '6.1.x' 2024-03-22 16:06:25 +01:00
Sébastien Deleuze
87dfa492af Refine null-safety in spring-webflux
See gh-32475
2024-03-22 16:05:17 +01:00
Sébastien Deleuze
cf9033a60d Polishing 2024-03-22 16:04:03 +01:00
Sébastien Deleuze
b1b9ee0ccf Merge branch '6.1.x' 2024-03-21 17:56:14 +01:00
Sébastien Deleuze
1e80694daf Fix a regression with Kotlin generic controllers
This commit reintroduces a more defensive parameter type check that
skips KClass casting for generic parameters.

Closes gh-32510
2024-03-21 17:55:57 +01:00
Sam Brannen
a30c06b883 Polishing and consistent use of exception assertions 2024-03-21 16:36:14 +01:00
Andrea Mauro
458c30cb63 Resolve property-dependent parameter names for exception messages
Prior to this commit when a required parameter defined as a property or
expression placeholder was missing, the exception thrown would refer to
the placeholder instead of the resolved name.

This change covers messaging handlers and web controllers, both blocking
and reactive. It also fixes the error message when handling null values
for non-required parameters, as well as in cases that need conversion.

See gh-32323
Closes gh-32462
2024-03-20 17:40:38 +01:00
Sam Brannen
5698191ba0 Rename listener to CommonCachesTestExecutionListener
See gh-30954
2024-03-20 16:37:22 +01:00
Sam Brannen
7d197972e0 Polishing 2024-03-20 13:05:30 +01:00
Sam Brannen
1732844137 Polishing 2024-03-20 12:55:35 +01:00
Sam Brannen
7f40b49f4d Improve names of classes generated by the SpEL compiler
Prior to this commit, the SpEL compiler generated classes in a package
named "spel" with names following the pattern "Ex#", where # was an
index starting with 2.

This resulted in class names such as:

- spel.Ex2
- spel.Ex3

This commit improves the names of classes created by the SpEL compiler
by generating classes in a package named
"org.springframework.expression.spel.generated" with names following
the pattern "CompiledExpression#####", where ##### is a 0-padded
counter starting with 00001.

This results in class names such as:

- org.springframework.expression.spel.generated.CompiledExpression00001
- org.springframework.expression.spel.generated.CompiledExpression00002

This commit also moves the saveGeneratedClassFile() method from
SpelCompilationCoverageTests to SpelCompiler and enhances it to:

- Save classes in a "build/generated-classes" directory.
- Convert package names to directories.
- Create missing parent directories.
- Use logging instead of System.out.println().

Running a test with saveGeneratedClassFile() enabled now logs something
similar to the following.

DEBUG o.s.e.s.s.SpelCompiler - Saving compiled SpEL expression [(#root.empty ? 0 : #root.size)] to [/Users/<username>/spring-framework/spring-expression/build/generated-classes/org/springframework/expression/spel/generated/CompiledExpression00001.class]

Closes gh-32497
2024-03-20 12:34:01 +01:00
Stéphane Nicoll
2f070e59e6 Merge branch '6.1.x' 2024-03-20 10:16:26 +01:00
Stéphane Nicoll
e17c3d3be4 Upgrade actions that use deprecated features 2024-03-20 10:16:09 +01:00
Sébastien Deleuze
f648fd7c3b Perform NullAway build-time checks in spring-expression
See gh-32475
2024-03-20 10:10:00 +01:00
Sébastien Deleuze
1ccd5512c5 Merge branch '6.1.x' 2024-03-20 10:08:30 +01:00
Sébastien Deleuze
2e98a8a2a4 Refine null-safety in spring-expression
See gh-32475
2024-03-20 10:07:56 +01:00
Stéphane Nicoll
5a86ab99df Merge branch '6.1.x' 2024-03-20 10:01:56 +01:00
Stéphane Nicoll
592f23674d Merge pull request #32494 from qww1552
* pr/32494:
  Fix link to vavr in the reference guide

Closes gh-32494
2024-03-20 10:01:47 +01:00
Minsung Oh
0b3a05b463 Fix link to vavr in the reference guide
See gh-32494
2024-03-20 09:48:00 +01:00
Stéphane Nicoll
29d307e211 Clear ApplicationContext cache after a test class completes if necessary
The ApplicationContext has a resource cache that it uses while the
context is being refreshed. Once the refresh phase completes, the
cache is cleared as its content is no longer in use. If beans are
lazily initialized, there is a case where the cache might be filled
again as processing is deferred past the refresh phase.

For those cases, the cache is not cleared. This can be a problem when
running in this mode with a large set of test configurations as the TCF
caches the related contexts.

This commit includes an additional TestExecutionListener to the TCF that
clears the resource cache if necessary once a test class completes. It
is ordered so that it runs after `@DirtiesContext` support as marking
the context as dirty will remove it from the cache and make that extra
step unnecessary.

Closes gh-30954
2024-03-20 09:42:41 +01:00
Sébastien Deleuze
4c7735016b Refine null-safety with NullAway build-time checks
This commit introduces null-safety checks for spring-core at build-time
in order to validate the consistency of Spring null-safety annotations
and generate errors when inconsistencies are detected during a build
(similar to what is done with Checkstyle).

In order to make that possible, this commit also introduces a new
org.springframework.lang.Contract annotation inspired from
org.jetbrains.annotations.Contract, which allows to specify semantics
of methods like Assert#notNull in order to prevent artificial
additional null checks in Spring Framework code base.

This commit only checks org.springframework.core package, follow-up
commits will also extend the analysis to other modules, after related
null-safety refinements.

See gh-32475
2024-03-19 16:30:32 +01:00
Sam Brannen
0a715bcab3 Merge branch '6.1.x' 2024-03-19 15:52:12 +01:00
Sam Brannen
ef02f0bad8 Wrap InvalidMimeTypeException in HttpMediaTypeNotAcceptableException
The fix for #31254 resulted in an InvalidMimeTypeException being thrown
by MimeTypeUtils.sortBySpecificity() instead of an
IllegalArgumentException. However, InvalidMimeTypeException extends
IllegalArgumentException. Consequently, the change from
IllegalArgumentException to InvalidMimeTypeException did not result in
the desired effect in HeaderContentNegotiationStrategy.

HeaderContentNegotiationStrategy.resolveMediaTypes() still allows the
InvalidMimeTypeException to propagate as-is without wrapping it in an
HttpMediaTypeNotAcceptableException.

To address this issue, this commit catches InvalidMediaTypeException
and InvalidMimeTypeException in HeaderContentNegotiationStrategy and
wraps the exception in an HttpMediaTypeNotAcceptableException.

See gh-31254
See gh-31769
Closes gh-32483
2024-03-19 15:51:27 +01:00
Sam Brannen
836a0b3a40 Polishing 2024-03-19 14:19:01 +01:00
Sam Brannen
09f210f5f7 Polish wording in reference manual 2024-03-19 14:15:19 +01:00
Sébastien Deleuze
8d23ec4747 Merge branch '6.1.x' 2024-03-19 13:36:39 +01:00
Sébastien Deleuze
aa0fb97ba5 Nullability refinements
See gh-32475
2024-03-19 13:32:13 +01:00
Juergen Hoeller
14bc0d6469 Fix typo in condition check
See gh-21190
2024-03-19 13:17:33 +01:00
Sam Brannen
3bd342ee7d Polish bean override support in the TestContext framework 2024-03-19 12:41:06 +01:00
Sébastien Deleuze
871860798e Merge branch '6.1.x' 2024-03-19 11:05:22 +01:00
Sébastien Deleuze
71a117c0fd Document AOT limitations related to Kotlin backticks
Closes gh-32487
2024-03-19 11:03:56 +01:00
Juergen Hoeller
e58ea0d945 Merge branch '6.1.x'
# Conflicts:
#	spring-core/src/main/java/org/springframework/core/CoroutinesUtils.java
2024-03-19 10:06:48 +01:00
Juergen Hoeller
bd27ddf83a Polishing (aligned with main) 2024-03-19 10:05:32 +01:00
Juergen Hoeller
c531a8a705 Nullability refinements and related polishing
See gh-32475
2024-03-19 09:58:44 +01:00
Sam Brannen
8f56b4a8ae Fix logic error hidden by auto-boxing 2024-03-18 18:19:34 +01:00
Sam Brannen
2ca10e20ca Simplify implementation of BeanOverrideParser
See gh-29917
2024-03-18 18:13:36 +01:00
Sam Brannen
0ef5a4090b Support non-public BeanOverrideProcessors in the TestContext framework
Closes gh-32485
2024-03-18 18:02:51 +01:00