Commit Graph

4846 Commits

Author SHA1 Message Date
Juergen Hoeller 7adc2f0779 Upgrade to Tomcat 10.1.16 and Jetty 12.0.4 2023-12-12 14:26:56 +01:00
Arjen Poutsma 134bb6e31f Document exception wrapping in RestClient status handlers
This commit documents the fact that any (Unchecked)IOExceptions or
HttpMessageNotReadableExceptions thrown from the error handler will be
wrapped in a RestClientException.

Closes gh-31783
2023-12-12 13:34:16 +01:00
Arjen Poutsma 57b8100a06 Copy headers map in RestClientResponseException to ensure serializability
This commit ensures that the HttpHeaders used are serializable by making
 a copy.

Closes gh-31787
2023-12-11 14:02:31 +01:00
Sébastien Deleuze d75a7c3818 Support multiple CoWebFilter changing the context
This commit ensures CoWebFilter merges the exchange
CoroutineContext with the filter one if needed.

Closes gh-31792
2023-12-11 11:35:19 +01:00
Sébastien Deleuze 91b9a75371 Box Kotlin value class parameters in web endpoint
In order to avoid "java.lang.IllegalArgumentException:
object is not an instance of declaring class" errors.

Closes gh-31698
2023-12-08 15:27:08 +01:00
Rossen Stoyanchev 2e07f9ab33 DefaultWebClient exposes full URI template as request attribute
Closes gh-30027
2023-12-07 12:16:22 +00:00
Sam Brannen 438c3818cc Replace System.getProperties().remove(x) with System.clearProperty(x)
This commit migrates to the not-so-new System.clearProperty() method
introduced in Java 1.5.
2023-12-06 17:11:46 +01:00
Sébastien Deleuze d410872e4f Polish CookieIntegrationTests 2023-12-06 15:01:09 +01:00
Sébastien Deleuze 8fe2c780df Support cookies with the same name with Reactor Netty
Ignore the related test with Undertow due to a bug in
their cookies handling.

Closes gh-28490
2023-12-06 15:01:09 +01:00
Arjen Poutsma 0e6c17f518 Process tokens after each feed in Jackson2Tokenizer
This commit ensures that we process after each fed buffer in
Jackson2Tokenizer, instead of after all fed buffers.

Closes gh-31747
2023-12-06 14:31:05 +01:00
Arjen Poutsma ef4ffa0005 Support empty part in DefaultPartHttpMessageReader
This commit fixes a bug in DefaultPartHttpMessageReader's
MultipartParser, due to which the last token in a part window was not
properly indicated.

Closes gh-30953
2023-12-06 12:21:37 +01:00
Yanming Zhou afcd03bddc Replace assertThat(x.isEmpty()).isTrue() with assertThat(x).isEmpty()
Search for   : assertThat\((.+).isEmpty\(\)\).isTrue\(\)
Replace with : assertThat($1).isEmpty()

Search for   : assertThat\((.+).isEmpty\(\)\).isFalse\(\)
Replace with : assertThat($1).isNotEmpty()

Closes gh-31758
2023-12-06 10:04:56 +01:00
Yanming Zhou 7b16ef90f1 Replace assertThat(x.equals(y)) with assertThat(x).isEqualTo(y)
Search for   : assertThat\((.+)\.equals\((\w+)\)\)\.isTrue\(\)
Replace with : assertThat($1).isEqualTo($2)

Search for   : assertThat\((.+)\.equals\((\w+)\)\)\.isFalse\(\)
Replace with : assertThat($1).isNotEqualTo($2)

Closes gh-31763
2023-12-06 09:50:15 +01:00
Yanming Zhou 59815cefce Replace assertThat(x.get(i)). with assertThat(x).element(i).
Search for   : assertThat\((.+)\.get\((\d+)\)\)\.
Replace with : assertThat($1).element($2).

Closes gh-31759
2023-12-06 09:43:59 +01:00
Sam Brannen c74d60b9fe Polishing 2023-12-05 16:14:13 +01:00
Sam Brannen db48813181 Polish contribution
See gh-31757
2023-12-05 16:14:13 +01:00
Yanming Zhou 6f11716b6f Use idiomatic AssertJ map assertions
See gh-31752
2023-12-05 10:01:38 +01:00
Sam Brannen 62b3d7a963 Update copyright headers 2023-12-04 16:47:25 +01:00
Yanming Zhou 490b5c77fc Use switch expression where feasible 2023-12-04 15:42:55 +01:00
Patrick Strawderman 7cdacf3083 Introduce toString(Charset) in FastByteArrayOutputStream
This commit introduces a toString() overload in
FastByteArrayOutputStream that accepts a Charset in order to mirror the
method that was introduced in ByteArrayOutputStream in JDK 10,
including a special case for when a single buffer is in use internally
to avoid the need to resize.

