Commit Graph

4384 Commits

Author SHA1 Message Date
Juergen Hoeller 19cf503534 Align with Servlet 6.0 and introduce support for Jakarta WebSocket 2.1
Includes corresponding build upgrade to Tomcat 10.1.1 and Undertow 2.3.0
(while retaining runtime compatibility with Tomcat 10.0 and Undertow 2.2)

Closes gh-29435
Closes gh-29436
2022-11-06 16:08:30 +01:00
Sam Brannen ac5eb9bfd3 Avoid String allocations with Assert.isTrue() 2022-11-05 14:51:36 +01:00
Sam Brannen 82823517fa Merge branch '5.3.x'
# Conflicts:
#	build.gradle
#	spring-messaging/src/main/java/org/springframework/messaging/rsocket/DefaultRSocketRequesterBuilder.java
#	spring-messaging/src/main/java/org/springframework/messaging/rsocket/MetadataEncoder.java
#	spring-messaging/src/main/java/org/springframework/messaging/simp/broker/OrderedMessageChannelDecorator.java
#	spring-messaging/src/main/java/org/springframework/messaging/simp/user/DefaultUserDestinationResolver.java
#	spring-test/src/main/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilder.java
#	spring-web/src/main/java/org/springframework/http/HttpRange.java
#	spring-webflux/src/main/java/org/springframework/web/reactive/result/view/RedirectView.java
#	spring-webflux/src/main/java/org/springframework/web/reactive/socket/CloseStatus.java
#	spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/RedirectViewControllerRegistration.java
2022-11-05 14:50:18 +01:00
Sam Brannen 4207c4d757 Suppress warnings in tests 2022-11-05 14:44:36 +01:00
Sam Brannen 5f02323b9c Avoid String allocations with Assert.isTrue() 2022-11-05 14:40:45 +01:00
Sam Brannen 2afcf60566 Avoid String allocations with Assert.state() 2022-11-04 16:44:59 +01:00
Sam Brannen fff999f416 Polishing 2022-11-04 16:44:33 +01:00
Sam Brannen d849f9816a Merge branch '5.3.x'
# Conflicts:
#	build.gradle
#	spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/ScriptTemplateViewTests.java
#	spring-webmvc/src/main/java/org/springframework/web/servlet/view/script/ScriptTemplateView.java
#	spring-webmvc/src/test/java/org/springframework/web/servlet/view/script/ScriptTemplateViewTests.java
2022-11-04 16:29:54 +01:00
Sam Brannen deabd66939 Avoid String allocations with Assert.state() 2022-11-04 16:24:59 +01:00
Christoph Dreis 2a853aea67 Avoid String allocations in MediaType.checkParameters
Closes gh-29428
2022-11-04 16:24:59 +01:00
Sam Brannen a281d8c3fd Polishing 2022-11-04 16:24:59 +01:00
Brian Clozel 6022065ad3 Rename web observation documentation
Prior to this commit, several variants of observation documentation
would share the same name; for example HTTP client observations for both
blocking and reactive clients would have the same name.

While it is required that they have the same metric name for dashboards,
the observation documentation names should be different so that they can
be documented without confusing developers.

This commit renames the observation documentation names to avoid that.

Closes gh-29431
2022-11-04 15:38:32 +01:00
Sam Brannen d492086c76 Polishing 2022-11-03 16:02:19 +01:00
Brian Clozel a94b0e51e2 Align server contextual names with OTel conventions
This commit ensures that the matching path pattern for the request being
observed is used in the conytextual name, as advised in the OTel HTTP
server semantic conventions.

If the path pattern is not available, no additional value is provided
and the "http {method}" baseline is being used.

Fixes gh-29424
2022-11-02 20:57:41 +01:00
Marcin Grzejszczak c03ccb2e6c Propagate context in reactive HTTP server and client
Prior to this commit, the ServerHttpObservationFilter would not add
the current observation as a key in the Reactor context, preventing
from being used or propagated during the HTTP exchange handling.

Also, the client instrumentation in `DefaultWebClient` would start
the observation once the request is fully formed and immutable,
preventing the context from being propagated through HTTP request
headers.

This commit fixes both uses cases now by:

* adding the current observation as a key in the reactor context
  on the server side
* using the `ClientRequest.Builder` as a Carrier on the client side

Closes gh-29388
2022-11-02 16:25:50 +01:00
rstoyanchev 481389f761 Support `@RequestPart` for `@HttpExchange` methods
Closes gh-29420
2022-11-02 13:26:49 +00:00
rstoyanchev 4b647a1801 Minor refactoring in AbstractNamedValueArgumentResolver
Expose MethodParameter information in abstract protected method that
adds the HTTP request value.

See gh-29420
2022-11-02 13:26:49 +00:00
Arjen Poutsma 0ef96b893b Filter out empty PartEvents in PartEventHttpMessageWriter
This commit makes sure that PartEvents with empty data buffer are
filtered out before written. Empty buffers caused issues with the
JdkClientHttpConnector.

Closes gh-29400
2022-11-01 16:24:35 +01:00
rstoyanchev 921eeadff4 Minor refactoring after recent commits
See gh-29384
2022-11-01 13:56:40 +00:00
rstoyanchev e71057dca9 Support i8n of ProblemDetail "title" field
Closes gh-29407
2022-11-01 12:42:34 +00:00
rstoyanchev 506fbe5243 Improve mapping any Exception to ErrorResponse
Add protected, convenience method in ResponseEntityExceptionHandler
to create a ProblemDetail for any exception, along with a
MessageSource lookup for the "detail" field.

