Commit Graph

1577 Commits

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

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

Closes gh-28433
2022-05-10 11:32:37 +02:00
rstoyanchev 8378af9e39 Polishing
See gh-28189
2022-05-09 19:01:10 +01:00
rstoyanchev 78ab4d7118 Support content negotiation for RFC 7807
Closes gh-28189
2022-05-09 18:32:21 +01:00
Sam Brannen 6c131ef9dc Merge branch '5.3.x' 2022-05-09 15:23:15 +02:00
Sam Brannen a1c7380398 Add test for `value` attribute in @ModelAttribute in WebFlux
This complements the previous commit which tested only the `name`
attribute.

See gh-28423
2022-05-09 15:22:22 +02:00
rstoyanchev 5d0f49c2c8 Add WebInputException subclasses
Closes gh-28142
2022-05-09 09:52:15 +01:00
Sam Brannen 061d1263f8 Merge branch '5.3.x' 2022-05-07 17:24:50 +02:00
Sam Brannen 7dd622bdb2 Support name attribute in @ModelAttribute in WebFlux
Prior to this commit, the `name` attribute in @ModelAttribute was not
supported when using WebFlux. This is because MethodParameter was used
instead of SynthesizingMethodParameter when retrieving the
@ModelAttribute annotation. In other words, @AliasFor was not honored
because the annotation was not synthesized. Consequently, only the
`value` attribute was supported in WebFlux when specifying a custom name
via @ModelAttribute.

This commit fixes this by using SynthesizingMethodParameter to retrieve
the @ModelAttribute annotation.

Closes gh-28423
2022-05-07 17:16:26 +02:00
Sam Brannen 9b1c8a3a5c Fix broken ToStringVisitorTests
Tests were broken due to the switch to Set.of(...) in
2b65f274dc.
2022-05-07 16:45:46 +02:00
Sam Brannen a69d9716c9 Merge branch '5.3.x' 2022-05-07 16:28:01 +02:00
Sam Brannen 64c96c579d Polish contribution
See gh-28422
2022-05-07 16:18:47 +02:00
Carlos Bouzón García 39e3876301 Fix BindingResult error when ModelAttribute has custom name in WebFlux
Closes gh-28422
2022-05-07 16:18:04 +02:00
Juergen Hoeller 2b65f274dc Use Set.of instead of HashSet with Arrays.asList 2022-05-06 16:19:27 +02:00
rstoyanchev b4e6014a14 Merge branch '5.3.x' into main 2022-04-28 11:40:11 +01:00
rstoyanchev b30f4d7bb7 Exposes all root causes to ExceptionHandler methods
Closes gh-28155
2022-04-28 04:04:57 +01:00
rstoyanchev b1384ddafa Add HttpServiceProxyFactory builder
See gh-28386
2022-04-27 21:21:43 +01:00
rstoyanchev d7ab5b4132 Refactor HttpRequestSpec to HttpRequestValues
HttpRequestValues is immutable and exposes a builder.

See gh-28386
2022-04-27 21:21:43 +01:00
rstoyanchev 564f8ba7a0 Update after review
See gh-28386
2022-04-27 21:21:43 +01:00
rstoyanchev c418768f05 Add @HttpRequest and HttpServiceProxyFactory
See gh-28386
2022-04-27 21:21:43 +01:00
Arjen Poutsma be7fa3aaa8 Introduce PartEvent
This commit introduces the PartEvent API. PartEvents are either
- FormPartEvents, representing a form field, or
- FilePartEvents, representing a file upload.

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

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

Closes gh-28006
2022-04-20 11:00:07 +02:00
Sam Brannen 081c6463e9 Polish Javadoc for PathVariableMapMethodArgumentResolver 2022-04-16 17:57:44 +02:00
Sam Brannen 1574fed90b Merge branch '5.3.x' 2022-04-13 10:08:31 +02:00
Sam Brannen a7cf19cec5 Improve documentation and matching algorithm in data binders 2022-04-13 09:55:40 +02:00
Arjen Poutsma 9adfa5e8b0 Add HEAD support in MVC/WebFlux Resource handling
This commit introduces explicit HEAD support in Spring
MVC's ResourceHttpRequestHandler and WebFlux's ResourceWebHandler,
adding just headers but no body.

