Commit Graph

4024 Commits

Author SHA1 Message Date
Sébastien Deleuze 9135921d1d Move BindingReflectionHintsRegistrar to spring-context
Closes gh-28735
2022-06-30 11:56:08 +02:00
Sébastien Deleuze 4ec3e1042a Add runtime hints for WebFlux
Closes gh-28701
2022-06-30 10:02:34 +02:00
rstoyanchev b312eca391 Deprecate and set trailingSlash option to false
Closes gh-28552
2022-06-29 16:09:10 +01:00
rstoyanchev 92cf1e13e8 Enable use of parsed patterns by default in Spring MVC
Closes gh-28607
2022-06-29 10:17:27 +01:00
rstoyanchev 8a9b082d8a Improve MappingMatch determination in mock request
MockHttpServletRequest now checks the requestURI and servletPath to
check whether they imply a Servlet path mapping, which is the case
when the requestURI is longer than the contextPath + servletPath.

This is essential when parsed patterns are in use in which case the
request path is parsed taking into account only the requestURI and
the contextPath. However, if the MappingMatch indicates a match by
Servlet path, then the servletPath is also taken into account.

See gh-28607
2022-06-29 10:17:07 +01:00
Sébastien Deleuze 798dd4fec0 Add missing build time class initialization
As gh-28624 supports only static boolean fields, we still
need a few classes to be initialized at build time.

Such explicit configuration should be in theory avoidable,
so we will work with the GraalVM team to see if this can be
fixed, see for example
https://github.com/oracle/graal/issues/4673
for HttpStatus.

See gh-28624
2022-06-27 19:08:20 +02:00
Sébastien Deleuze 22a750f378 Replace build-time initialization by constant fields
This commit leverages a subset of @philwebb initial experimentation
to compute at build time the value of specific boolean static fields
in native images. This enhancement is implemented for now as a
GraalVM feature.

The goal here is to keep an optimized footprint via build time code
removal without leveraging build-time class initialization which is known
for the blocking compatibility issues it introduces due to its viral nature.

For now, the static fields initialized at build time with native are:
 - NativeDetector#imageCode
 - Fields with a name ending by "Present" in "org.springframework" package
   typically used for classpath check with ClassUtils#isPresent

Closes gh-28624
2022-06-24 13:54:20 +02:00
rstoyanchev 98c7d8100d Remove "with" methods in ProblemDetail
ProblemDetail is intended to be extended with additional fields. This
commit removes its "with" methods for chained initialization to keep
it as plain as possible and avoid imposing a particular style on
subclasses.

See gh-27052
2022-06-24 11:08:32 +01:00
rstoyanchev c139f3d526 Add generic properties map to ProblemDetail
Closes gh-28665
2022-06-24 10:42:20 +01:00
rstoyanchev b72ee5f034 Add static factory methods to WebClientAdapter
Ideally one would pass WebClient directly to HttpServiceProxyFactory,
but two need to remain decoupled. This commit adds static, shortcut
methods to WebClientAdapter to create an HttpServiceProxyFactory, thus
eliminating the step to wrap the WebClient.
2022-06-24 09:55:21 +01:00
rstoyanchev 45ee7913bf Polishing ProblemDetail support
See gh-28665
2022-06-24 09:55:21 +01:00
Brian Clozel 0783f0762d Improve conditional requests support
Prior to this commit, Spring MVC and Spring WebFlux would not support
conditional requests with `If-Match` preconditions. As underlined in the
RFC9110 Section 13.1, those are related to the `If-None-Match`
conditions, but this time only performing requests if the resource
matches the given ETag.

This feature, and in general the `"*"` request Etag, are generally
useful to prevent "lost updates" when performing a POST/PUT request: we
want to ensure that we're updating a version with a known version or
create a new resource only if it doesn't exist already.

This commit adds `If-Match` conditional requests support and ensures
that both `If-Match` and `If-None-Match` work well with `"*"` request
ETags.

