Commit Graph

5521 Commits

Author SHA1 Message Date
Sam Brannen 8553f97df1 Merge HtmlCharacterEntityDecoderTests into HtmlUtilsTests
See gh-35711

(cherry picked from commit 0342cd0904)
2025-11-17 15:29:52 +01:00
Brian Clozel 030dace2be Polishing contribution
Closes gh-35477
2025-11-17 15:15:39 +01:00
potato 5af1c9b487 Fix HtmlUtils unescape for supplementary chars
See gh-35477

Signed-off-by: potato <65760583+juntae6942@users.noreply.github.com>
2025-11-17 15:15:39 +01:00
Dmitry Sulman d0ff8f9243 Fix HttpServiceMethod for suspending functions returning Flow
Closes gh-35718
Signed-off-by: Dmitry Sulman <dmitry.sulman@gmail.com>
2025-11-11 12:58:42 +01:00
Brian Clozel ba39385cce Use executor for blocking I/O in Reactor request factory
Prior to this commit, the `ReactorClientHttpRequestFactory` and the
`ReactorClientHttpRequest` would use the `Executor` from the current
event loop for performing write operations.
Depending on I/O demand, this work could be blocked and would result in
blocked Netty event loop executors and the HTTP client hanging.

This commit ensures that the client uses a separate Executor for such
operations. If the application does not provide one on the request
factory, a `Schedulers#boundedElastic` instance will be used.

Fixes gh-34707
2025-11-10 16:12:14 +01:00
rstoyanchev 3cb498fa98 Improve docs on streaming via StreamingHttpOutputMessage
Closes gh-35700
2025-11-10 14:43:34 +00:00
Sam Brannen 1714a00492 Suppress warnings in Gradle build 2025-11-10 14:13:34 +01:00
Brian Clozel 285182be27 Relax multiple segment matching constraints in PathPattern
Prior to this commit, gh-35213 allowed wildcard path elments at the
start of path patterns. This came with an additional constraint that
rejected such patterns if the pattern segment following the wildcard one
was not a literal:

* `/**/{name}` was rejected
* `/**/something/{name}` was accepted

The motivation here was to make the performance impact of wildard
patterns as small as possible at runtime.

This commit relaxes this constraint because `/**/*.js` patterns are very
popular in the security space for request matchers.

Closes gh-35686
2025-11-05 18:32:44 +01:00
Brian Clozel 8bb63081a8 Document PathPattern matching for single/multiple segments
This commit improves the reference document to better reflect the
different between `*` or `{name}` on one side, and `**` or `{*path}` on
the other.

The former patterns only consider a single path segment and its content,
while the latter variants consider zero or more path segments. This
explains why `/test/{*path}` can match `/test`.

Closes gh-35727
2025-11-05 14:58:58 +01:00
Brian Clozel c0429dbb09 Fix file extension resolution for media types with q parameter
Prior to this commit, the `MappingMediaTypeFileExtensionResolver` would
resolve file extensions for a given media type by using a direct lookup
using the given media type provided by the request.
If the request contains a quality parameter like
"application/json;q=0.9", this would not resolve configured file
extensions for this media type.
While other media type parameters can be meaningful, the quality
parameter should not be used for lookups. This commit ensures that the
quality parameter is dropped before performing lookups.

Fixes gh-35754
2025-11-05 10:48:24 +01:00
Brian Clozel d65de19e7d Deprecate setConnectTimeout on HttpComponents client factory
Prior to this commit, the `HttpComponentsClientHttpRequestFactory` would
set the connection timeout on the request configuration. This has been
deprecated by the client itself and this value should be set while
creating the client on the connection manager itself.

This commit deprecates this method, as there is no way for the factory
to set this value anymore.

Closes gh-35748
2025-11-03 16:53:54 +01:00
Juergen Hoeller 4b7cf85d71 Retrieve cached response body in a thread-safe manner
Closes gh-35745
2025-11-02 20:40:02 +01:00
Anton Xu 01a58a253b Fix minor typo in RestClient
Closes gh-35723
Signed-off-by: Anton Xu <anton-xu@hotmail.com>
2025-10-30 19:41:56 +01:00
rstoyanchev b19059f6cb Handle null from JDK HttpResponse#body
Closes gh-35692
2025-10-28 11:44:16 +00:00
Brian Clozel a5141b187a Fix '**' parsing within a PathPattern segment
Prior to this commit, a regexp path segment ending with a double wilcard
(like "/path**") would be incorrectly parsed as a double wildcard
segment ("/**").

This commit fixes the incorrect parsing.

See gh-35679
2025-10-22 12:21:57 +02:00
Brian Clozel d3c1e678c2 Support wildcard path elements at the start of path patterns
Prior to this commit, the `PathPattern` and `PathPatternParser` would
allow multiple-segments matching and capturing with the following:

* "/files/**" (matching 0-N segments until the end)
* "/files/{*path}" (matching 0-N segments until the end and capturing
  the value as the "path" variable)

This would be only allowed as the last path element in the pattern and
the parser would reject other combinations.