Closes gh-29384
2022-11-01 12:42:34 +00:00
Arjen Poutsma ca33752267 Upgrade to Jackson 2.14.0-rc3
This commit upgrades Jackson to 2.14.0-rc3, which resolves two
outstanding issues Spring Framework had with rc2. This commit reverts
the changes made due to those issues, see
https://github.com/FasterXML/jackson-core/issues/824, and
https://github.com/FasterXML/jackson-module-kotlin/issues/582.

Closes gh-29405
2022-10-31 10:35:10 +01:00
Arjen Poutsma 2ccfc7068e Merge branch '5.3.x' 2022-10-28 11:33:57 +02:00
Arjen Poutsma 46329851c1 Ensure state of PartGenerator accepts buffers
This commit makes sure that the current state of the PartGenerator
is able to handle an incoming buffer, possibly requested because of
a request coming from the subscription. All states accept new buffers
except the WritingFileState.

Closes gh-29227
2022-10-27 12:12:57 +02:00
rstoyanchev 5aeafc0761 Fix ISE in [Http|RSocket]ServiceProxyFactory
Closes gh-29376
2022-10-25 12:27:53 +01:00
Sébastien Deleuze 386d83545d Register proxy hints for HttpExchange annotations
Close gh-29271
2022-10-25 10:44:16 +02:00
Sébastien Deleuze e5b05586a3 Register reflection hints for HttpExchange annotations
See gh-29271
2022-10-25 10:44:16 +02:00
Brian Clozel 13c0c242b3 Revert "Revisit resource cleanup in ClientHttpRequestFactory"
Closes gh-29370
2022-10-24 10:52:07 +02:00
Brian Clozel 5e808ad018 Merge branch '5.3.x' 2022-10-21 15:24:08 +02:00
Brian Clozel 9410998897 Add caching headers to If-Unmodified-Since responses
Conditional requests using "If-Unmodified-Since" headers are generally
used as precondition checks for state-changing methods (POST, PUT,
DELETE). See https://datatracker.ietf.org/doc/html/rfc7232#section-3.4
The spec also allows for idempotent methods like GET and HEAD.

Prior to this commit, the "If-Unmodified-Since" processing done in
`checkNotModified` (see `ServletWebRequest` and
`DefaultServerWebExchange`) would only focus on the state changing
methods and not take into account the safe methods. For those cases, the
"ETag" and "Last-Modified" would be missing from the response.

This commit ensures that such headers are added as expected in these
cases.

Fixes gh-29362
2022-10-21 15:11:08 +02:00
Sébastien Deleuze 6dd3fb1411 Merge branch '5.3.x' 2022-10-21 09:38:03 +02:00
Brian Clozel fcbd5ec80a Avoid NPEs in DefaultServerRequestObservationConvention
In some cases, the default response status of a `ServerWebExchange` can
be `null`, especially when the response is not available or the server
implementation does not set a default response status.
This commit ensures that the status code is available when deriving
`KeyValue` information from it, or uses a fallback value for the key
value.

Fixes gh-29359
2022-10-20 14:31:41 +02:00
Brian Clozel 7e0a039291 Add ServerWebExchange getter in WebFlux Observation context
The observation context relies on request and response for propagation,
but the exchange itself holds attributes and locale context so this is
needed for keyvalues extraction in general.

This commit adds a getter to expose the exchange from the context.
2022-10-20 11:13:36 +02:00
Phillip Webb f93fda2a95 Guard against no-op observation
Update `ServerHttpObservationFilter` to check if the `Observation`
is a no-op before adding the `ServerRequestObservationContext`.

Prior to this commit, if the `Observation` is a no-op then the
context type added with the `CURRENT_OBSERVATION_CONTEXT_ATTRIBUTE`
would not be a `ServerRequestObservationContext`. This would mean
that `findObservationContext` would throw a `ClassCastException`.

Fixes gh-29356
2022-10-19 16:01:09 -07:00
Johnny Lim ba99672fd6 Suppress removal warnings
Closes gh-29325
2022-10-19 18:44:59 +02:00
rstoyanchev d4f7484252 Add Builder to RSocketServiceProxyFactory
RSocketServiceProxyFactory now support programmatic initialization
through a builder, while bean-style initialization is deprecated.

Closes gh-29296
2022-10-19 14:36:45 +01:00
Brian Clozel 57bbc09fca Do not set response status in ServerHttpObservationFilter
Prior to this commit, the `ServerHttpObservationFilter` would set the
response status (and possibly overwrite it) in case an exception is
found as an attribute.
While the exception itself should be used in the observation, the filter
should have no side effect on the response.

Fixes gh-29353
2022-10-19 12:11:00 +02:00
Arjen Poutsma f99c02fc94 Upgrade to Jackson 2.14.0-rc2
This commit upgrades Jackson to 2.14.0-rc2, and uses the new
ByteBufferFeeder in Jackson2Tokenizer.

Unfortunately, because of https://github.com/FasterXML/jackson-core/issues/478,
we had to change the CompilerConventions to suppress class file warnings.

Closes gh-29343
2022-10-19 11:05:40 +02:00
Sébastien Deleuze aa776e40f9 Ensure classpath checks can be evaluated at build-time
Closes gh-29352
2022-10-19 10:49:11 +02:00
Johnny Lim 5dca43ebd6 Use KeyValue.NONE_VALUE where possible
See https://github.com/micrometer-metrics/micrometer/issues/3458