We can't rely on `checkNotModified(null)`, as the compiler can't decide
between method variants accepting an ETag `String` or a Last Modified
`long`. Instead, developers should use empty ETags `""` to signal that
no resource is known on the server side.

Closes gh-24881
2022-06-21 19:29:20 +02:00
Sébastien Deleuze 93b340e563 Add reflection hints for HttpEntity
For those used in Web controllers.

Closes gh-28622
2022-06-20 18:15:43 +02:00
Sam Brannen 04dde03451 Merge branch '5.3.x' 2022-06-20 16:03:09 +02:00
Sam Brannen e19e9757d4 Polishing 2022-06-20 15:19:02 +02:00
Lars Grefer 181023c0c3 Update to Bouncycastle 1.71
Closes gh-28636
2022-06-16 16:03:11 +02:00
Lars Grefer f41b99218e Update to Bouncycastle 1.71 2022-06-16 03:21:41 +02:00
Juergen Hoeller aa48dec697 Merge branch '5.3.x'
# Conflicts:
#	build.gradle
#	spring-jms/src/main/java/org/springframework/jms/connection/CachingConnectionFactory.java
2022-06-14 15:14:10 +02:00
Juergen Hoeller d7be1e0dab Polishing 2022-06-14 15:09:39 +02:00
Juergen Hoeller 30c873b4b5 Move NestedServletExceptionTests to spring-web module
See gh-25162
2022-06-14 15:09:21 +02:00
Stephane Nicoll 77ad4a1428 Polish 2022-06-14 14:15:29 +02:00
Juergen Hoeller 639c047f2f Apply StringUtils.cleanPath for Windows path compatibility
See gh-28006
2022-06-14 14:02:17 +02:00
Juergen Hoeller 4e1b9f1492 Replace deep exception message nesting with custom inclusion of cause messages
Includes deprecation of NestedServletException, whereas NestedCheckedException and NestedRuntimeException remain as base classes with several convenience methods.

Closes gh-25162
2022-06-14 14:00:28 +02:00
Arjen Poutsma 1881e48bb4 Remove Jetty dependencies from JdkHttpClientResourceFactory
This commit removes the Eclipse Jetty dependencies from
JdkHttpClientResourceFactory, replacing them with a check for
ExecutorService.

Closes gh-28588
2022-06-14 10:59:02 +02:00
Sébastien Deleuze a57dead4be Add support for serialization in RequestMappingReflectiveProcessor
Support reflection-based serialization of parameters annotated
with @RequestBody and return values annotated with @ResponseBody.

It leverages a new BindingReflectionHintsRegistrar class that
is designed to register transitively the types usually needed
for binding and reflection-based serialization on fields,
constructors and properties. Generics are taken in account
as well.

Closes gh-28518
2022-06-13 15:25:44 +02:00
Sébastien Deleuze 2b76a12b86 Refine build time init configuration
For Spring MVC and RestTemplate.

See gh-28518
2022-06-13 14:54:57 +02:00
Stephane Nicoll 0992f855e6 Add base infra for Web controllers hints
See gh-28518
2022-06-13 14:52:45 +02:00
Arjen Poutsma 472af9c25f Merge branch '5.3.x' 2022-06-13 14:02:02 +02:00
Arjen Poutsma c278d8c656 Do not ignore charset in Jaxb2XmlDecoder
This commit makes sure that the charset, if defined in the mimetype, is
used when decoding XML to JAXB2 objects.

Closes gh-28599
2022-06-13 13:47:31 +02:00
Sam Brannen 74d1be9bd8 Remove obsolete references to @Required
Since the @Required annotation was removed in a previous 6.0 milestone,
this commit removes all remaining references to it.

Closes gh-28600
2022-06-09 14:54:09 +02:00
rstoyanchev 2269c0063a Restore base class of MissingServletRequestPartException
Effectively reverts commit #ad2722.