This commit also updates getContentAsString() in
ContentCachingRequestWrapper to use this new toString(Charset) method.

Closes gh-31737
2023-12-02 16:31:28 +01:00
Sam Brannen 47cdc7c5f0 Update copyright headers
See gh-31738
2023-12-02 15:32:46 +01:00
dogglezz decb22a93d Polish Javadoc
Closes gh-31738
2023-12-02 15:31:39 +01:00
Arjen Poutsma d204dd2dbe Use IntrospectingClientHttpResponse in RestClient
This commit ensures that the RestClient uses the
IntrospectingClientHttpResponse to verify whether the response has a
body, and return null if it does not.

See gh-12671
Closes gh-31719
2023-12-01 14:22:58 +01:00
Patrick Strawderman e452c2e89c Avoid byte array copy in getContentAsString
The getContentAsString method was originally added in d9b8826 to avoid
the extra copying inherent to calling ByteArrayOutputStream.toByteArray;
however, in f83c609 the class was updated to instead use
FastByteArrayOutputStream, and in the process the extra copy was brought
back when getContentAsString was changed to call toByteArray.

Switch to calling toByteArrayUnsafe, a method provided by
FastByteArrayOutputStream, which avoids the extra copy; since we
immediately pass the byte array to the String constructor, and it isn't
accessed anywhere else, the usage is safe.

See gh-31731
2023-12-01 10:47:38 +01:00
Sam Brannen 6ea9fdbf77 Polishing 2023-11-30 19:04:59 +01:00
rstoyanchev 8090a52f5c ForwardedHeaderFilter supports ERROR requestUri attribute
Closes gh-30828
2023-11-30 13:10:17 +00:00
rstoyanchev 19bca03aa2 Polishing in ForwardedHeaderFilter
See gh-30828
2023-11-30 13:10:17 +00:00
rstoyanchev 8ca82120e0 Add missing exception name to DisconnectedClientHelper
Closes gh-31717
2023-11-30 13:10:17 +00:00
rstoyanchev 9ade52dbe2 Exclude Part and MultipartFile from nested constructor binding
Closes gh-31669
2023-11-30 13:10:17 +00:00
Brian Clozel 35fcbae8c6 Fix reactive HTTP server Observation instrumentation
Prior to this commit, regressions were introduced with gh-31417:

1. the observation keyvalues would be inconsistent with the HTTP response
2. the observation scope would not cover all controller handlers, causing
  traceIds to be missing

The first issue is caused by the fact that in case of error signals, the
observation was stopped before the response was fully committed, which
means further processing could happen and update the response status.
This commit delays the stop event until the response is committed in
case of errors.

The second problem is caused by the change from a `contextWrite`
operator to using the `tap` operator with a `SignalListener`. The
observation was started in the `doOnSubscription` callback, which is too
late in some cases. If the WebFlux controller handler is synchronous
non-blocking, the execution of the handler is performed before the
subscription happens. This means that for those handlers, the
observation was not started, even if the current observation was
present in the reactor context. This commit changes the
`doOnSubscription` to `doFirst` to ensure that the observation is
started at the right time.

Fixes gh-31703
Fixes gh-31706
2023-11-29 14:39:56 +01:00
Sam Brannen 657b1c6455 Document need for -parameters flag in exception messages
Closes gh-31675
2023-11-25 14:53:56 +01:00
Stéphane Nicoll 487dbf8140 Polish "Polish RestClient Javadoc"
See gh-31659
2023-11-23 12:59:03 +01:00
johannesrost e95f8d2922 Polish RestClient Javadoc
See gh-31659
2023-11-23 12:38:16 +01:00
Brian Clozel d50b51e312 Fix ordering of releasing resources in JSON Encoder
Prior to this commit, the Jackson 2.x encoders, in case of encoding a
stream of data, would first release the `ByteArrayBuilder` and then the
`JsonGenerator`. This order is inconsistent with the single value
variant (see `o.s.h.codec.json.AbstractJackson2Encoder#encodeValue`) and
invalid since the `JsonGenerator` uses internally the
`ByteArrayBuilder`.