Closes gh-29342
2022-10-19 09:32:57 +02:00
Sam Brannen 19f795a75a Suppress deprecation warnings in tests 2022-10-18 14:31:57 +02:00
Sam Brannen bfdf070232 Suppress deprecation warnings in tests 2022-10-18 14:21:57 +02:00
Johnny Lim d0a99c15c4 Make RestTemplate.createResourceAccessException() private
See gh-29313
2022-10-18 13:05:25 +02:00
Johnny Lim 7df8b59a7f Polish "Reorganize HTTP Observation types"
See gh-29334
2022-10-18 09:11:07 +09:00
Brian Clozel 001b2636d6 Reorganize HTTP Observation types
Closes gh-29334
2022-10-17 21:54:53 +02:00
rstoyanchev 5cb3af708c Add Builder to HttpServiceProxyFactory
HttpServiceProxyFactory now support programmatic initialization through
a builder, while bean-style initialization is deprecated.

See gh-29296
2022-10-17 12:23:58 +01:00
rstoyanchev 113db2fb2f Fix regression in AbstractJackson2Decoder
Closes gh-29307
2022-10-13 15:45:25 +01:00
Yanming Zhou 19cbba6b34 Use correct RFC number for ProblemDetail support in Javadoc
Closes gh-29302
2022-10-13 16:16:41 +02:00
Arjen Poutsma ce03980fb4 Mark HttpRequest::getMethodValue and ClientHttpResponse::getRawStatusCode for removal 2022-10-12 16:29:14 +02:00
Arjen Poutsma 2c58eea781 Mark HttpMethod::resolve for removal 2022-10-12 15:32:51 +02:00
Arjen Poutsma dedcb19f44 Document PartEvent API
Closes #29170
2022-10-11 16:28:41 +02:00
rstoyanchev cf2b1020f4 Update table of supported controller method return types
Closes gh-28814
2022-10-11 15:10:30 +01:00
Juergen Hoeller bba66429fb Polishing 2022-10-11 15:35:25 +02:00
Stephane Nicoll 45939720f2 Add native support for @ExceptionHandler
This commit makes sure that `@ExceptionHandler`-annotated methods can be
invoked via reflection in a native image. As most of the handling of
the parameter and the return type is shared with our generic
RequestMapping handling, the ReflectiveProcessor extends from it.

An `@ExceptionHandler`-annotated method can return a `ProblemDetail`. If
that's the case, reflection entries are contributed.

Closes gh-29297
2022-10-11 10:18:23 +02:00
Johnny Lim d4a08dae43 Fix typos in CorsConfiguration[Tests]
Closes gh-29292
2022-10-10 19:27:41 +02:00
Arjen Poutsma 8227032a0f Improve exception message if MultipartParser can not find end of body
This commit improves the exception message thrown by MultipartParser
when it cannot find the end of the multipart body, by showing in the
message what the parser is looking for (CRLF--<boundary>).

Closes gh-28067
2022-10-10 13:26:46 +02:00
Sébastien Deleuze 42c3ac64ff Remove spring.spel.ignore and spring.xml.ignore flags
This commit also removes ResourcePropertiesPersister which
was introduced in 5.3 specifically for spring.xml.ignore
flag and which is expected to be used only internally by
Spring Framework. DefaultPropertiesPersister should be used
instead.

Closes gh-29277
2022-10-10 12:11:19 +02:00
Arjen Poutsma 3e33912624 Deprecate streaming mode in DefaultPartHttpMessageReader
This commit deprecates the streaming mode of
DefaultPartHttpMessageReader, in favor of PartEvent and
PartEventHttpMessageReader.

Closes gh-29293
2022-10-10 11:49:30 +02:00
Johnny Lim 371fd06ae2 Use AssertJ static imports consistently in main
Closes gh-29282
2022-10-08 14:07:27 +02:00
Sam Brannen ae368a20b8 Merge branch '5.3.x'
# Conflicts:
#	spring-web/src/test/kotlin/org/springframework/http/codec/json/KotlinSerializationJsonDecoderTests.kt
#	spring-web/src/test/kotlin/org/springframework/http/codec/json/KotlinSerializationJsonEncoderTests.kt
2022-10-08 14:06:41 +02:00
Johnny Lim 1c1a0afbed Use AssertJ static imports consistently in 5.3.x
Closes gh-29282
2022-10-08 13:57:21 +02:00
Sam Brannen c98ed17728 Polishing 2022-10-08 13:43:09 +02:00
Johnny Lim ced37d53b4 Polishing
Closes gh-29284
2022-10-08 13:43:09 +02:00
rstoyanchev 16ea4692ba Drop Servlet 4 classpath check 2022-10-07 18:14:41 +01:00
rstoyanchev 1afc1fc90d Fix regression in AbstractJackson2Encoder
Closes gh-29274
2022-10-07 18:14:41 +01:00
Sam Brannen ba42deb7db Remove obsolete code 2022-10-07 14:12:04 +02:00
Brian Clozel 455a736a01 Switch to Micrometer 1.10.0-SNAPSHOT
See gh-29241
2022-10-06 14:08:07 +02:00
Iain Henderson b8243e6f84 Support CBOR and Protobuf with Kotlin Serialization
This commit introduces support for CBOR and Protobuf using Kotlin
serialization. Support comes in the form of Encoder/Decoder as well
as HttpMessageConverters. Seperate abstract base classes supply support
for binary and string (de)serialization.

The exising JSON codecs and message converters have been migrated to
use the new base classes.