Closes gh-28291
2022-04-07 13:51:21 +02:00
Arjen Poutsma 192f2becf6 Automatically clean up multipart temp files
This commit ensures that any resources created for multipart handling,
obtained via ServerWebExchange.getMultipartData(), are automatically
deleted after handling the completing the response.

Resource for parts obtained via BodyExtractors::toMultipartData and
BodyExtractors::toParts are not cleaned automatically, and
should be cleaned via Part::delete.

Closes gh-27633
2022-04-06 17:02:31 +02:00
rstoyanchev aea39fdad3 Merge branch '5.3.x' into main 2022-04-01 17:57:48 +01:00
rstoyanchev 24cd3c1f4c Revert "Disable flaky integration tests for now"
This reverts commit 1627f57f1f in
preparation for fixing the root cause
2022-04-01 16:07:05 +01:00
Stephane Nicoll 9ea741364a Merge branch '5.3.x' 2022-03-31 09:47:29 +02:00
Stephane Nicoll 1627f57f1f Disable flaky integration tests for now 2022-03-31 09:46:36 +02:00
Sam Brannen 7a1421cb0f Suppress deprecation warnings in tests 2022-03-29 15:04:58 +02:00
Arjen Poutsma 28ac0d3883 Use HttpStatusCode interface
This commit contains changes made because of the introduction of
HttpStatusCode. In general, methods that used to return a HttpStatus
now return HttpStatusCode instead, and methods that returned raw status
codes are now deprecated.

See gh-28214
2022-03-23 12:49:38 +01:00
Sam Brannen 9764f0e59b Merge branch '5.3.x'
# Conflicts:
#	spring-test/src/test/java/org/springframework/mock/http/server/reactive/MockServerHttpRequestTests.java
#	spring-web/src/test/java/org/springframework/http/server/reactive/HeadersAdaptersTests.java
#	spring-web/src/test/java/org/springframework/web/client/RestTemplateIntegrationTests.java
#	spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientIntegrationTests.java
#	spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/SseIntegrationTests.java
#	spring-webmvc/src/test/java/org/springframework/web/servlet/handler/MappedInterceptorTests.java
#	spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/HandlerMethodAnnotationDetectionTests.java
#	spring-websocket/src/test/java/org/springframework/web/socket/AbstractWebSocketIntegrationTests.java
2022-03-16 15:07:53 +01:00
Sam Brannen c462fe30ed Use Named arguments in parameterized tests 2022-03-16 14:45:47 +01:00
Sam Brannen 8a0c4caff6 Polish Javadoc 2022-03-16 14:33:52 +01:00
Sam Brannen 4db2f8ea1b Remove obsolete Nashorn-based scripting tests
Since the Nashorn JavaScript engine was removed in Java 15, these tests
will never be run on a Java 17+ JDK which is required as of Spring
Framework 6.0.

See gh-27919
2022-03-15 16:33:52 +01:00
Arjen Poutsma 5abaf20a74 Merge branch '5.3.x' 2022-03-11 12:22:39 +01:00
Arjen Poutsma a3e23cd5fc Fix unwrapping logic for ResponseEntity<Flux>
This commit makes sure that the response returned by coroutine handler
methods that return ResponseEntity<Flux> is unwrapped correctly.

Closes gh-27809
2022-03-11 11:56:13 +01:00
rstoyanchev 76be6373a8 ErrorResponse support in Spring MVC exception hierarchy
All Spring MVC exceptions from spring-web, now implement ErrorResponse
and expose HTTP error response information, including an RFC 7807 body.