In case of a CSV Encoder, the codec can buffer data to write the column
names of the CSV file. Writing an empty Flux with this Encoder would not
fail but still log a NullPointerException ignored by the reactive
pipeline.

This commit fixes the order and avoid such issues at runtime.

Fixes gh-30493
2023-11-22 18:21:06 +01:00
Sébastien Deleuze 441e210533 Treat kotlin.Unit as void in web controllers
This commit fixes a regression introduced by gh-21139
via the usage of Kotlin reflection to invoke HTTP
handler methods. It ensures that kotlin.Unit is treated
as void by returning null.

It also polishes CoroutinesUtils to have a consistent
handling compared to the regular case, and adds related
tests to prevent future regressions.

Closes gh-31648
2023-11-22 13:45:03 +01:00
Arjen Poutsma e6ab8a6d61 Remove attributes from RestClient
This commit removes any references to attributes from RestClient, which
were left by mistake.

Closes gh-31625
2023-11-21 16:12:06 +01:00
Juergen Hoeller 99378fe947 Polishing 2023-11-16 11:22:09 +01:00
Brian Clozel c02f735056 Merge branch '6.0.x' 2023-11-16 09:04:09 +01:00
Brian Clozel c18784678d Reduce allocations in server conventions
This commit optimizes the default observation conventions to reduce
`KeyValues` allocations.
2023-11-16 09:00:24 +01:00
Stéphane Nicoll f15b8b95ad Merge branch '6.0.x' 2023-11-15 19:04:11 +01:00
Stéphane Nicoll 4464251754 Add missing runtime hints for ProblemDetail mixins
Closes gh-31606
2023-11-15 18:44:17 +01:00
Arjen Poutsma 8f21479234 Add body conversion capabilities in RestClient::exchange
This commit introduces a ConvertibleClientHttpResponse type that
extends ClientHttpResponse, and that can convert the body to a desired
type. Before this commit, it was not easy to use the configured HTTP
message converters in combination with RestClient::exchange.

Closes gh-31597
2023-11-14 11:18:59 +01:00
Stéphane Nicoll 7f615fd8af Fix reference in deprecation message of parseForwardedFor 2023-11-11 18:05:36 +01:00
Sébastien Deleuze 38724a1205 Fix RestClient generic type handling
For client side use case, the context class should be null,
consistently with what is done in HttpMessageConverterExtractor.

Closes gh-31574
2023-11-09 08:50:31 +01:00
rstoyanchev ba4d459f81 Merge branch '6.0.x' 2023-11-08 11:47:18 +00:00
rstoyanchev 5c012bbb0c Set maxAge correctly when expiring WebSession
Closes gh-31214
2023-11-08 11:44:36 +00:00
Stéphane Nicoll d34b3c1a71 Merge branch '6.0.x' 2023-11-08 08:04:27 +01:00
Johnny Lim cafb38ad1d Add Javadoc since to ProblemDetail.setProperties()
See gh-31571
2023-11-08 08:02:57 +01:00
Arjen Poutsma 5afb00d270 Merge branch '6.0.x' 2023-11-07 15:10:59 +01:00
Arjen Poutsma dc26d3b0ec Defer cleanup in DefaultServerWebExchange
This commit ensures that the multipartRead flag is read in a deferred
block, and is not evaluated too early.

Closes gh-31567
2023-11-07 15:00:20 +01:00
Arjen Poutsma 486503bd31 Buffer writes in JettyClientHttpRequest
This commit ensures that not every OutputStream.write gets written as a
separate chunk, by buffering the written data in a BufferedOutputStream.
In some cases, a large quantity of small writes would result in many
sent chunks.

Closes gh-31361
2023-11-07 14:02:01 +01:00
Arjen Poutsma 0839f5b749 Test form submissions
See gh-31361
2023-11-07 12:27:31 +01:00
rstoyanchev 5df6e8825d Polishing in CookieWebSessionIdResolver
See gh-31214
2023-11-06 11:31:39 +00:00
Arjen Poutsma efb93ca109 Fix bug in calculation of maximum form part size
See gh-31343
2023-11-06 11:20:18 +01:00
rstoyanchev 654e822676 Fix Javadoc link 2023-11-03 14:38:53 +00:00
Arjen Poutsma 6dd93d4d85 Allow repeatable writes in HttpMessageConverter
This commit ensures that the StreamingHttpOutputMessage.Body.repeatable
flag is set in message converters for bodies that can be written
repeatedly.