Closes gh-27628
2022-10-06 13:51:50 +02:00
Juergen Hoeller 2a1807895e Upgrade to Tomcat 10.1 in web tests
Adapting to FileUpload API change: no FileItemFactory constructor argument anymore.
2022-10-06 12:33:56 +02:00
rstoyanchev ffe2ba4c7b Undo constructor deprecation + polishing 2022-10-05 20:04:39 +01:00
rstoyanchev b08f185a0b Use MethodArgumentNotValidException for model attributes
Closes gh-29251
2022-10-05 14:02:42 +01:00
rstoyanchev a4210854fb MessageSource support for Spring MVC and WebFlux exceptions
See gh-28814
2022-10-05 14:02:42 +01:00
Brian Clozel 681cf0dae7 Provide full request URL for "http.url" keyvalue
Prior to this commit, the Observation filter for Servlet applications
would only use the request pathInfo as an "http.url" high cardinality
keyvalue. This commit ensures that we're using the full request URL as a
value there.

This also polishes gh-29254.

Fixes gh-29257
See gh-29254
2022-10-05 11:40:28 +02:00
Brian Clozel 486a1b6024 Change keyvalue name to http.url in server observations
This commit changes the new high cardinality key value from
"uri.expanded" to "http.url" in order to align with the OTel
specification, since there is no need for backwards compatibility on
this new metadata.

Closes gh-29254
2022-10-05 09:55:42 +02:00
rstoyanchev 4d5b0c91a3 Polishing contribution
Closes gh-29247
2022-10-03 18:20:52 +01:00
Violeta Georgieva b5adae2086 Switch to Reactor Netty 2 snapshots
Update to Reactor BOM 2022.0.0-SNAPSHOT.
Process package changes.
Adapt to new `HttpHeaders` API.
Adapt to new cookies API.

See gh-29247
2022-10-03 18:20:52 +01: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
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
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
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
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
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
rstoyanchev badba7c3e9 Support coma-delimited format for origin values
Closes gh-27606
2022-09-27 14:49:18 +01:00
Arjen Poutsma d516667f37 Polish "Allow for CoroutineContext in invokeSuspendingFunction"
See gh-27193
2022-09-27 13:26:49 +02:00
Lukáš Křečan ff844ed99f Allow overriding invokeSuspendingFunction
This commit isolates the invocation of Kotlin coroutines into a separate
template method, so that it can be overridden in subclasses of
RequestMappingHandlerAdapter.

Closes gh-27195
2022-09-27 13:26:28 +02:00
Brian Clozel 1707a22c18 Merge branch '5.3.x' 2022-09-26 22:27:53 +02:00
Brian Clozel 9465110917 Polish
See gh-26707
2022-09-26 22:25:44 +02:00
chenrl b71e686cbd Fix ServletContextResource isFile check
Prior to this commit, `ServletContextResource` could rely on
`ServletContext#getRealPath` to check whether a resource exists.
This behavior is not enforced on some Servlet containers, as this method
is only meant to translate virtual paths to real paths, but not
necessarily check for the existence of the file.

See https://bz.apache.org/bugzilla/show_bug.cgi?id=55837#c3 for a
rationale of this behavior in Tomcat.

This commit enforces an additional check, resolving the path as a `File`
and checking that is exists and is a file.

Closes gh-26707
2022-09-26 22:20:15 +02:00
Brian Clozel 9c400ed384 Polish Stream#toList() consistent usage
In general, `Stream#toList()` is not a transparent replacement for
`.collect(Collectors.toList()))`, as the former returns an immutable
list.

This commit reverts some of those changes, where the returned `List`
instance was expected to be mutable.

See gh-29203
2022-09-26 20:25:13 +02:00
Adam Ostrožlík 0ccb64fe10 Replace Collectors.toList with Stream.toList
Closes gh-29203
2022-09-26 18:32:01 +02:00
Sam Brannen a975b9d5da Suppress "unused" warnings in tests 2022-09-26 14:27:32 +02:00
Sébastien Deleuze 42ab1b75e7 Fix a regression in Kotlin serialization support
After gh-29068, some Type instances can throw an
IllegalArgumentException. This commit catches them
properly to just return a null serializer in that
case.

Closes gh-29192
2022-09-26 09:55:44 +02:00
Johnny Lim 907c96b21e Polish "Deprecate support for theme" changes
See gh-29202
2022-09-26 08:46:19 +02:00
rstoyanchev 57067f58e1 Polishing contribution
Closes gh-28401
2022-09-23 16:54:15 +01:00
Laber, Jason M 27b5d141e2 Allow customization for ObjectReader and ObjectWriter
Allows customization from subclasses of
AbstractJackson2HttpMessageConverter, AbstractJackson2Decoder, and
AbstractJackson2Encoder

See gh-28401
2022-09-23 16:54:15 +01:00
rstoyanchev 74df50c906 Polishing ProblemDetail Javadoc 2022-09-23 16:54:02 +01:00
Arjen Poutsma ef5b64dc00 Minor Javadoc correction 2022-09-22 12:26:16 +02:00
rstoyanchev 5192d99fa4 Support formatting annotations on HTTP service interface
Closes gh-29095
2022-09-21 16:18:39 +01:00
Sébastien Deleuze 157c28bcec Enable HTTP and HTTPS on native in spring-web module
Closes gh-29185
2022-09-21 16:47:57 +02:00
Sam Brannen 321092ce6f Consistent use of @Deprecated(since = "6.0") 2022-09-20 14:34:24 +02:00
Sam Brannen 1263226928 Remove unused EMPTY_BUFFER constant
See gh-29038
2022-09-20 13:51:35 +02:00
Arjen Poutsma 990a34074a Upgrade RestTemplate to HttpClient 5
This commit upgrades the HttpComponentClientHttpRequestFactory and
related types from HttpClient version 4.5 to 5.