See gh-27052
2022-02-28 13:40:05 +00:00
rstoyanchev 3efedef161 Add ErrorResponse and ErrorResponseException
ErrorResponse represents a complete error response with status, headers,
and an  RFC 7807 ProblemDetail body.

ErrorResponseException implements ErrorResponse and is usable on its
own or as a base class. ResponseStatusException extends
ErrorResponseException and now also supports RFC 7807 and so does its
sub-hierarchy.

ErrorResponse can be returned from `@ExceptionHandler` methods and is
mapped to ResponseEntity.

See gh-27052
2022-02-28 13:40:05 +00:00
rstoyanchev 714d451260 Add ProblemDetail and `@ExceptionHandler` support
ProblemDetail is a representation of an RFC 7807 "problem", and this
commits adds support for it in Spring MVC and WebFlux as a return value
from `@ExceptionHandler` methods, optionally wrapped with
ResponseEntity for headers.

See gh-27052
2022-02-28 13:40:05 +00:00
Sam Brannen c42023f20e Stop using SocketUtils in WebClientIntegrationTests
See gh-28052
2022-02-15 14:59:26 +01:00
Sam Brannen 552e02cb44 Polishing 2022-02-15 14:44:46 +01:00
Sam Brannen 7412625929 Merge branch '5.3.x'
# Conflicts:
#	spring-web/src/test/java/org/springframework/remoting/caucho/CauchoRemotingTests.java
#	spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientIntegrationTests.java
2022-02-15 14:35:25 +01:00
Sam Brannen 685a195ba1 Deprecate SocketUtils
SocketUtils was introduced in Spring Framework 4.0, primarily to assist
in writing integration tests which start an external server on an
available random port. However, these utilities make no guarantee about
the subsequent availability of a given port and are therefore
unreliable. Instead of using SocketUtils to find an available local
port for a server, it is recommended that users rely on a server's
ability to start on a random port that it selects or is assigned by the
operating system. To interact with that server, the user should query
the server for the port it is currently using.

SocketUtils is now deprecated in 5.3.16 and will be removed in 6.0.

Closes gh-28052
2022-02-15 14:28:58 +01:00
Sébastien Deleuze 5e64081ed1 Merge branch '5.3.x' 2022-02-14 10:51:46 +01:00
Sébastien Deleuze 8eb618b480 Make Kotlin functions accessible in CoroutinesUtils
In order to allow using private classes like in Java
for example.

Closes gh-23840
2022-02-14 10:43:31 +01:00
Brian Clozel 6c42bcfaec Upgrade to Kotlin 1.6.20-M1
This commit upgrades the Kotlin dependencies to 1.6.20-M1 and configures
the build to generate Java 17 bytecode for Kotlin classes.

Closes gh-27814
2022-02-11 11:39:32 +01:00
Sam Brannen b3f786728e Use modern language features in tests 2022-02-03 15:35:32 +01:00
Sam Brannen 54565e95b5 Merge branch '5.3.x' 2022-02-03 14:58:36 +01:00
Sam Brannen f8a5a8d7be Use modern language features in tests 2022-02-03 14:50:10 +01:00
Arjen Poutsma a9a6b071d9 Merge branch '5.3.x' 2022-01-28 13:45:45 +01:00
Arjen Poutsma caa13690e8 Support multiple boundary buffers in MultipartParser
In a small minority of cases, the multipart boundary can spread across
three incoming buffers.

Prior to this commit, MultipartParser.BodyState only supported two
buffers. If the boundary is spread across three buffers, the first
buffer of the three is sent as a whole, even though it contains the
first bytes of the boundary.

This commit fixes this bug, by enqueuing all prior buffers in a queue,
and emitting the ones that cannot contain boundary bytes.

Closes gh-27939
2022-01-28 13:42:24 +01:00
Sam Brannen 316e84f04f Polish contribution
See gh-27908
2022-01-14 15:53:41 +01:00
Frank Chen f43fb41bce Simplify debugging of Undertow transferTo issue
This commit introduces a dedicated (disabled) transferToWithUndertow()
test method to simplify debugging of transferTo issues with Undertow.