Closes gh-31516
See gh-31449
2023-11-02 15:51:36 +01:00
rstoyanchev f16122d533 Polishing and minor refactoring
Closes gh-31202
2023-11-02 11:32:03 +00:00
Carl-Eric Menzel d54a694f5a Add handler for unknown status codes
See gh-31202
2023-11-02 11:32:03 +00:00
Johnny Lim 2b750926c3 Polishing
Closes gh-31522
2023-10-30 15:05:20 +01:00
Arjen Poutsma 66aac7e359 Add maxParts and maxPartSize to PartEventHttpMessageReader
This commit introduces the maxParts and maxPartSize properties to
PartEventHttpMessageReader, which can be used to limit the amount of
parts, and maximum part size respectively.

Closes gh-31343
2023-10-25 15:18:35 +02:00
Rob Winch 03d286c4a1 Document X-Forwarded-* Headers
Previously the documentation assumed that the readers knew how to use
the X-Forwarded-* headers. This commit documents details & examples
of how to use the X-Forwarded-* headers.

See gh-31491
2023-10-25 13:22:41 +01:00
Sébastien Deleuze 3b80f2c4cb Refine MaxUploadSizeExceededException handling
This commit refines MaxUploadSizeExceededException
handling in order to translate to a "413 Payload Too Large"
status code instead of "500 Internal Server Error", with
related ProblemDetail body.

Closes gh-27170
2023-10-25 12:11:53 +02:00
Sébastien Deleuze a71eb3fb08 Merge branch '6.0.x' 2023-10-24 17:56:06 +02:00
Arjen Poutsma b6e0b8c343 Use StreamingHttpOutputMessage.Body.repeatable in OkHttp3ClientHttpRequest
See gh-31449
2023-10-24 16:12:26 +02:00
rstoyanchev 3f8bbdb116 Merge branch '6.0.x' 2023-10-24 12:53:55 +01:00
rstoyanchev 5c6b9be3a1 Send 400 for PathVariable that is null after conversion
This implies a value was actually sent, but is not something
that can be converted to the expected type.

Closes gh-31382
2023-10-24 12:53:25 +01:00
rstoyanchev 796080abb8 Test for change to add conversion of defaultValue
This commit adds a test and polishing for a change in
AbstractNamedValueMethodArgumentResolver erroneously committed
with (unrelated) commit e57b942b.

If an argument becomes null after conversion and a default value is
applied, that default value should also pass through conversion.

Closes gh-31336
2023-10-24 12:24:03 +01:00
Arjen Poutsma e0ac000415 Allow repeatable writes in StreamingHttpOutputMessage
This commit adds a repeatable property to
StreamingHttpOutputMessage.Body, indicating that the body can be written
 multiple times. In HttpComponentsClientHttpRequest, this property is
 exposed via org.apache.hc.core5.http.HttpEntity.isRepeatable, to allow
 for redirects.

Closes gh-31449
2023-10-24 12:11:13 +02:00
rstoyanchev e57b942b4d MockMvcBuilder supports filter name in addition to initParams
Closes gh-31474
2023-10-24 10:33:58 +01:00
Arjen Poutsma cb4d44b83e JdkClientHttpRequest does not support Content-Length 0
This commit ensures the correct HttpRequest.BodyPublisher is used with
Content-Length 0.

Closes gh-31451
2023-10-23 12:25:10 +02:00
Sam Brannen 2d792f000a Polish "Apply SingleSpaceSeparator Checkstyle module"
See gh-31469
2023-10-22 14:18:18 +02:00
Johnny Lim 64e9fcad53 Apply SingleSpaceSeparator Checkstyle module
This commit also fixes its violations.

Closes gh-31469
2023-10-22 14:09:57 +02:00
Sam Brannen 37e6fe5b64 Update copyright headers 2023-10-22 11:28:40 +02:00
Brian Clozel 31a62ff8ba Add JMH benchmarks for Protobuf message converter
This commit re-generates the protobuf Java classes with a recent version
of the protoc binary and adds JMH benchmarks that exercise the message
converter for both the reading and writing cases.

