Commit Graph

31788 Commits

Author SHA1 Message Date
rstoyanchev
84e863f803 Refactoring in MethodValidationAdapter
Extract the default logic for resolving the name of an @Valid
parameter into an ObjectNameResolver, and use it when there isn't
one configured.

See gh-30644
2023-07-03 12:08:11 +01:00
rstoyanchev
7a79da589a Add default web handling of method validation errors
Closes gh-30644
2023-07-03 12:08:11 +01:00
rstoyanchev
a481c7649f Refactor to prepare for method validation handling
To handle method validation errors in ResponseEntityExceptionHandler,
MethodValidationException and associated types should not depend on
Bean Validation. To that effect:

1. MethodValidationResult and ParameterValidationResult no longer make
the underlying ConstraintViolation set available, and instead expose
only the adapted validation errors (MessageSourceResolvable, Errors),
analogous to what SpringValidatorAdapter does. And likewise
MethodValidationException no longer extends ConstraintViolationException.

2. MethodValidationPostProcessor has a new property
adaptConstraintViolations to decide whether to simply raise
ConstraintViolationException, or otherwise to adapt the ConstraintViolations
and raise MethodValidationException instead, with the former is the default
for compatibility.

3. As a result, the MethodValidator contract can now expose methods that
return MethodValidationResult, which provided more flexibility for handling,
and it allows MethodValidationAdapter to implement MethodValidator directly.

4. Update Javadoc in method validation classes to reflect this shift, and
use terminology consistent with Spring validation in classes without an
explicit dependency on Bean Validation.

See gh-30644
2023-07-03 12:08:11 +01:00
Rossen Stoyanchev
ba4d9a5230 Add BindErrorUtils
This deprecates static methods in MethodArgumentNotValidException
which is not a great vehicle for such methods.

See gh-30644
2023-07-03 12:08:11 +01:00
rstoyanchev
e83594a2a3 Polishing in Web validation exceptions
- Update method order
- Do not automatically create MessageSource arguments in
WebExchangeBindException constructor as they're more likely to be
created via getDetailMessageArguments with MessageSource passed in.

See gh-30644
2023-07-03 12:08:11 +01:00
rstoyanchev
a8ea472121 Refactoring in MethodValidationResult
Remove throwIfViolationsPresent and replace with static factory
methods on MethodValidationException taking MethodValidationResult,
which makes handling more explicit and allows choice of what
exception to raise.

Update MethodValidationResult to expose the target, the method, and
forReturnValue flag, so the code handling an exception will have
access to all details.

See gh-30644
2023-07-03 12:08:11 +01:00
Arjen Poutsma
1393fac402 Merge pull request #30788 from spencergibb:customize-disallowed-headers
* gh-30788:
  Polishing external contribution
  Allow customization of disallowed JdkClientHttpRequest headers
2023-07-03 12:42:47 +02:00
Arjen Poutsma
46f1849c2f Polishing external contribution
See gh-30787
Closes gh-30788
2023-07-03 12:36:25 +02:00
spencergibb
9900575f9c Allow customization of disallowed JdkClientHttpRequest headers
By default, the JDK HttpClient's HttpRequest does not allow Connection,
Content-Length, Expect, Host, or Upgrade headers to be set, but this can
be overriden with the `jdk.httpclient.allowRestrictedHeaders` system
property.

See https://bugs.openjdk.org/browse/JDK-8213696

Closes gh-30787
2023-07-03 12:35:44 +02:00
Sam Brannen
2ed10f13e9 Merge branch '6.0.x' 2023-07-02 16:47:25 +02:00
Sam Brannen
a23c9cd53d Merge branch '6.0.x' 2023-07-01 17:42:28 +02:00
Sam Brannen
9ac2443b78 Polish ModuleResource[Tests] 2023-07-01 16:49:32 +02:00
Sébastien Deleuze
f075120675 Support WildcardType resolution in GenericTypeResolver
This commit adds support for WildcardType bounds resolution,
commonly seen in Kotlin due to declaration-site variance,
but also possible in Java even if less common.