See gh-25310
Closes gh-27908
2022-01-14 15:44:29 +01:00
Sam Brannen a849f76586 Merge branch '5.3.x' 2022-01-13 17:57:14 +01:00
Sam Brannen c92b9bc7fe Properly abort transferTo test for Undertow
Instead of simply returning prematurely and allowing the tests to be
marked as SUCCESS, this commit uses a failed assumption to abort the
the trasferTo tests for Undertow, resulting in the parameterized test
invocation properly being marked as ABORTED.

See gh-25310
2022-01-13 17:55:37 +01:00
rstoyanchev 7067461d71 Fix exception in Jetty10RequestUpgradeStrategy
Closes gh-27899
2022-01-12 15:04:05 +00:00
rstoyanchev d61d0d41a3 Merge branch '5.3.x' into main 2022-01-12 09:02:07 +00:00
rstoyanchev 7665424ea8 Polishing contribution
Closes gh-27888
2022-01-12 08:55:32 +00:00
Max Demydenko f63a106c85 clear() method also clears argument resolver cache
See gh-27888
2022-01-12 08:55:32 +00:00
Sam Brannen d57bc176f2 Merge branch '5.3.x' 2022-01-10 14:21:25 +01:00
Sam Brannen df263d01b9 Use idiomatic AssertJ assertions for true, false, and null 2022-01-10 14:15:55 +01:00
Sébastien Deleuze a410f4c0f2 Upgrade Kotlin Coroutines to 1.6.0
Closes gh-27878
2022-01-03 15:45:37 +01:00
izeye 713795cc34 Polish
See gh-27827
2021-12-21 09:36:08 +01:00
Juergen Hoeller ba468a731f Remove JamonPerformanceMonitorInterceptor support
Includes upgrade to Tomcat 10.0.14, Undertow 2.2.14, Apache HttpClient 5.1.2, Hibernate ORM 5.6.2, Mockito 4.1.

Closes gh-27786
2021-12-14 09:46:08 +01:00
Rossen Stoyanchev 3600644ed1 Require type-level @Controller annotation
Closes gh-22154
2021-12-14 07:09:08 +00:00
Rossen Stoyanchev a15393836c Merge branch '5.3.x' into main 2021-12-09 15:35:21 +00:00
Rossen Stoyanchev e9083d7d20 Apply LogFormatUtils in more places 2021-12-09 14:53:52 +00:00
Juergen Hoeller 7f43128a0e Merge branch '5.3.x'
# Conflicts:
#	build.gradle
#	spring-web/src/main/java/org/springframework/web/server/MediaTypeNotSupportedStatusException.java
#	spring-web/src/main/java/org/springframework/web/util/ContentCachingRequestWrapper.java
#	spring-webmvc/src/main/java/org/springframework/web/servlet/handler/HandlerMappingIntrospector.java
2021-12-03 22:42:05 +01:00
Juergen Hoeller 70974e006e Upgrade to Tomcat 9.0.55, Undertow 2.2.13, RxJava 3.1.3, SmallRye Mutiny 1.2, Joda-Time 2.10.13, JRuby 9.2.20.1, HtmlUnit 2.55, Checkstyle 9.2 2021-12-03 22:32:00 +01:00
Arjen Poutsma 0a41da9ec9 Merge branch '5.3.x' 2021-12-03 12:52:30 +01:00
Arjen Poutsma b84fe99d07 Polish "Throw 404 ResponseStatusException when no routes found"
See gh-25358
2021-12-03 12:01:49 +01:00
Ingmar van Dijk 69df27a99f Throw 404 ResponseStatusException when no routes found
This commit makes it possible to customize 404 responses generated by
RouterFunctionWebHandler, by throwing an ResponseStatusException
instead of returning a standard 404 response.