See gh-29496
2023-10-20 16:35:21 +02:00
Brian Clozel 631a5d1dc1 Remove support for Protobuf 2.x and protobuf-java-format
Closes gh-31465
2023-10-20 15:05:02 +02:00
rstoyanchev 7271dfed68 Use CopyOnWriteArrayList for beforeCommit actions
Closes gh-27587
2023-10-20 13:21:09 +01:00
rstoyanchev a8019f2d0b Create reusable DisconnectedClientHelper
See gh-26181
2023-10-17 15:52:24 +01:00
Stéphane Nicoll 5c6232e681 Polish "Order modifiers to align with JLS"
See gh-31368
2023-10-17 16:16:58 +02:00
Johnny Lim 919faa2ce2 Order modifiers to align with JLS
This commit also applies Checkstyle ModifierOrder to enforce it.

See gh-31368
2023-10-17 16:13:56 +02:00
Sébastien Deleuze 669c723ae0 Merge branch '6.0.x' 2023-10-17 14:25:33 +02:00
Sébastien Deleuze 875eeabb6f Add a properties setter to ProblemDetail
Mainly to allow Kotlin idiomatic properties assignment.

Closes gh-31430
2023-10-17 14:11:24 +02:00
Stéphane Nicoll 6efc99fdd8 Harmonize BeanRegistrationAotContribution class names 2023-10-17 12:37:52 +02:00
Sam Brannen 32b4f55d92 Update copyright headers 2023-10-16 16:19:55 +02:00
Sam Brannen d43cf2c5cd Polishing 2023-10-13 18:12:49 +02:00
Brian Clozel ca4d0d784b Apply instrumentation fixes to HttpWebHandlerAdapter
Since the Spring WebFlux HTTP server instrumentation has been moved from
the `WebFilter` to the `HttpWebHandlerAdapter`, we need to apply similar
changes there.

See gh-31417
2023-10-13 15:04:03 +02:00
Brian Clozel 579f29857f Merge branch '6.0.x' 2023-10-13 15:03:56 +02:00
Brian Clozel da95542d8f Prevent duplicate HTTP server observations
Prior to this commit, HTTP server observations for Spring WebFlux could
be recorded twice for a single request in some cases. The "COMPLETE" and
"CANCEL" signals would race in the reactive pipeline and would trigger
both the `doOnComplete()` and ` `doOnCancel()` operators, each calling
`observation.stop()` on the current observation.
This would in fact publish two different observations for the same
request.

This commit ensures that the instrumentation uses the `Mono#tap`
operator to guard against this case and only call `Observation#stop`
once for each request.

Fixes gh-31417
2023-10-13 14:56:40 +02:00
rstoyanchev b5b9386be6 Polishing
Closes gh-31413
2023-10-13 11:47:47 +01:00
Olga MaciaszekSharma 0cd196e3dd Add UriBuilderFactoryArgumentResolver
See gh-31413
2023-10-13 11:47:47 +01:00
rstoyanchev 0542fe5232 Update ClientHttpRequestInterceptor javadoc
Clarify the interceptor is responsible for closing the response
if it throws an exception after receiving it.

Closes gh-29751
2023-10-11 17:09:18 +01:00
Brian Clozel d1cf71cc70 Merge branch '6.0.x' 2023-10-11 11:24:00 +02:00
Brian Clozel e9fcb21d55 Refine status KeyValue for HTTP server observations
Prior to this commit, a cancelled exchange would always result in an
`"status":"UNKNOWN"` KeyValue. This only applied to reactive variants,
as cancelled exchanges are not currently detected for Servlet
implementations.

In some cases, exchanges can be cancelled by clients before they are
completed, but the response was actually received by the client. The
response status information has been set by the application and the
response has been committed. For those cases, we shouldn't assume an
"UNKNOWN" value.

This commit assumes that committed responses have a response status set
by the application and that the observations should reflect that. From
now on, we only assume an "UNKNOWN" status if the response has not been
commited.

Fixes gh-31388
2023-10-11 11:17:38 +02:00
Sébastien Deleuze 2158410853 Revert "Support Jackson's DatatypeFeature in Jackson2ObjectMapperBuilder"
This reverts commit 5f053401e2.
2023-10-11 10:10:36 +02:00
Sébastien Deleuze ae88bbaac3 Reintroduce org.springframework.http.client.reactive.ReactorResourceFactory
This commit reintroduces a deprecated ReactorResourceFactory in
org.springframework.http.client.reactive package that extends
the one in org.springframework.http.client package to avoid an
API breaking change and to provide a smoother upgrade experience.