Closes gh-28925
2022-09-20 12:04:51 +02:00
Brian Clozel 4c45387805 Polish Observability instrumentation
This commit removes the scoping of `RestTemplate` requests, since no
user code is meant to run during HTTP client exchanges.

This also polishes the reactive `WebFilter` to directly use the
specific enum when creating the observation.
2022-09-19 10:05:42 +02:00
rstoyanchev 8f617780f7 Merge branch '5.3.x' 2022-09-14 19:28:45 +01:00
rstoyanchev ae8b7973b4 Improve Javadoc on RequestEntity#getUrl
Closes gh-28930
2022-09-14 19:25:55 +01:00
rstoyanchev f3c082abac Deprecate ignoreDefaultModelOnRedirect property
Closes gh-28324
2022-09-14 18:14:04 +01:00
rstoyanchev 02f61e3aae Fix failing test in CancelWithoutDemandCodecTests
The test started failing after recent commit
e370c15bc6.

See gh-29038
2022-09-14 16:43:35 +01:00
Sam Brannen b87d48b99b Merge branch '5.3.x' 2022-09-14 17:18:00 +02:00
Marc Wrobel ce49068ff9 Fix links in Javadoc and reference docs
- Fix broken links (by using a new URL, an alternative URL, or a
  Wayback Machine link)

- Use HTTPS where possible

- Remove https://issuetracker.springsource.com/browse/EBR-349: this
  link is dead and is also mentioned in
  https://jira.spring.io/browse/SPR-8093

- Clean up nohttp allowlist.lines

Closes gh-28876
2022-09-14 17:00:11 +02:00
Sam Brannen 8d92c57777 Merge branch '5.3.x'
# Conflicts:
#	spring-tx/src/main/java/org/springframework/jca/cci/core/support/CciDaoSupport.java
2022-09-14 16:52:55 +02:00
Marc Wrobel 92a231cf91 Fix typos in Javadoc, reference docs, and code
Closes gh-28822
2022-09-14 16:45:34 +02:00
Sam Brannen 992a81ab68 Merge branch '5.3.x'
# Conflicts:
#	spring-web/src/main/java/org/springframework/web/util/WebUtils.java
2022-09-14 16:12:04 +02:00
Sam Brannen 50dff77d01 Polish contribution 2022-09-14 16:08:01 +02:00
Marc Wrobel 0f479293b1 Replace use of the <tt> HTML tag in Javadoc
The <tt> HTML tag was used in HTML 4 to define teletype text. It is not
supported in HTML5, and its use is discouraged.

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/tt

Closes gh-28819
2022-09-14 15:56:16 +02:00
Sam Brannen 911d1f2dea Suppress warnings 2022-09-14 15:27:11 +02:00
rstoyanchev e370c15bc6 Fix error handling regression for non-streaming Flux
Closes gh-29038
2022-09-14 12:00:31 +01:00
Brian Clozel 19d991a67b Revisit resource cleanup in ClientHttpRequestFactory
Prior to this commit, resource management around
`ClientHttpRequestFactory` and `RestTemplate` was unclear. Some
factories implementation were implementing a `DisposableBean` and other
contracts were not managing request factory resources.

In the meantime, neither `ClientHttpRequestFactory` nor `RestTemplate`
are typically meant to be contributed as beans to the application
context. Most often, they're instantiated within beans and their
lifecycle should be managed by those.

This commit makes all `ClientHttpRequestFactory` `Closeable` and ensures
that all existing implementations have a similar behavior between
`dispose()` and `close()`. Since `RestTemplate` (actually
`HttpAccessor`) can instantiate factories on its own, they also now
extend `Closeable` to properly close those resources, if not externally
managed.

Closes gh-29010
2022-09-13 15:53:01 +02:00
Brian Clozel 241261b6b6 Polish
See gh-28341
2022-09-13 14:00:55 +02:00
Brian Clozel 82e47db28f Instrument reactive servers for Observability
This commit introduces a `HttpRequestsObservationWebFilter` which
instruments web frameworks using Spring's reactive `ServerHttpRequest`
and `ServerHttpResponse` interfaces.

This replaces Spring Boot's `MetricsWebFilter`.

See gh-28880
2022-09-12 11:38:20 +02:00
Brian Clozel 6eded96740 Instrument Servlet server apps for Observability
This commit introduces the new `HttpRequestsObservationFilter`
This `Filter` can be used to instrument Servlet-based web frameworks for
Micrometer Observations. While the Servlet request and responses are
automatically used for extracting KeyValues for observations, web
frameworks still need to provide the matching URL pattern, if supported.

This can be done by fetching the observation context from the request
attributes and contributing to it.

This commit instruments Spring MVC (annotation and functional variants),
effectively replacing Spring Boot's `WebMvcMetricsFilter`.

See gh-28880
2022-09-12 11:37:47 +02:00
Brian Clozel a0ddcd07c8 Instrument RestTemplate for Observability
This commit introduces Micrometer as an API dependency to the spring-web
module. Micrometer is used here to instrument `RestTemplate` and record
`Observation` for HTTP client exchanges.

This will replace Spring Boot's `MetricsClientHttpRequestInterceptor`
which uses the request interceptor contract for instrumentation.
This approach is limited as measurements and tags aren't always precise
and overhead is more important than a direct instrumentation.