Closes gh-28455
2022-06-01 18:18:16 +01:00
rstoyanchev cc56da7735 Support default methods in @HttpExchange interface
Closes gh-28491
2022-06-01 17:49:19 +01:00
Sam Brannen ee209de9cf Merge branch '5.3.x'
# Conflicts:
#	spring-beans/src/test/java/org/springframework/beans/factory/support/security/CallbacksSecurityTests.java
#	spring-context/src/test/java/org/springframework/ejb/access/LocalSlsbInvokerInterceptorTests.java
#	spring-context/src/test/java/org/springframework/ejb/access/SimpleRemoteSlsbInvokerInterceptorTests.java
#	spring-web/src/test/java/org/springframework/remoting/jaxws/JaxWsSupportTests.java
#	spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/ViewResolutionIntegrationTests.java
2022-05-31 14:15:36 +02:00
Sam Brannen 1beb7068f6 Use new AssertJ exception assertions 2022-05-31 14:08:28 +02:00
Sam Brannen 720261db26 Use List.of() and Set.of() where feasible 2022-05-30 18:42:48 +02:00
Sam Brannen b629487b44 Polish Javadoc for MockFilterChain 2022-05-30 18:41:25 +02:00
Sam Brannen 9e1d0057bc Merge branch '5.3.x' 2022-05-25 11:30:42 +02:00
Sam Brannen a221835558 Throw IllegalStateException for invalid port in HierarchicalUriComponents
Prior to this commit, getPort() in HierarchicalUriComponents threw a
NumberFormatException for an invalid port supplied as a String, which
was inconsistent with exception handling elsewhere in the class as well
as within the same method.

This commit introduces a try-catch block in getPort() to consistently
throw IllegalStateExceptions for ports that cannot be parsed.

Closes gh-28521
2022-05-25 11:29:12 +02:00
Sam Brannen aa06a09dee Polishing 2022-05-25 11:29:12 +02:00
rstoyanchev ff890bc1cc Support custom HTTP method for @HttpExchange
Closes gh-28504
2022-05-24 09:27:35 +01:00
rstoyanchev 48c1746693 Refactor HttpServiceProxyFactory for use as a bean
Closes gh-28505
2022-05-24 09:27:17 +01:00
rstoyanchev 2a2fba6a37 Resolve placeholders in HttpExchange#url
Closes gh-28492
2022-05-23 11:06:14 +01:00
rstoyanchev ce568468ae Refine JSON encoding of non-streaming Flux
Closes gh-28398
2022-05-23 11:06:14 +01:00
rstoyanchev 496c1dcae1 Add RequestAttributeArgumentResolver
Closes gh-28458
2022-05-23 11:06:14 +01:00
rstoyanchev 495507e5d4 AbstractNamedValueArgumentResolver supports Object values
See gh-28458
2022-05-23 11:06:14 +01:00
Sam Brannen 16a4a9ad3f Polishing 2022-05-21 14:30:46 +02:00
Sam Brannen ea9b1fccbd Fix attribute return types in @PutExchange
The return types for the `value` and `url` attributes don't match those
in `@HttpExchange`.

See gh-28498
2022-05-21 14:28:47 +02:00
Eddú Meléndez 163bad38ef Fix attribute return types in @DeleteExchange and @PatchExchange
The return types for the `value` and `url` attributes don't match those
in `@HttpExchange`.

Closes gh-28498
2022-05-21 14:25:00 +02:00
wonwoo 9181ac70f5 Correctly detect Optional return type for @HttpExchange methods
Prior to this commit, a ClassCastException was thrown for an Optional
return type for an @HttpExchange method. This is because the check for
an Optional return type was based on the type contained in the Optional
instead of the Optional itself.