This commit expands the support and allows multiple segments matching at
the beginning of the path:

* "/**/index.html" (matching 0-N segments from the start)
* "/{*path}/index.html" (matching 0-N segments until the end and capturing
  the value as the "path" variable)

This does come with additional restrictions:

1. "/files/**/file.txt" and "/files/{*path}/file.txt" are invalid,
   as multiple segment matching is not allowed in the middle of the
   pattern.
2. "/{*path}/files/**" is not allowed, as a single "{*path}" or "/**"
   element is allowed in a pattern
3. "/{*path}/{folder}/file.txt"  "/**/{folder:[a-z]+}/file.txt" are
   invalid because only a literal pattern is allowed right after
   multiple segments path elements.

Closes gh-35679
2025-10-22 12:21:57 +02:00
Juergen Hoeller 7adcd99ea2 Polishing 2025-10-21 00:59:56 +02:00
Juergen Hoeller c53132ecdf Polishing 2025-10-15 19:40:09 +02:00
rstoyanchev 03c3ec1577 Fall back on remoteHost if remoteAddress is null
See gh-35589
2025-10-15 16:42:40 +01:00
Sam Brannen 2591cab561 Polishing 2025-10-13 15:12:21 +02:00
Sam Brannen 8456cd1e74 Polish contribution
See gh-35587
2025-10-13 15:12:21 +02:00
Igor Murzich 7699b4af9c Retain order of produces media types in @⁠ExceptionHandler
Closes gh-35587

Signed-off-by: Igor Murzich <imurzich@gmail.com>
2025-10-13 15:12:21 +02:00
rstoyanchev 2c83144946 Use getRemoteAddr in ServletServerHttpRequest
Closes gh-35589
2025-10-10 17:24:48 +01:00
rstoyanchev b3264ec2a8 Fix typo 2025-10-01 16:13:40 +01:00
rstoyanchev a19b51b7e0 Handle invalid position in ResourceHttpMessageWriter
Closes gh-35536
2025-10-01 14:44:05 +01:00
rstoyanchev fbdece6759 Polishing in ResourceHttpMessageWriter
See gh-35536
2025-10-01 14:42:01 +01:00
rstoyanchev e9fb5eb38a Respect forwarded path in UrlHandlerFilter
Closes gh-35509
2025-09-25 12:19:56 +01:00
rstoyanchev 5a858915ea Revise parsed path handling in UrlHandlerFilter
Closes gh-35538
2025-09-24 19:08:55 +01:00
Brian Clozel 0cc79ba366 Catch EOFException in IntrospectingClientHttpResponse
Prior to this commit, the `IntrospectingClientHttpResponse` would try
and read the HTTP response stream in order to check for the presence of
a non-empty message body.

Developers reported that in some cases, an `EOFException` is thrown
instead of returning -1 from the `read()` method. This commit ensures
that this case is taken into account and that we report the response as
an empty body in these cases.

Closes gh-35361
2025-09-19 17:49:12 +02:00
Juergen Hoeller ba52164373 Provide graceful fallback for non-default NIO file systems
Closes gh-35443
2025-09-08 17:28:45 +02:00
Brian Clozel 764336f0f2 Fix Jetty DataBufferFactory memory leak
Prior to this commit, gh-32097 added native support for Jetty for both
client and server integrations. The `JettyDataBufferFactory` was
promoted as a first class citizen, extracted from a private class in the
client support. To accomodate with server-side requirements, an extra
`buffer.retain()` call was performed.
While this is useful for server-side support, this introduced a bug in
the data buffer factory, as wrapping an existing chunk means that this
chunk is already retained.

This commit fixes the buffer factory implementation and moved existing
tests from mocks to actual pooled buffer implementations from Jetty.
The extra `buffer.retain()` is now done from the server support, right
before wrapping the buffer.

Fixes gh-35319
2025-08-27 13:36:34 +02:00
Sam Brannen 4903fee939 Permit @⁠Nullable value in ResponseCookie from*() factory methods
Closes gh-35377
2025-08-26 11:01:29 +02:00
Sam Brannen 6d710d482a Find annotation on overridden method in type hierarchy with unresolved generics
Prior to this commit, the MergedAnnotations support (specifically
AnnotationsScanner) and AnnotatedMethod did not find annotations on
overridden methods in type hierarchies with unresolved generics.

The reason for this is that ResolvableType.resolve() returns null for
such an unresolved type, which prevents the search algorithms from
considering such methods as override candidates.

For example, given the following type hierarchy, the compiler does not
generate a method corresponding to processOneAndTwo(Long, String) for
GenericInterfaceImpl. Nonetheless, one would expect an invocation of
processOneAndTwo(Long, String) to be @⁠Transactional since it is
effectively an invocation of processOneAndTwo(Long, C) in
GenericAbstractSuperclass, which overrides/implements
processOneAndTwo(A, B) in GenericInterface, which is annotated with
@⁠Transactional.

However, the MergedAnnotations infrastructure currently does not
determine that processOneAndTwo(Long, C) is @⁠Transactional since it is
not able to determine that processOneAndTwo(Long, C) overrides
processOneAndTwo(A, B) because of the unresolved generic C.