See gh-25358
2021-12-03 12:01:49 +01:00
Rossen Stoyanchev a9d2016007 Merge branch '5.3.x' into main 2021-12-03 09:27:11 +00:00
Rossen Stoyanchev 5649a6f8ef Update exchangeToMono Javadoc
This time showing a more representative example.

See gh-27645
2021-12-03 09:21:21 +00:00
Arjen Poutsma be6eeafe78 Revert change createException to createError
createError is not available in 5.3.

See gh-27645
2021-12-02 15:59:51 +01:00
Arjen Poutsma 720c30ce84 Merge branch '5.3.x' 2021-12-02 15:12:01 +01:00
Arjen Poutsma b77b45434f Change createException to createError
See gh-27645
2021-12-02 15:11:15 +01:00
Rossen Stoyanchev 2d2db530b1 Merge branch '5.3.x' into main 2021-12-02 12:35:48 +00:00
Rossen Stoyanchev 8b89128c7b Update createException example for WebClient
Closes gh-27645
2021-12-02 11:53:43 +00:00
Arjen Poutsma 7794606305 Add ClientResponse::createError
This commit introduces ClientResponse::createError, returning
a Mono that terminates with a WebClientException.

Closes gh-27637
2021-12-01 11:10:10 +01:00
Arjen Poutsma 7a4207cd7b Changes because HttpMethod changed to class
This commit contains changes made because HttpMethod changed from enum
to class.

See gh-27697
2021-11-30 13:44:36 +01:00
Arjen Poutsma f57004db2c Merge branch '5.3.x' 2021-11-30 13:41:19 +01:00
Arjen Poutsma 2a5713f389 Always copy ServerResponse headers
Prior to this commit, ServerResponse headers would only be written if
there were no existing headers with the same name, thus making it
impossible to overwrite existing headers.

With the changes in this commit, headers are always written.

Closes gh-27741
2021-11-30 13:38:16 +01:00
Arjen Poutsma 259bcd60fb Change deprecated MimeType specificity usages
This commit changes all code that uses now deprecated methods in
MimeType and MediaType.

See gh-27580
2021-11-23 11:49:01 +01:00
Rossen Stoyanchev 1694691b79 Default to JDK HttpClient if no others present
Closes gh-23432
2021-11-22 12:20:30 +00:00
Rossen Stoyanchev fe8d42ff59 Add JdkHttpClientResourceFactory
See gh-23432
2021-11-22 12:20:30 +00:00
Rossen Stoyanchev dcc7154641 Polishing contribution
See gh-23432
2021-11-22 12:20:30 +00:00
Julien Eyraud d930617442 JDK HttpClient connector for WebClient
See gh-21014
2021-11-22 12:20:30 +00:00
Juergen Hoeller 4750a9430c Early removal of 5.x-deprecated code
Closes gh-27686
2021-11-18 09:18:06 +01:00
Juergen Hoeller b88ed7f4bb Update API version and package references for Jakarta EE 9
Closes gh-27689
See gh-25354
2021-11-17 12:39:23 +01:00
Arjen Poutsma 33ed92e552 Merge branch '5.3.x' 2021-11-10 16:26:31 +01:00
Arjen Poutsma 9197f15a30 Use ByteArrayDecoder in DefaultClientResponse::createException
This commit changes DefaultClientResponse::createException to use
the ByteArrayDecoder, instead of converting to DataBuffers and
turning these into a byte array.

Closes gh-27666
2021-11-10 16:24:49 +01:00
Christoph Dreis 5c972fcc54 Use Charset variants of URLEncoder and URLDecoder methods 2021-11-10 16:12:11 +01:00
Juergen Hoeller 75036fa0ad Merge branch '5.3.x' 2021-11-10 14:22:58 +01:00
Juergen Hoeller 2a268701c4 Introduce optimizeLocations flag for resource location filtering on startup
This flag is off by default since it requires jar files with directory entries.

Closes gh-27624
2021-11-10 14:21:48 +01:00