Closes gh-28493
2022-05-20 11:25:31 +02:00
Sam Brannen 578d3f4466 Polish error message 2022-05-17 11:22:56 +02:00
Sam Brannen 0d4d383068 Merge branch '5.3.x' 2022-05-16 11:22:17 +02:00
Sam Brannen 6efe3aee34 Polishing 2022-05-16 11:20:20 +02:00
Juergen Hoeller a8c3c746af Avoid package cycle with web.service.invoker through plain javadoc reference
See gh-28386
2022-05-12 13:17:12 +02:00
rstoyanchev f0e23b66f3 The "consumes" condition compares MediaType parameters
Closes gh-9257
2022-05-11 17:52:04 +01:00
Sam Brannen eb50a6f4a0 Further polishing regarding JDK baseline upgrade
See gh-28440
2022-05-10 17:01:40 +02:00
lihan a892ce80c1 Polishing regarding JDK baseline upgrade
Closes gh-28440
2022-05-10 17:01:40 +02:00
Juergen Hoeller c1a5b462c2 Merge branch '5.3.x'
# Conflicts:
#	build.gradle
2022-05-10 13:39:31 +02:00
Arjen Poutsma e29bc3db7c Refactor PartGenerator to use isLast
This commit refactors the PartGenerator to use the newly introduced
Token::isLast property.

See gh-28006
2022-05-10 13:16:37 +02:00
Juergen Hoeller c81e11d537 Polishing 2022-05-10 13:07:00 +02:00
rstoyanchev 922636e85e Content decoding in client exceptions
Closes gh-28190
2022-05-10 11:48:46 +01:00
rstoyanchev 64795664b2 Add ClientHttpResponseDecorator
See gh-28190
2022-05-10 11:48:46 +01:00
rstoyanchev 6b1a8452fa Polishing 2022-05-10 11:48:46 +01:00
Sam Brannen d45b5f6e8a Merge branch '5.3.x'
# Conflicts:
#	spring-webflux/src/main/java/org/springframework/web/reactive/resource/VersionResourceResolver.java
#	spring-webmvc/src/main/java/org/springframework/web/servlet/resource/VersionResourceResolver.java
2022-05-10 11:44:14 +02:00
Sam Brannen 1c10cdd1e8 Update copyright dates
See gh-28433
2022-05-10 11:33:32 +02:00
evgeny.bovykin 941b92cbed Make inner classes static when feasible
A static nested class does not keep an implicit reference to its
enclosing instance.

This prevents a common cause of memory leaks and uses less memory per
instance of the class.

Closes gh-28433
2022-05-10 11:32:37 +02:00
rstoyanchev 78ab4d7118 Support content negotiation for RFC 7807
Closes gh-28189
2022-05-09 18:32:21 +01:00
Sam Brannen f7d032c924 Polish formatting 2022-05-09 15:31:53 +02:00
rstoyanchev 5d0f49c2c8 Add WebInputException subclasses
Closes gh-28142
2022-05-09 09:52:15 +01:00
Sam Brannen 5641584a89 Merge branch '5.3.x' 2022-05-05 16:11:36 +02:00
neals e22a038725 Remove Log4J initialization from package-info.java
Closes gh-28420
2022-05-05 16:10:59 +02:00
Sam Brannen 365a18c9c2 Polishing 2022-05-03 15:46:07 +02:00
rstoyanchev 2d2726b8f7 Add RequestBody resolver and minor improvements
Support for RequestBody arguments.
List supported arguments on HttpExchange.
Improve null handling.

See gh-28386
2022-05-03 12:42:37 +01:00
rstoyanchev 7797453f28 Refactor resolver tests
Extract NamedValueArgumentResolverTests.
Move form data vs query params tests into HttpRequestValues.

See gh-28386
2022-05-03 12:42:37 +01:00
rstoyanchev 2794553d2e Add resolvers for URI, cookies, and request params
See gh-28386
2022-05-03 12:42:37 +01:00
rstoyanchev f8ac5985bd Extract base class AbstractNamedValueArgumentResolver
Closes gh-28395
2022-05-03 12:42:37 +01:00
rstoyanchev d91b840d0e Polishing and refactoring
See gh-28395
2022-05-03 12:42:37 +01:00
Olga Maciaszek-Sharma 38bf0776a1 Add initial RequestHeaderArgumentResolver implementation and tests. 2022-05-03 12:42:37 +01:00
Arjen Poutsma efafccde2b Polish contribution & Support multiple quoted printable segments in Content-Disposition
This commit polishes the contribution for support of multiple
base64 segments, and adds supports for multiple quoted printable
segments in Content-Disposition.