interface GenericInterface<A, B> {

    @⁠Transactional
    void processOneAndTwo(A value1, B value2);
}

abstract class GenericAbstractSuperclass<C> implements GenericInterface<Long, C> {

    @⁠Override
    public void processOneAndTwo(Long value1, C value2) {
    }
}

static GenericInterfaceImpl extends GenericAbstractSuperclass<String> {
}

To address such issues, this commit changes the logic in
AnnotationsScanner.hasSameGenericTypeParameters() and
AnnotatedMethod.isOverrideFor() so that they use
ResolvableType.toClass() instead of ResolvableType.resolve(). The
former returns Object.class for an unresolved generic which in turn
allows the search algorithms to properly detect method overrides in
such type hierarchies.

Closes gh-35342
2025-08-19 12:28:12 +02:00
Sam Brannen f11a1e6f82 Polish tests 2025-08-11 11:27:10 +03:00
rstoyanchev ffc785471b Fix checkstyle error 2025-08-08 12:31:13 +01:00
rstoyanchev 6e2fbfe108 Polishing contribution
Closes gh-35232
2025-08-08 11:50:07 +01:00
秦利斌 968e037503 Add documentation of RequestMapping about SpEL
Signed-off-by: 秦利斌 <68638598+Allan-QLB@users.noreply.github.com>
2025-08-08 11:37:25 +01:00
rstoyanchev f0a9f649c1 Allow null in ProblemDetail#type
See gh-35294
2025-08-08 11:36:53 +01:00
rstoyanchev 600d6c6fc0 Update contribution
Closes gh-34721
2025-08-08 11:31:21 +01:00
giampaolo 7a55ce48a9 Handle CancellationException in JdkClientHttpRequest
Handle CancellationException in order to throw an HttpTimeoutException
when the timeout handler caused the cancellation.

See gh-34721

Signed-off-by: giampaolo <giampaorr@gmail.com>

fix: use timeoutHandler with a flag isTimeout

    Closes gh-33973

    Signed-off-by: giampaolo <giampaorr@gmail.com>
2025-08-08 11:31:21 +01:00
Juergen Hoeller 5df9fd4eff Polishing (aligned with main) 2025-08-06 19:01:18 +02:00
Patrick Strawderman 24e66b63d1 Refine StringUtils#uriDecode and update documentation
Refine the StringUtils#uriDecode method in the following ways:
- Use a StringBuilder instead of ByteArrayOutputStream, and only decode
  %-encoded sequences.
- Use HexFormat.fromHexDigits to decode hex sequences.
- Decode to a byte array that is only allocated if encoded sequences are
  encountered.

This commit adds another optimization mainly for the use case where
there is no encoded sequence, and updates the Javadoc of both
StringUtils#uriDecode and UriUtils#decode to match the implementation.

Signed-off-by: Patrick Strawderman <pstrawderman@netflix.com>
Co-Authored-by: Sebastien Deleuze <sebastien.deleuze@broadcom.com>

Closes gh-35253
2025-07-29 21:44:26 +02:00
Sébastien Deleuze 5e338ef1b8 Make MessageSource locale parameter nullable
Closes gh-35230
2025-07-23 16:02:38 +02:00
Juergen Hoeller 54732605a5 Backport nullability refinements for Micrometer
See gh-35170
2025-07-15 20:56:36 +02:00
Juergen Hoeller f86034b528 Drop final declaration from doFilter entry point (for CGLIB proxying)
Closes gh-35198
2025-07-15 15:59:23 +02:00
Sam Brannen 1ad05db877 Simplify dependency management for JUnit artifacts
This commit simplifies our dependency management for JUnit artifacts by
making use of the junit-jupiter and junit-platform-suite aggregator
artifacts.

Closes gh-35127
2025-06-29 17:42:22 +02:00
rstoyanchev f84552a97e Polishing contribution
Closes gh-35102
2025-06-25 12:37:42 +01:00
Daniil Razorenov 8d6117e419 Support StreamingHttpOutputMessage in RestClient
This commit allows RestClient to handle StreamingHttpOutputMessage
properly by checking the type of the request and invoking setBody()
when appropriate. This improves interoperability with components that
expect streamed output.

A new integration test has been added to verify the functionality.

See gh-35102

Signed-off-by: Daniil Razorenov <daniltmb@gmail.com>
2025-06-25 12:36:32 +01:00
Brian Clozel 45d887f973 Fix missing request body for GET and DELETE JdkClientHttpRequest
This commit fixes a regression introduced in gh-34971 where GET and
DELETE requests would not allow request bodies anymore for
`JdkClientHttpRequest`.
We are now using `builder.GET()` and `builder.DELETE()` methods only if
the provided body is null.

Fixes gh-35068
2025-06-17 17:19:21 +02:00
Spring Builds aee29b7f30 Update copyright headers in source files
This commit updates Java, Kotlin, and Groovy source files to use the
"<year>-present" pattern in copyright headers.

Closes gh-35070
2025-06-17 15:54:58 +02:00