Closes gh-31399
2023-10-11 08:38:17 +02:00
Sébastien Deleuze 299a10ce2a Update `@Since` Java doc tags in ReactorResourceFactory
See gh-31399
2023-10-10 16:51:21 +02:00
Sébastien Deleuze e0ba42a80c Move ReactorResourceFactory to org.springframework.http.client package
Closes gh-31399
2023-10-10 15:58:20 +02:00
Arjen Poutsma faaf3a61f2 Add FormEvent stream event test
Add sample that shows how FormEvents can be used to create a form
submit from a stream of key/value pairs.

See gh-30131
2023-10-10 14:08:06 +02:00
Sébastien Deleuze 298d6e4db0 Fix unused import error in ReactorClientHttpConnector 2023-10-10 13:04:32 +02:00
Sébastien Deleuze 955112be0e Polish ReactorClientHttpConnector Javadoc 2023-10-10 12:50:26 +02:00
Sébastien Deleuze 363d5a6413 Add CRaC support to ReactorNettyClientRequestFactory
This commit adds a constructor with externally managed
Reactor Netty resources to ReactorNettyClientRequestFactory
and makes it lifecycle-aware in order to support Project CRaC.

Closes gh-31280
Closes gh-31281
2023-10-10 12:42:56 +02:00
Sébastien Deleuze cd3daa873f Merge branch '6.0.x' 2023-10-10 10:17:02 +02:00
Bram Hagens 5f053401e2 Support Jackson's DatatypeFeature in Jackson2ObjectMapperBuilder
Closes gh-31380
2023-10-10 10:13:52 +02:00
Arjen Poutsma 59d123a18e Introduce OutputStream BodyInserter
This commit introduces a BodyInserter that inssert any bytes written to
an output stream to the body of an output message.

Closes gh-31184
2023-10-05 15:31:08 +02:00
rstoyanchev ef8d1db403 Improve exception handling in startCallableProcessing
Absorb any exception from the submission to the executor. It will be
handled in the resulting ASYNC dispatch.

Closes gh-30232
2023-10-04 13:05:09 +01:00
Kai Zander e8b42c5439 Optimize uses of onErrorResume()
This commit replaces uses of onErrorResume() with
- onErrorMap() in places where onErrorResume() is just used to map to a
  different exception.
- onErrorComplete() where onErrorResume() just maps to Mono.empty().
- onErrorReturn() where onErrorResum() just maps to Mono.just().

Closes gh-31352
2023-10-03 14:42:24 +02:00
Henning Poettker 9cab6c90a9 Allow custom observation convention for RestClient
This commit allows to use a custom `ObservationConvention`
in the `DefaultRestClient`, and to set it through the
`RestClient.Builder`.

Closes gh-31325
2023-10-02 14:55:01 +02:00
rstoyanchev 8fa428f825 Skip reconstructing body from request params if query present
This allows restoring optimization in StringHttpMessageConverter
that was undone in 23162b for 6.0.x.

Closes gh-31327
2023-09-29 18:01:18 +01:00
rstoyanchev a6ab636614 Merge branch '6.0.x' 2023-09-29 18:00:52 +01:00
Sam Brannen 95838e18cc Clean up (boolean) (Boolean) casts in tests 2023-09-29 18:16:04 +02:00
rstoyanchev 23162bb306 Undo optimization from 12fe2c that can cause regression
Closes gh-31327
2023-09-29 17:15:23 +01:00
rstoyanchev a2c5fed494 Make targetType in UknownContentTypeException transient
Closes gh-31283
2023-09-28 16:52:03 +01:00
rstoyanchev 957b6b2caf Use URI String as fallback in ReactorClientHttpConnector
Closes gh-31033
2023-09-27 14:01:35 +01:00
Sam Brannen bc3d98565c Update copyright headers 2023-09-23 13:36:41 +02:00
Brian Clozel d926769a5e Fix copyright headers
See gh-30137
2023-09-22 09:36:38 +02:00
rstoyanchev cc296c5033 Polishing contribution
Closes gh-30137
2023-09-20 18:44:33 +01:00
Joakim Mohn a1c4fb3840 Lenient URI encoding handling in ForwardedHeaderTransformer
See gh-30137
2023-09-20 18:44:33 +01:00
Markus Heiden 59771318ce Introduce CharBufferDecoder
This commit introduces the CharBufferDecoder.