Closes gh-28236
2022-04-29 12:38:42 +02:00
Alex Lei 195b622411 Support multiple base64 segments in Content-Disposition
See gh-28236
2022-04-29 12:36:42 +02:00
Arjen Poutsma 217117ced0 Remove Jakarta Mail dependency from spring-web
This commit removes the dependency that the spring-web module has on
Jakarta Mail.

In FormHttpMessageConverter, a dependency on
jakarta.mail.internet.MimeUtility was replaced by existing encoding
logic in ContentDisposition.

In StandardMultipartHttpServletRequest, a dependency on the same
MimeUtility was replaced by new quoted-printable decoding logic in
ContentDisposition.

Closes gh-28392
2022-04-28 15:39:52 +02:00
rstoyanchev b4e6014a14 Merge branch '5.3.x' into main 2022-04-28 11:40:11 +01:00
rstoyanchev f0d149b330 Polishing contribution
Closes gh-27830
2022-04-28 11:26:50 +01:00
binchoo caaf83b8e6 Add tests for binding to a Part field
See gh-27830
2022-04-28 10:45:09 +01:00
rstoyanchev 62ab360f64 Update HttpMethodArgumentResolver
Boolean return value indicates if the value was resolved or not.

See gh-28386
2022-04-27 21:21:43 +01:00
rstoyanchev b1384ddafa Add HttpServiceProxyFactory builder
See gh-28386
2022-04-27 21:21:43 +01:00
rstoyanchev 8a46e96875 Add remaining HttpExchange annotations
See gh-28386
2022-04-27 21:21:43 +01:00
rstoyanchev d7ab5b4132 Refactor HttpRequestSpec to HttpRequestValues
HttpRequestValues is immutable and exposes a builder.

See gh-28386
2022-04-27 21:21:43 +01:00
rstoyanchev 564f8ba7a0 Update after review
See gh-28386
2022-04-27 21:21:43 +01:00
rstoyanchev bb44c0e13a Polishing
See gh-28386
2022-04-27 21:21:43 +01:00
rstoyanchev 4bddbd30c4 Polishing contribution
See gh-28386
2022-04-27 21:21:43 +01:00
Olga Maciaszek-Sharma c2a008fc22 Add HttpMethod and PathVariable argument resolvers
See gh-28386
2022-04-27 21:21:43 +01:00
rstoyanchev c418768f05 Add @HttpRequest and HttpServiceProxyFactory
See gh-28386
2022-04-27 21:21:43 +01:00
Stephane Nicoll ccb66247ce Merge branch '5.3.x' 2022-04-24 10:05:35 +02:00
izeye fcf64798b5 Add Javadoc since for GraphQL constants
See gh-28369
2022-04-24 09:58:50 +02:00
Arjen Poutsma be7fa3aaa8 Introduce PartEvent
This commit introduces the PartEvent API. PartEvents are either
- FormPartEvents, representing a form field, or
- FilePartEvents, representing a file upload.

The PartEventHttpMessageReader is a HttpMessageReader that splits
multipart data into a stream of PartEvents. Form fields generate one
FormPartEvent; file uploads produce at least one FilePartEvent. The last
element that makes up a particular part will have isLast set to true.

The PartEventHttpMessageWriter is a HttpMessageWriter that writes a
Publisher<PartEvent> to a outgoing HTTP message. This writer is
particularly useful for relaying a multipart request on the server.

Closes gh-28006
2022-04-20 11:00:07 +02:00
Sam Brannen 1574fed90b Merge branch '5.3.x' 2022-04-13 10:08:31 +02:00
Sam Brannen a7cf19cec5 Improve documentation and matching algorithm in data binders 2022-04-13 09:55:40 +02:00
Juergen Hoeller 8744952424 Merge branch '5.3.x' 2022-04-13 00:28:22 +02:00
Juergen Hoeller 0cf7f7bd89 Polishing 2022-04-13 00:24:23 +02:00
Arjen Poutsma 6e9a662290 Merge branch '5.3.x' 2022-04-12 16:52:49 +02:00