Closes gh-22313
2023-06-30 15:26:32 +02:00
Sam Brannen
b8f091e2f6 Merge branch '6.0.x' 2023-06-30 14:17:49 +02:00
Johnny Lim
41f8b6926f Polish gh-30013
See gh-30013
2023-06-30 14:02:15 +02:00
Juergen Hoeller
b4ed3fbcd0 Upgrade to Checkstyle 10.12.1 2023-06-30 13:02:38 +02:00
Juergen Hoeller
83ec9f4fe7 Merge branch '6.0.x'
# Conflicts:
#	build.gradle
2023-06-30 13:00:04 +02:00
Seonghoon Kim
3f65b8506b Increase log level to error 2023-06-30 12:38:28 +02:00
Juergen Hoeller
50074f0e96 Merge branch '6.0.x' 2023-06-30 10:40:37 +02:00
Juergen Hoeller
31a51cca4f Support for getFilename() in ModuleResource
See gh-28507
2023-06-30 00:35:14 +02:00
Juergen Hoeller
654dee8cd6 Additional notes on module access via ClassPathResource
See gh-28507
2023-06-29 18:15:38 +02:00
Juergen Hoeller
7028de9dbd Merge branch '6.0.x' 2023-06-29 18:04:40 +02:00
Juergen Hoeller
e4751513a4 Additional notes on module access via ClassPathResource
See gh-28507
2023-06-29 17:54:53 +02:00
Sébastien Deleuze
bd7e2d2875 Change restore logging to info level
Closes gh-30775
2023-06-29 17:20:51 +02:00
Juergen Hoeller
6061fdf231 Introduce ModuleResource for resources loaded from a given Module
Closes gh-28507
2023-06-29 17:18:46 +02:00
Arjen Poutsma
9b662e8244 Typo 2023-06-29 15:36:31 +02:00
Arjen Poutsma
f51a640309 Polishing JdkClientHttpRequestFactory 2023-06-29 14:40:25 +02:00
Arjen Poutsma
48906afaf4 Polishing JettyClientHttpRequestFactory 2023-06-29 12:32:20 +02:00
Juergen Hoeller
ef4d93507d Merge branch '6.0.x' 2023-06-29 12:05:57 +02:00
Arjen Poutsma
d1d79babe7 Polishing JettyClientHttpRequestFactory 2023-06-28 16:19:13 +02:00
Juergen Hoeller
2eb8efe83b Merge branch '6.0.x' 2023-06-28 15:46:29 +02:00
Arjen Poutsma
dd57ec9fa0 Merge pull request #30478 from mdeinum:http-client
* gh-30478:
  Polishing external contribution
  HttpClient based ClientHttpRequestFactory
2023-06-28 12:28:24 +02:00
Arjen Poutsma
0033eb4ed6 Polishing external contribution
- Removed duplicate Client in types names.
- Removed buffering in favor of OutputStream to
  Flow.Publisher<ByteBuffer> bridge.
- Made request and types package private.
- Various other small improvements.

Closes gh-30478
2023-06-28 12:23:29 +02:00
Marten Deinum
2ca8dd2faa HttpClient based ClientHttpRequestFactory
As JDK17 is now the baseline it is possible to use the
HttpClient provided by Java.
2023-06-28 10:43:44 +02:00
Brian Clozel
c2e3fed8dc Align observations of @Scheduled with OTel conventions
This commit updates the `ScheduledTaskObservationDocumentation` to
better align the contributed KeyValues with OpenTelemetry conventions
for observations of code executions.

Instead of a "target.type" key with the bean class simple name, this
is now contributing the canonical class name of the bean under the
"code.namespace" key.
The "method.name" key is renamed to "code.function" and its values
remain unchanged.

Closes gh-30721
2023-06-27 22:20:06 +02:00
rstoyanchev
91eb2be44c Remove no longer supported protected methods
Closes gh-26721
2023-06-27 16:34:52 +01:00
rstoyanchev
d4ac90dae0 Support nested constructors in DataBinder
Closes gh-20806
2023-06-26 17:01:44 +01:00
rstoyanchev
11a416156b Use ResolvableType to create WebDataBinder
This provides more flexibility to pass a targetType even if
a MethodParameter is not available.

See gh-26721
2023-06-26 13:11:05 +01:00
Sam Brannen
3bf78d6f8c Fix AbstractMessageListenerContainer Javadoc regarding error log level
This commit updates AbstractMessageListenerContainer's Javadoc
regarding the log level used in invokeErrorHandler() so that the
documentation aligns with the implementation, namely that errors will
logged at WARN level if no ErrorHandler has been registered.

Closes gh-30730
2023-06-23 12:45:52 +02:00
Sam Brannen
563b2a8505 Polish AbstractMessageListenerContainer Javadoc 2023-06-23 12:44:57 +02:00
rstoyanchev
d37d6688d8 WebFlux constructs model attribute via DataBinder
See gh-26721
2023-06-23 11:15:00 +01:00
Sam Brannen
9ccbeec947 Ignore null message when introspecting resource cleanup failure
This commit fixes a regression introduced in conjunction with gh-27572.

See gh-30597
Closes gh-30729
2023-06-23 12:01:16 +02:00
rstoyanchev
801f01e23f Polishing in ModelAttributeMethodArgumentResolver
See gh-26721
2023-06-22 20:59:05 +01:00
rstoyanchev
ea398d7b7e Support constructing target object in DataBinder
See gh-26721
2023-06-22 20:36:28 +01:00
rstoyanchev
40bf923d7d Polishing in MultipartFileArgumentResolver
Closes gh-30728
2023-06-27 10:51:42 +01:00
Olga Maciaszek-Sharma
e69a1d22f9 Add MultipartFile support to HTTP interface client
See gh-30728
2023-06-27 09:55:24 +01:00
Juergen Hoeller
3f40452511 Merge branch '6.0.x' 2023-06-26 19:36:20 +02:00
Juergen Hoeller
2ccf4cab8b Polishing 2023-06-26 12:37:33 +02:00
Juergen Hoeller
feac983869 Merge branch '6.0.x' 2023-06-26 12:35:56 +02:00
Sébastien Deleuze
66b27e6dc8 Merge branch '6.0.x' 2023-06-26 12:03:40 +02:00