See gh-28341
2022-09-12 11:37:41 +02:00
Brian Clozel f9dcd428ae Extract Mock HTTP client requests and responses
This commit extracts Mock HTTP client request and response for the
imperative variant. These are made available in the testFixtures
configuration for shared usage.
2022-09-12 11:36:26 +02:00
rstoyanchev 3c5888c43f Polishing
See gh-28847
2022-09-12 09:37:11 +01:00
rstoyanchev 2f4c39ba2a Add classpath detection for Reactor Netty 2
See gh-28847
2022-09-12 09:37:11 +01:00
유예본(Yebon You)/Platform Engineering팀/11ST fa1f7f6dc7 Use InputStream's contracts instead of StreamUtils
Since Spring Framework 6.0 requires Java 17, we can now use
`InputStream` new contracts when manipulating streams.

Closes gh-27702
2022-09-12 10:21:50 +02:00
Brian Clozel 0770d86936 Deprecate StreamUtils.emptyInput()
Closes gh-29125
2022-09-12 10:21:50 +02:00
Patrick Strawderman d4a74c8f9d Update StreamUtils drain and emptyInput to use JDK builtins
Update StreamUtils.drain to use InputStream.transferTo with a null
OutputStream. This avoids allocating buffers for cases where the
supplied InputStream has an optimized transferTo method (e.g.,
ByteArrayInputStream and FileInputStream).

Additionally, update StreamUtils.emptyInput to simply call
InputStream.nullInputStream.

Closes gh-28961
2022-09-12 10:21:50 +02:00
Sam Brannen 6d83a959fb Rename registerResourceIfNecessary to registerResource
This commit renames registerResourceIfNecessary() to registerResource()
and throws an exception if the class path resource does not exist.

Closes gh-29083
2022-09-10 19:49:56 +02:00
Brian Clozel 2b5ca63339 Fix serialization compiler warnings with Java 18
As of Java 18, the serial lint warning in javac has been expanded to
check for class fields that are not marked as `Serializable`.
See https://www.oracle.com/java/technologies/javase/18all-relnotes.html#JDK-8202056

In the Spring Framework codebase, this can happen with `Map`, `Set` or
`List` attributes which are often assigned with an unmodifiable
implementation variant. Such implementations are `Serializable` but
cannot be used as field types.

This commit ensures that the following changes are applied:
* fields are marked as transient if they can't be serialized
* classes are marked as `Serializable` if this was missing
* `@SuppressWarnings("serial")` is applied where relevant
2022-09-09 20:24:26 +02:00
Brian Clozel 1051fe7bee Improve InvocableHandlerMethod error handling
This commit improves the fix for gh-18491 for Java 18 as in this case
the exception message might not be null.
2022-09-09 20:20:29 +02:00
Brian Clozel 1dc3d5d2d6 Make HttpStatusCode extend Serializable
`HttpStatusCode` instance only hold an int value and are held by
`Serializable` classes, so this commit enforces this.

Without this change, Java 19+ will emit a compiler warning as
`Serializable` classes use `HttpStatusCode` as a field.
2022-09-09 19:56:00 +02:00
Brian Clozel c72c2ffc26 Polish
See gh-29114
2022-09-09 11:22:21 +02:00
Nheyll 058109315d Deprecate support for theme
As seen in gh-28868, the support for Themes is now deprecated as of
Spring Framework 6.0 and will be removed in a future release.

Closes gh-29114
2022-09-09 11:22:21 +02:00
rstoyanchev d373435856 Support for WebFlux on Reactor Netty 2 with Netty 5
See gh-28847
2022-09-08 21:54:46 +01:00
Sébastien Deleuze d6c49eec5a Polish WebUtilRuntimeHints
See gh-29112
2022-09-08 18:24:02 +02:00
Sébastien Deleuze bfa803baa4 Add resource hints for HtmlCharacterEntityReferences.properties
Closes gh-29112
2022-09-08 18:00:58 +02:00
Brian Clozel 616161f054 Merge branch '5.3.x' 2022-09-07 16:58:56 +02:00
Sam Brannen 26d2f7d12b Delete unused import 2022-09-07 16:55:20 +02:00
rstoyanchev 8423b2cab7 Add support for RSocket interface client
See gh-24456
2022-09-07 15:01:40 +01: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
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
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
Sébastien Deleuze f6db2cc35f Use serializerOrNull in Kotlin Serialization support
Closes gh-29068
2022-09-04 16:05:37 +02:00
Sébastien Deleuze f50c301387 Change BindingReflectionHintsRegistrar package
Move it to org.springframework.aot.hint.

See gh-28979
2022-09-02 19:31:26 +02:00
Sébastien Deleuze aaffb8b27e Move BindingReflectionHintsRegistrar to spring-core
See gh-28979
2022-09-02 17:31:43 +02:00
Sam Brannen 69f23095b8 Deprecate SynthesizedAnnotation and related methods
Since Spring no longer adds the SynthesizedAnnotation interface to the
JDK dynamic proxy used to synthesize an annotation, this commit
officially deprecates SynthesizedAnnotation and related methods in
RuntimeHintsUtils.

See gh-29041, gh-29054
Closes gh-29053
2022-09-02 12:04:17 +02:00
Sébastien Deleuze 7214b1e03c Merge branch '5.3.x' 2022-09-02 11:19:55 +02:00
junsu bb3ada4a67 Fix Kotlin Serialization converter registration logic
This commit fixes Kotlin Serialization converter
registration logic in RestTemplate,
AbstractMessageBrokerConfiguration and
AllEncompassingFormHttpMessageConverter classes
to be similar to the one in
WebMvcConfigurationSupport.