Closes gh-29741
2023-09-19 16:24:07 +02:00
Sam Brannen b05e46d502 Update copyright headers 2023-09-16 15:23:10 +02:00
Sébastien Deleuze 20df52e543 Merge branch '6.0.x' 2023-09-15 18:16:26 +02:00
Sébastien Deleuze ce0923b946 Remove Reactor Netty 2 from integration tests
Closes gh-31243
2023-09-15 18:15:26 +02:00
Arjen Poutsma 81ebc3a6f3 MultipartParser should respect read position
This commit ensures that the MultipartParser takes a buffer's read
position into account.

Closes gh-31110
2023-09-15 14:20:12 +02:00
Arjen Poutsma 8f130316d2 MultipartParser should respect read position
This commit ensures that the MultipartParser takes a buffer's read
position into account.

Closes gh-31110
2023-09-15 13:46:04 +02:00
Stephane Nicoll 01f717375b Introduce ObjectUtils#nullSafeHash(Object... element)
This commit deprecates the various nullSafeHashCode methods taking array
types as they are superseded by Arrays.hashCode now. This means that
the now only remaining nullSafeHashCode method does not trigger a
warning only if the target type is not an array. At the same time, there
are multiple use of this method on several elements, handling the
accumulation of hash codes.

For that reason, this commit also introduces a nullSafeHash that takes
an array of elements. The only difference between Objects.hash is that
this method handles arrays.

The codebase has been reviewed to use any of those two methods when it
is possible.

Closes gh-29051
2023-09-13 15:14:34 +02:00
Sébastien Deleuze 6548cee20a Document CoWebFilter.COROUTINE_CONTEXT_ATTRIBUTE
See gh-27522
2023-09-12 19:27:49 +02:00
Brian Clozel 19588d413d Auto-detect observability beans in WebHttpHandlerBuilder
This commit ensures that both `ObservationRegsitry` and
`ServerRequestObservationConvention` beans are automatically detected in
the application context if they are unique. This aligns with the
existing behavior for all other builder methods.

Closes gh-31205
2023-09-11 21:17:14 +02:00
Sébastien Deleuze dfd631e662 Merge branch '6.0.x' 2023-09-11 18:10:13 +02:00
Sébastien Deleuze 76b8bb2c75 Refine CORS documentation for wildcard processing
This commit refines CORS wildcard processing Javadoc to
provides more details on how wildcards are handled for
Access-Control-Allow-Methods, Access-Control-Allow-Headers
and Access-Control-Expose-Headers CORS headers.

For Access-Control-Expose-Headers, it is not possible to copy
the response headers which are not available at the point
when the CorsProcessor is invoked. Since all the major browsers
seem to support wildcard including on requests with credentials,
and since this is ultimately the user-agent responsibility to
check on client-side what is authorized or not, Spring Framework
continues to support this use case.

See gh-31143
2023-09-11 18:07:31 +02:00
rstoyanchev 38a9c2ceeb Polishing contribution
See gh-31164
2023-09-11 11:27:25 +01:00
Dmitrii Bocharov fe8e6d3d5a Merge MultipartFileArgumentResolver into RequestPartArgumentResolver
Also add test with Optional parameter for a RequestPart argument.

See gh-31164

Signed-off-by: Dmitrii Bocharov <bdshadow@gmail.com>
2023-09-11 11:27:25 +01:00
Brian Clozel f83c609436 Polish
This commit replaces the initial allocation size for the content caching
buffer by a `FastByteArrayOutputStream`. With this variant, allocations
are cheap and we don't need to apply heuristics anymore to guess the
best initial buffer size.

See gh-29775
2023-09-11 10:58:01 +02:00
Ryan Rupp 6de0be16c2 Optimize initial buffer size in ContentCachingRequestWrapper
Prior to this commit, the initial buffer size for content caching
allocated in `ContentCachingRequestWrapper` would be:

* the request content length, if available in request headers
* the cache limit size as configured on the wrapper

The latter is really an upper bound and should not be considered as a
good default in most cases. This commit ensures that the request content
length is still used if available, but uses a default 1024 size if it's
not.

While this change will probably cause more reallocations as the buffer
grows, this will avoid large allocations in many cases and should
overall help with GC.

Closes gh-29775
2023-09-11 10:36:40 +02:00
Sébastien Deleuze da7ad71b7f Refine ReactorResourceFactory Javadoc
Provides more details about stop/restart
scenario.