Closes gh-29008
2022-09-02 11:17:51 +02:00
Phillip Webb 505da5c602 Migrate hint registration to shortcuts
Migrate code to make use of the `MemberCategory` and `FieldMode`
shortcuts.

See gh-29011
2022-09-01 17:26:06 -07:00
Brian Clozel f877f81ae4 Move Netty 5 dependency to Framework platform 2022-08-30 21:58:41 +02:00
Andy Wilkinson a5fb55fd6d Replace dependency management plugin with built-in platform support 2022-08-30 17:03:24 +01:00
Arjen Poutsma 3eaf259f2d Polishing 2022-08-30 12:19:13 +02:00
Arjen Poutsma b5b51e73fc Merge branch '5.3.x' 2022-08-30 12:18:51 +02:00
Arjen Poutsma 4c0ece944a Fix race condition in PartGenerator
This commit fixes a race condition in PartGenerator, used by
DefaultPartHttpMessageReader. The condition can occur when a
completion signal comes in, and the state is changed to IdleFileState
at the same time.

Closes gh-28963
2022-08-30 12:11:22 +02:00
Sam Brannen b50415062b Clean up warnings and polish tests
This commit also modifies ResourceWebHandlerTests.getResourceFromFileSystem()
so that it passes in the IDE.
2022-08-26 15:20:16 +02:00
Sébastien Deleuze d16fa82888 Remove remaining native build-time class initializations
See oracle/graal#4673 related issue.

Closes gh-29018
2022-08-26 09:29:17 +02:00
Sébastien Deleuze 08f636b691 Introduce TypeHint.Builder#onReachableType(Class<?>)
Closes gh-29017
2022-08-26 08:34:54 +02:00
Arjen Poutsma 9c33d2707a Introduce support for Netty 5 Buffer
This commit introduces support for Netty 5's Buffer, in the form of
Netty5DataBuffer. Because of the new API offered by Buffer, several
changes have been made to the DataBuffer API:

- CloseableDataBuffer is a simpler alternative to PooledDataBuffer, and
  implemented by Netty5DataBuffer. DataBufferUtils::release can now
  handle CloseableDataBuffer as well as PooledDataBuffer.
- PooledDataBuffer::touch has been moved into a separate interface:
  TouchableDataBuffer, which is implemented by Netty5DataBuffer.
- The capacity of DataBuffers can no longer be reduced, they can only
  grow larger. As a consequence, DataBuffer::capacity(int) has been
  deprecated, but ensureWritable (formally ensureCapacity) still exists.
- DataBuffer::slice and retainedSlice have been deprecated in favor of
  split, a new method that ensures that memory regions do not overlap.
- DataBuffer::asByteBuffer has been deprecated in favor of toByteBuffer,
  a new method that returns a copy, instead of shared data.
- DataBufferFactory::allocateBuffer has been deprecated in favor of
  allocateBuffer(int).

Closes gh-28874
2022-08-25 11:00:22 +02:00
Stephane Nicoll 5aa8583159 Add shortcut to register an executable with a mode
See gh-29011
2022-08-24 19:32:02 +02:00
Stephane Nicoll c164b918c0 Apply consistent RuntimeHints defaults
This commit harmonizes the registration of an executable so that
the default method and the method that takes an empty customizer
produces the same hint. The same applies to the readable flag of
a field hint.

Rather than returning a list of executable modes, the "highest" mode
is retained.

See gh-29011
2022-08-24 19:32:01 +02:00
Stephane Nicoll 41e8683781 Polish 2022-08-23 14:41:32 +02:00
Stephane Nicoll 560f53dbf7 Polish 2022-08-23 14:34:20 +02:00
Sébastien Deleuze 2f920e8fb3 Polish JacksonModulesRuntimeHints
Closes gh-29001
2022-08-23 13:49:53 +02:00
Sébastien Deleuze 0973348bde Add classpath checks to JacksonModulesRuntimeHints
Closes gh-29001
2022-08-23 12:55:26 +02:00
Sébastien Deleuze 5525b17f19 Add missing condition in JacksonModulesRuntimeHints
Closes gh-29001
2022-08-23 12:11:42 +02:00
Stephane Nicoll d6afa8df2d Improve registration of the same hint for multiple classes
Based on the feedback in #28977 an easy way to create a list of
type references based on a vararg of classes is helpful when
registering the same hints for several types.
2022-08-18 06:52:34 +02:00
Stephane Nicoll 4f0c879778 Rationalize hints required for annotations
This commit updates RuntimeHintsUtils to focus on registering a JDK
proxy only as annotations of annotated elements that have at least
an introspection hints are visible out-of-the-box.

This commit also removes unnecessary hints and adapt `@Reflective` to
detect if a hint is required using the introduced
MergedAnnotation#isSynthesizable.

See gh-28967
2022-08-16 15:42:52 +02:00
Arjen Poutsma 59c2f4c069 Allow null for ResponseEntity.HeadersBuilder::eTag
Closes gh-28947
2022-08-16 12:02:00 +02:00
Sam Brannen a052f9a34e Polishing 2022-08-11 20:43:35 +02:00
Juergen Hoeller b31a15851e Support for pre-generated CGLIB proxy classes (in AOT scenarios)
Includes runtime storing of generated classes to a directory specified by the "cglib.generatedClasses" system property. Avoids lazy CGLIB fast-class generation and replaces generated Enhancer and MethodWrapper key classes with equivalent record types. Introduces support for early type determination in InstantiationStrategy, AopProxy and SmartInstantiationAwareBeanPostProcessor - in order to trigger CGLIB class generation in refreshForAotProcessing (through early determineBeanType calls for bean definitions).

Closes gh-28115
2022-08-10 23:30:19 +02:00
Vedran Pavic 7e719fe3f8 Use Jakarta EE XML namespaces instead of Java EE
Closes gh-28903
2022-08-04 13:24:30 +02:00
Stephane Nicoll 058b5fef6b Merge branch '5.3.x' 2022-08-02 16:11:16 +02:00
Johnny Lim d080b64907 Fix Javadoc since for new modules() and modulesToInstall()
See gh-28914
2022-08-02 16:10:47 +02:00
Stephane Nicoll 1bdb67cda9 Merge branch '5.3.x' 2022-07-29 17:13:52 +02:00
Arend v. Reinersdorff 67eb2bbf19 Clarify docs on JNDI properties in Servlet environment
See gh-28488
2022-07-29 17:05:58 +02:00
Stephane Nicoll c2f6d346d5 Merge branch '5.3.x' 2022-07-29 17:01:28 +02:00
Vedran Pavic 812b089f1d Add missing nullability annotations to ResponseCookie
See gh-28780
2022-07-29 16:54:37 +02:00
Rossen Stoyanchev 1aa4e7c68d Merge branch '5.3.x' 2022-07-29 16:20:51 +03:00
Rossen Stoyanchev 6e6f8637d1 Polishing contribution
Closes gh-28771
2022-07-29 14:45:42 +03:00
Johnny Lim 00f7f5ff0a Use MediaType.APPLICATION_FORM_URLENCODED_VALUE
See gh-28771
2022-07-29 14:40:45 +03:00
rstoyanchev f814fb420b Merge branch '5.3.x' 2022-07-13 19:21:33 +01:00
rstoyanchev e50131d454 Add Consumer methods to configure Jackson modules
Closes gh-28633
2022-07-13 19:10:51 +01:00
rstoyanchev cdd4e8cd7f Improve regex support for URL path matching
Closes gh-28815
2022-07-13 18:43:51 +01:00
Sam Brannen a81558ee5a Polishing 2022-07-13 16:58:59 +02:00
Sam Brannen 3ff1326cbb Merge branch '5.3.x' 2022-07-13 13:23:21 +02:00
Sam Brannen 222dbf8377 Update copyright date 2022-07-13 13:22:40 +02:00
kacperkrzyzak 10838a636f Correctly identify MaxUploadSizeExceededException in StandardMultipartHttpServletRequest
This commit correctly identifies MaxUploadSizeExceededException in
StandardMultipartHttpServletRequest by converting keywords in the
exception message to lowercase before checking for their presence, for
compatibility with Jetty 9.4.x.

Closes gh-28759
2022-07-13 13:17:53 +02:00
Stephane Nicoll 2c92d7da8f Harmonize RuntimeHintsRegistrar implementations
Closes gh-28801
2022-07-12 18:30:23 +02:00
rstoyanchev 380aedb12a Add ProblemDetailJacksonMixin
Closes gh-28665
2022-07-12 13:04:58 +01:00
Sam Brannen 3f993f8639 Merge branch '5.3.x'
# Conflicts:
#	spring-web/src/main/java/org/springframework/web/accept/AbstractMappingContentNegotiationStrategy.java
2022-07-12 12:14:52 +02:00
Marc Wrobel 6f494ef438 Fix and improve Javadoc in spring-web
Closes gh-28791
2022-07-12 12:08:12 +02:00
Sébastien Deleuze 9d42779826 Add reflection hints for data binding in Web controllers
Closes gh-28623
2022-07-11 11:41:33 +02:00
Arjen Poutsma a64d3716e0 Merge branch '5.3.x' 2022-07-08 16:43:28 +02:00
Arjen Poutsma aa8b06b622 Delete file on multipart cancel
This commit makes sure that the temporary file used for multipart
storage is deleted when the source stream is malformed or cancelled.

Closes gh-28740
2022-07-08 16:36:01 +02:00
rstoyanchev 0938909cd9 Switch to Reactor 2022.0.0 snapshots
See gh-28766
2022-07-06 11:58:28 +01:00
Sam Brannen adb2eef749 Clean up warnings and remove unused code 2022-07-03 18:56:47 +02:00
Johnny Lim 1205f53c4a Polish 2022-07-02 15:11:35 +09:00
rstoyanchev a575590c01 Merge branch '5.3.x' 2022-07-01 09:42:18 +01:00
rstoyanchev 058ce36402 Improve ExtendedWebExchangeDataBinder implementation
Close gh-28646
2022-07-01 03:23:32 +01:00
Sam Brannen 033d9d09e4 Merge branch '5.3.x' 2022-06-30 16:56:43 +02:00
Sam Brannen 9ea45697ac Support cookie comments in MockHttpServletResponse and MockCookie
Prior to this commit, if a cookie was added to MockHttpServletResponse,
the comment attribute was not included in the generated Set-Cookie
header. In addition, MockCookie.parse(String) did not support the
Comment attribute.

This commit addresses both of these issues.

Closes gh-28730
2022-06-30 16:51:43 +02:00
Sébastien Deleuze e94f2a8e3f Add Jackson well-known module runtime hints
Closes gh-28709
2022-06-30 15:26:44 +02:00
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