See gh-31178
2023-09-08 09:12:35 +02:00
Yanming Zhou 94a49c4ed3 Log warning if ResponseStatus 'reason' is set and handler returns value
When a handler method is annotated with `@ResponseStatus(reason="...")`,
Spring MVC will use `HttpServletResponse#sendError` to complete the
response. As a result, the Servlet container will send an HTML error
page and any existing data in the response buffer will be cleared.

This commit clarifies the `@ResponseStatus` Javadoc and ensures that a
message is logged at the WARN level if a handler method is annotated
like this and still returns a non-Void value. In this case, the return
value will be ignored and developers should be aware of this fact.

See gh-31113
Closes gh-31121
2023-09-07 19:00:26 +02:00
Sébastien Deleuze b0aa004d9d Propagate CoroutineContext in CoWebFilter
This provides an elegant and dynamic way to customize the
CoroutineContext in WebFlux with the annotation programming
model.

Closes gh-27522
2023-09-07 12:08:12 +02:00
Sébastien Deleuze 9d768a89d2 Make ReactorClientHttpConnector lifecycle-aware
With this commit, ReactorClientHttpConnector now implements
SmartLifecycle which optionally allows recreating the HttpClient
after ReactorResourceFactory has been updated.

Closes gh-31180
2023-09-06 17:48:22 +02:00
Sébastien Deleuze ab2ad746b5 Polish ReactorResourceFactoryTests
See gh-31178
2023-09-06 16:01:06 +02:00
Sébastien Deleuze 125b8e7418 Make ReactorResourceFactory lifecycle-aware
With this commit, ReactorResourceFactory now implements
Lifecycle which allows supporting JVM Checkpoint Restore
in Spring Boot with Reactor Netty server, and helps
to support Reactor Netty client as well.

Closes gh-31178
2023-09-06 14:14:07 +02:00
Sébastien Deleuze 2a916a3869 Polish ReactorResourceFactoryTests 2023-09-06 14:14:07 +02:00
Sam Brannen fad70aa252 Update copyright headers 2023-09-04 14:30:44 +02:00
rstoyanchev b068742ec8 Support method validation for Lists in WebMvc and WebFlux
Closes gh-31120
2023-09-04 13:22:09 +01:00
Arjen Poutsma 6597727c86 Upgrade to Jetty 12
This commit upgrades Spring Framework to Jetty 12.0.1, and Reactive HTTP
 Client 4.0.0.

Closes gh-30698
2023-09-04 14:03:29 +02:00
Brian Clozel 5fb567a37e Fix missing URI template from client observations in ResTemplateAdapter
Prior to this commit, the `RestTemplateAdapter` would manually expand
templated URIs. This means that the `RestTemplate` instance itself would
never see the templated URIs and could not record it in the client
observations at runtime.

This commit ensures that when URI templates are available, the adapter
uses the correct `exchange` method variant.

Fixes gh-31144
2023-09-04 11:45:35 +02:00
Anton-Vasilev 1ee18e74fc Fix typo in RestClient Javadoc
Closes gh-31145
2023-08-31 09:43:06 +02:00
Anna Buyevich 376a8989f5 Add more tests to DefaultClientRequestObservationConvention
Closes gh-31125
2023-08-29 14:09:46 +02:00
Sébastien Deleuze bcf11e8919 Replace Reactive awaitSingle() usages by the Mono variant
Closes gh-31127
2023-08-29 09:49:44 +02:00
Arjen Poutsma 76c032cc11 Schedule blocking ResourceHttpMessageWriter operations on bounded elastic
This commit schedules blocking I/O operations on the bounded elastic
scheduler, which includes retrieving the content length and writing
the resource (region).

Closes gh-30928
2023-08-28 12:54:52 +02:00
Sébastien Deleuze 499f57ebc5 Fix formatting errors 2023-08-28 10:12:45 +02:00
Sébastien Deleuze 349674ef5e Adapt tests for Jackson ParameterNamesModule
Closes gh-27511
2023-08-28 09:39:53 +02:00
Sam Kruglov 2f43f77dd1 Add ParameterNamesModule to "well known" jackson modules
See gh-27511
2023-08-28 09:36:36 +02:00
Sam Brannen 4e2d9252e5 Allow component name to be specified in @[Rest]ControllerAdvice
This commit builds on the recently added support for using @AliasFor to
override the `value` attribute in `@Component, and allows a custom
component name to be specified in both @ControllerAdvice and
@RestControllerAdvice via new `name` attributes.

See gh-31089
Closes gh-21108
2023-08-27 18:06:08 +02:00