Commit Graph

4007 Commits

Author SHA1 Message Date
Rossen Stoyanchev 1c5b95db0b Revert workaround in Jetty connector
The workaround was removed in the 5.3 milestone phase and in master
only because the referenced Jetty issue is marked fixed. However,
what we need to replace it with should be a little more involved
and also it's not entirely clear if the fixes in Jetty aligns with
our release and retain semantics so that needs to be investigated
more thoroughly.
2020-10-06 18:18:26 +01:00
Сергей Цыпанов 8a04910bdd Drop explicit zeroing at instantiation of Atomic* objects 2020-10-06 15:45:12 +02:00
Juergen Hoeller b7e1553c9d Merge branch '5.2.x'
# Conflicts:
#	build.gradle
#	spring-orm/src/main/java/org/springframework/orm/hibernate5/LocalSessionFactoryBuilder.java
2020-10-06 15:37:54 +02:00
Juergen Hoeller f83bb7183e Polishing 2020-10-06 15:31:34 +02:00
Rossen Stoyanchev d3087537d5 Merge branch '5.2.x' into master 2020-10-02 14:39:27 +01:00
Rossen Stoyanchev 2533ba5253 Use Mono.fromDirect for Jetty ReactiveRespnose
Closes gh-25849
2020-10-02 13:43:42 +01:00
Rossen Stoyanchev e44b08f1fc Minor refactoring in JettyClientHttpConnector
See gh-25849
2020-10-02 13:32:00 +01:00
Sam Brannen ba94a1216c Deprecate HttpStatus.Series.valueOf(HttpStatus) and polish
See gh-22366
2020-09-26 16:06:31 +02:00
Nico Heller 97cc89630d Remove inefficiency in HttpStatus.series()
Prior to this commit, the Series value for an HttpStatus was always
evaluated which resulted in an allocation of a Series array by invoking
Series.values() which makes a defensive copy.

This commit addresses this issue by hardcoding the corresponding Series
within the HttpStatus constructor, thereby avoiding any unnecessary
computations. In addition, a unit test has been added to verify that
all HttpStatus enum constants have a properly configured Series.

Closes gh-22366
2020-09-26 15:04:15 +02:00
Sam Brannen b34778d220 Polishing 2020-09-26 15:02:15 +02:00
Rossen Stoyanchev 852e904b08 Exposes getter for part converters in FormHttpMessageConverter
Closes gh-25817
2020-09-25 21:31:44 +01:00
Juergen Hoeller 7116e5f755 Polishing 2020-09-25 20:40:54 +02:00
Sébastien Deleuze 2dbceb9053 Deprecate LiveBeansView
This commit deprecates LiveBeansView and related classes in order to allow
a future removal in order to increase the separation of concerns between
Spring Framework and Spring Boot, and the consistency between JVM
and native.

Closes gh-25820
2020-09-25 20:04:34 +02:00
Brian Clozel 61d893257e Rewrite "performance" test to JMH benchmarks
This commit rewrites the remaining "fastEnough" performance tests into
proper JMH benchmarks.

See gh-24830
2020-09-25 13:43:38 +02:00
Juergen Hoeller 6c631e3d5c Merge branch '5.2.x'
# Conflicts:
#	spring-messaging/src/main/java/org/springframework/messaging/converter/MappingJackson2MessageConverter.java
2020-09-25 11:36:18 +02:00
Juergen Hoeller 6e4fcb69f0 Polishing 2020-09-25 11:26:01 +02:00
Rossen Stoyanchev 1061bcdba2 Set sameSite in ClientHttpResponse implementations
Closes gh-25785
2020-09-22 07:36:29 +01:00
Juergen Hoeller bbe74635eb Merge branch '5.2.x' 2020-09-18 18:16:33 +02:00
Juergen Hoeller c1617d3c52 Polishing 2020-09-18 18:15:36 +02:00
Juergen Hoeller d5fed34642 Merge branch '5.2.x' 2020-09-15 10:09:18 +02:00
Juergen Hoeller f010368a66 Polishing 2020-09-15 10:08:01 +02:00
Juergen Hoeller f4bdc0284e Polishing 2020-09-15 09:56:53 +02:00
Juergen Hoeller 801c8ed8ac Revise type resolution for alignment with AbstractJsonHttpMessageConverter
See gh-21188
2020-09-15 09:41:14 +02:00
Andreas Ahlenstorf cd6085a310 Add kotlinx.serialization JSON support to Spring MVC
Closes gh-21188

Co-authored-by: Sebastien Deleuze <sdeleuze@vmware.com>
2020-09-14 23:25:16 +02:00
Juergen Hoeller b8c12a3aa1 Upgrade to Undertow 2.2 (and R2DBC Arabba-SR7) 2020-09-14 22:59:46 +02:00
Juergen Hoeller 07b3e92bae Merge branch '5.2.x'
# Conflicts:
#	build.gradle
#	src/docs/asciidoc/core/core-aop-api.adoc
2020-09-14 22:22:02 +02:00
Juergen Hoeller 3c84863271 Polishing 2020-09-14 22:18:30 +02:00
Juergen Hoeller c2f6a98c90 Lenient handling of empty Content-Disposition filename
Closes gh-25769
2020-09-14 22:16:12 +02:00
Rossen Stoyanchev b50ad1b9aa AbstractServerHttpResponse skips commit actions on 2nd pass
Closes gh-25753
2020-09-13 21:21:07 +01:00
Brian Clozel b2a0978c12 Prepare for Sinks API updates in Reactor
See reactor/reactor-core#2374
All usages of this API are in tests, which are not checking overflow or
concurrent emissions - so a simple replacement with `try***` equivalents
is fine.
2020-09-11 16:34:31 +02:00
Arjen Poutsma 3bd96a665f Merge branch '5.2.x' into master 2020-09-10 11:34:44 +02:00
Arjen Poutsma 07d2c08f48 Do not tokenize Forward header value
This commit remove the tokenization previously used in
UriComponentsBuilder#adaptFromForwardedHeaders, in order to support
Forwarded headers that have multiple, comma-separated 'for' elements.

Closes gh-25737
2020-09-09 16:31:24 +02:00
Juergen Hoeller 7dbb40ffa0 Merge branch '5.2.x' 2020-09-08 12:24:18 +02:00
Juergen Hoeller ae1d15c8f4 Declare protected getCharset method as non-static
See gh-25509
2020-09-08 12:22:25 +02:00
Rossen Stoyanchev dd011c991c Merge branch '5.2.x' into master 2020-09-07 21:41:30 +01:00
Rossen Stoyanchev b6ff12d2f5 Expose protected method in AbstractJackson2HttpMessageConverter
Closes gh-25509
2020-09-07 21:27:52 +01:00
Rossen Stoyanchev b1d84067cd UriComponentsBuilder Javadoc update
Closes gh-25604
2020-09-07 21:27:52 +01:00
Rossen Stoyanchev 899761f0a8 Avoid unnecessary parsing of path params
See gh-25690
2020-09-07 21:27:52 +01:00
Rossen Stoyanchev f88759c3c9 Shared read-only instances of UrlPathHelper
UrlPathHelper is often created and used without customizations or with
the same customizations. This commit introduces re-usable, instances.
Effectively a backport of commit 23233c.

See gh-25690
2020-09-07 21:27:52 +01:00
Arjen Poutsma d550d344d5 Respect context path in WebMvc.fn & WebFlux.fn
This commit makes several changes in both WebMvc.fn as well as
WebFlux.fn.

 - ServerRequest now exposes a RequestPath through requestPath(), and
   pathContainer() has been deprecated.

 - The PathPredicate and PathResourceLookupFunction now respects this
   RequestPath's pathInApplication() in their path-related
   functionality.

 - When nesting, the PathPredicate now appends the matched part of the
   path to the current context path, instead of removing the matched
   part (which was done previously). This has the same result: the
   matched part is gone, but now the full path stays the same.

Closes gh-25270
2020-09-03 15:10:56 +02:00
Juergen Hoeller 689adb4bd0 Merge branch '5.2.x'
# Conflicts:
#	build.gradle
2020-09-01 23:46:11 +02:00
Juergen Hoeller 141470ff58 Explicit nullability declarations for getTarget() implementations 2020-09-01 23:26:22 +02:00
Juergen Hoeller e20bff9c64 Consistent data class constructor resolution with clear error message
MVC data class processor constructs target instance even in case of binding failure, as long as the corresponding method parameter is not marked as optional.

Closes gh-24372
2020-09-01 19:10:32 +02:00
Juergen Hoeller e365e0221a Merge branch '5.2.x'
# Conflicts:
#	spring-web/src/main/java/org/springframework/web/util/UrlPathHelper.java
2020-09-01 10:30:59 +02:00
Juergen Hoeller d62202f464 Polishing 2020-09-01 10:27:36 +02:00
Juergen Hoeller bcdc2503fa Avoid repeated calls to getPathWithinApplication from getLookupPathForRequest
Closes gh-25669
2020-09-01 10:27:04 +02:00
Johnny Lim 603d7e93b9 Copy httpHandlerDecorator in copy constructor for WebHttpHandlerBuilder
This commit also polishes its Javadoc and fixes its test along the way.
2020-09-01 10:09:34 +02:00
Juergen Hoeller c4f4fbc003 Polishing 2020-08-28 20:14:24 +02:00
Juergen Hoeller 00c5dbf11a Merge branch '5.2.x'
# Conflicts:
#	spring-beans/src/main/java/org/springframework/beans/CachedIntrospectionResults.java
2020-08-28 20:01:17 +02:00
Juergen Hoeller 6d9d4157ef Specifically detect Joda-Time 2.x
Closes gh-25655
2020-08-28 19:57:51 +02:00
Juergen Hoeller d37eaa5941 Introduce DataClassRowMapper with record-style constructor binding support
Closes gh-24695
2020-08-28 18:52:35 +02:00
Juergen Hoeller cf2e0c7959 Selected use of ArrayList instead of LinkedList in common places
See gh-25652
2020-08-27 14:14:44 +02:00
Rossen Stoyanchev 21d25b23d9 WebFlux extension point to decorate the HttpHandler
Closes gh-25633
2020-08-27 10:50:30 +01:00
Juergen Hoeller 874574513c Replace remaining usage of LinkedList with ArrayList/ArrayDeque
Closes gh-25650
2020-08-26 18:32:08 +02:00
Riley Park 6884a3ac56 Fix appendix typos in ContentDisposition 2020-08-26 11:33:27 +01:00
Juergen Hoeller ff11467a0c Avoid resizing of fixed-size HashMap/LinkedHashMap variants
Closes gh-25349
2020-08-25 19:26:18 +02:00
Juergen Hoeller 7324140d20 Merge branch '5.2.x' 2020-08-25 16:21:00 +02:00
Juergen Hoeller 04df9b8f49 Efficient checks for empty strings and single character matches
Closes gh-25552
Closes gh-25553
2020-08-25 16:17:12 +02:00
Rossen Stoyanchev 7adeb461e0 WebClient exposes API for access to native request
Closes gh-25115, gh-25493
2020-08-24 07:58:35 +01:00
Rossen Stoyanchev a7f71f4d9b Support filename hint for client side too
Closes gh-25516
2020-08-14 15:18:39 +01:00
Sam Brannen 4d3dd9b9f6 Clean up warnings in Gradle build 2020-08-11 17:20:27 +02:00
Sam Brannen 5de549d7d4 Update contentType property via MockHttpServletResponse::setCharacterEncoding()
Prior to this commit, MockHttpServletResponse's setCharacterEncoding()
method did not update the contentType property, which violates the
Servlet 2.4 Javadoc for getContentType() and setCharacterEncoding().

This commit addresses this issue; however, some existing tests may have
to be updated as a result of this change.

For example, note how some of the tests in this commit have been
refactored to use MediaType##isCompatibleWith() instead of asserting
exact matches for the value returned by MockHttpServletResponse's
getContentType() method.

Closes gh-25536
2020-08-10 16:05:18 +02:00
Сергей Цыпанов c2122551c8 Improve UriComponents.sanitizeSource() 2020-08-10 14:47:20 +02:00
Juergen Hoeller 7b6e1c957f Merge branch '5.2.x' 2020-08-10 14:44:22 +02:00
Juergen Hoeller 9bf5cba3c2 Drop outdated notes on handler type versus handler method restrictions
Closes gh-25482
2020-08-10 14:43:27 +02:00
Sam Brannen d0cf90bb8e Update tests due to deprecations in Reactor 2020-08-08 12:40:23 +02:00
Sam Brannen 17acc3554c Sync MockServerHttpResponse changes 2020-08-08 12:31:50 +02:00
Juergen Hoeller 8dd285f877 Polishing 2020-08-07 13:02:43 +02:00
Juergen Hoeller d61c0ee57d Consistent support for path variable and multipart binding
Closes gh-24107
Closes gh-22169
Closes gh-25265
2020-08-06 18:28:09 +02:00
Brian Clozel b6d2a2980d Update for Reactor API changes 2020-08-05 13:31:39 +02:00
Stephane Nicoll 673f83e388 Adapt to API changes in the latest reactor snapshot 2020-08-04 11:41:30 +02:00
Sam Brannen 58412affaa Merge branch '5.2.x' 2020-08-01 14:02:22 +02:00
Sam Brannen 5576321b04 Reset charset field in MockHttpServletResponse
Prior to this commit, calling reset() on MockHttpServletResponse did not
reset the `charset` field to `false` which could result in the
"Content-Type" header containing `;charset=null` which in turn would
result in errors when parsing the "Content-Type" header.

This commit resets the charset field to `false` in
MockHttpServletResponse's reset() method to avoid such errors.

Closes gh-25501
2020-08-01 14:01:39 +02:00
Sam Brannen 785ab5798a Sync MockHttpServletResponse changes 2020-08-01 12:43:26 +02:00
Sam Brannen 89bb9cb749 Polish Javadoc 2020-08-01 12:26:56 +02:00
Brian Clozel 9aae5ed3fa Update Reactor Netty modules
Since reactor/reactor-netty#739, the `reactor-netty` module is now split
into two: `reactor-netty-core` and `reactor-netty-http`.

This commit updates the Spring Framework build accordingly.
2020-08-01 11:49:15 +02:00
Sébastien Deleuze 5c456db3cc Upgrade to Kotlin 1.4 RC
- The compiler is configured to retain compatibility with Kotlin 1.3.
- Explicit API mode is not yet enabled but could be in the future.
- Some exceptions thrown by Kotlin have changed to NullPointerException,
  see https://youtrack.jetbrains.com/issue/KT-22275 for more details.

Closes gh-24171
2020-07-30 10:18:33 +02:00
Rossen Stoyanchev 683cc2eb7f Add NDJSON and deprecate application/stream+json
Closes gh-21283
2020-07-28 17:53:37 +03:00
Rossen Stoyanchev 354635ede0 Polishing 2020-07-28 17:53:37 +03:00
Juergen Hoeller 77137719d8 Polishing 2020-07-28 11:29:57 +02:00
Juergen Hoeller a1a9bb3e7f Explicit note on phasing out serialization-based remoting
See gh-25379
2020-07-28 11:28:34 +02:00
Juergen Hoeller 9f211de113 Turn MethodArgumentNotValidException into subclass of BindException
Closes gh-23107
2020-07-28 11:08:04 +02:00
Sam Brannen 86c52a842f Support multiple Content-Language values in MockHttpServletResponse
Prior to this commit, if the user supplied a comma-separated list such
as "en, it" as the Content-Language header value to
MockHttpServletResponse's setHeader() method, only the first language
was actually set in the response's Content-Language header (e.g., "en").

This commit ensures that all supplied content languages are set in the
response's Content-Language header.

Closes gh-25281
2020-07-27 17:47:46 +02:00
Sam Brannen d2db43a900 Polish Javadoc 2020-07-27 14:38:24 +02:00
Sam Brannen 335c3d5db6 Polish contribution
See gh-25445
2020-07-22 17:26:59 +02:00
XenoAmess ab859fcc96 Refine use of substring operations
Closes gh-25445
2020-07-22 17:26:42 +02:00
Sam Brannen a8901e3cf8 Polish contribution
See gh-25445
2020-07-22 16:36:14 +02:00
XenoAmess edfc6c0293 Refine use of substring operations
Closes gh-25445
2020-07-22 16:28:58 +02:00
Sam Brannen cdc234d7db Polish contribution
See gh-25446
2020-07-22 14:06:29 +02:00
XenoAmess c547809e89 Use instanceof instead of Class#isInstance where feasible
Closes gh-25446
2020-07-22 14:06:29 +02:00
XenoAmess 3b12beb1b8
Simplify if-statements with instanceof checks
Closes gh-25449
2020-07-22 10:34:27 +02:00
XenoAmess c7f44ff671
Fix links in Javadoc
Closes gh-25448
2020-07-22 10:24:55 +02:00
Juergen Hoeller 88394bff66 Merge branch '5.2.x' 2020-07-20 07:21:36 +02:00
Juergen Hoeller 65e601090f Copy queryParams MultiValueMap through addAll (for independent List entries)
Closes gh-25423
2020-07-20 07:07:17 +02:00
Juergen Hoeller e4e54b3c4a Merge branch '5.2.x' 2020-07-19 20:01:21 +02:00
Juergen Hoeller 9a618dc7a1 Enforce ConditionalContentCachingResponseWrapper in ShallowEtagHeaderFilter
Closes gh-24976
2020-07-19 19:53:29 +02:00
Juergen Hoeller 198d64d539 Merge branch '5.2.x'
# Conflicts:
#	build.gradle
2020-07-17 17:52:08 +02:00
Juergen Hoeller e9898f7d52 Polishing 2020-07-17 17:48:33 +02:00
Juergen Hoeller 01bab89dba Consistently use PropertySource.getName() for comparison
Includes synchronization for mutators on MutablePropertySources.

Closes gh-25369
2020-07-17 17:45:58 +02:00
Yanming Zhou d2e1150c79
Fix typo in javadoc for @RequestMapping
Closes gh-25396
2020-07-16 08:41:39 +02:00
Sam Brannen 4578e49213 Merge branch '5.2.x' 2020-07-15 19:04:05 +02:00
Sam Brannen fcf20bab2a Delete duplicate code block in WebHttpHandlerBuilder.applicationContext()
This commit deletes a duplicated code block that was accidentally
introduced in a8a1fc6de5.

Closes gh-25389
2020-07-15 18:58:31 +02:00
Rossen Stoyanchev 03fa48919e Switch to Reactor Dysprosium snapshots
See gh-25376
2020-07-13 16:51:09 +03:00
Brian Clozel d9ccd618ea Deprecate remoting technologies support
Because of security and broader industry support, support for several
remoting technologies is now deprecated and scheduled for removal in
Spring Framework 6.0.

This commit deprecates the following remoting technologies:

* HTTPInvoker
* RMI
* Hessian
* JMS remoting

Other remoting technologies like EJB or JAXWS might be deprecated in the
future depending on industry support.

Closes gh-25379
2020-07-10 12:04:24 +02:00
Rossen Stoyanchev 37366e0c91 Support for custom status in ResponseStatusException
Closes gh-20336
2020-07-09 15:06:33 +03:00
Rossen Stoyanchev 47a3a5c970 Switch to Reactor 2020.0.0 snapshots
See gh-25373
2020-07-08 19:52:50 +03:00
Rossen Stoyanchev 0e4e25d227 Updates to CORS patterns contribution
Closes gh-25016
2020-07-08 13:18:46 +03:00
Rossen Stoyanchev 1181bb1852 Rename originsPattern to originPatterns
See gh-25016
2020-07-08 13:18:46 +03:00
Ruslan Akhundov 8632118e8d CorsConfiguration now supports pattern based origins.
Closes gh-24763
2020-07-08 13:18:46 +03:00
Johnny Lim 72e92211ce Polish mutateContextPathWithoutUpdatingPathShouldFail()
Closes gh-25352
2020-07-02 16:58:32 +02:00
Arjen Poutsma f13ab6d18c Merge branch '5.2.x' 2020-07-01 13:29:15 +02:00
Arjen Poutsma 5b94d9b00b Use UTF-8 for application/*+json
This commit makes sure that the StringHttpMessageConverter reads
input with "application/*+json" as Content-Type with the UTF-8
character set.

Closes gh-25328
2020-07-01 10:46:58 +02:00
Rossen Stoyanchev 3aaff40e2e Replace explicit use of PooledDataBuffer.release() 2020-07-01 08:07:50 +01:00
Arjen Poutsma e251075d6c Merge branch '5.2.x' 2020-06-30 15:49:19 +02:00
Arjen Poutsma 79c339b03e Support for ASCII in Jackson codec & converter
This commit introduces support for writing JSON with an US-ASCII
character encoding in the Jackson encoder and message converter,
treating it like UTF-8.

See gh-25322
2020-06-30 15:46:54 +02:00
Sam Brannen a92441186c Check for valid IPv6 host in UriComponentsBuilder.fromUriString
PR gh-358 introduced a "scheme but no host" check in the fromHttpUrl()
method in UriComponentsBuilder, but a similar check was not added to
fromUriString() at that time.

This commit introduces a "scheme but no host" check in fromUriString()
to align with the functionality in fromHttpUrl().

Note, however that the regular expressions used to match against the
hostname or IP address are inexact and still permit invalid host names
or IP addresses. True validation of the host portion of the URI is out
of scope for this commit.

Closes gh-25334
2020-06-29 18:36:21 +02:00
Sam Brannen df673e65e8 Polish contribution
See gh-25300
2020-06-26 19:20:54 +02:00
May 43df06b905
Replace anonymous inner classes with lambda expressions
Closes gh-25319
2020-06-26 18:47:38 +02:00
Sam Brannen ba5f4f5414 Merge branch '5.2.x' 2020-06-26 18:31:07 +02:00
Sam Brannen 9876ca003b Support fragments in UriComponentsBuilder.fromHttpUrl()
Prior to this commit, UriComponentsBuilder.fromHttpUrl() threw an
IllegalArgumentException if the provided URL contained a fragment.

This commit aligns the implementation of fromHttpUrl() with that of
fromUriString(), by parsing a fragment and storing it in the builder.

Closes gh-25300
2020-06-26 18:30:09 +02:00
Sam Brannen dd11dbf3b1 Polish UriComponentsBuilderTests 2020-06-26 14:58:06 +02:00
Rossen Stoyanchev 115ea253f6 Fix typo 2020-06-24 16:29:47 +01:00
Rossen Stoyanchev b16f6fa456 Shared static instance of DefaultDataBufferFactory 2020-06-24 16:12:56 +01:00
Sam Brannen 049f5250fe Suppress varargs warning
Prior to this commit, the Gradle build failed due to a varargs warning.

See gh-25311
2020-06-24 15:38:39 +02:00
Philippe Marschall a142d21700 Use @SafeVarargs in Jackson builder and factory
Using @SafeVarargs in Jackson mapper builder and factory bean classes
allows the varargs methods to be used without a compiler warning. The
implementations of these methods do not perform unsafe operations on
their varargs parameter. It is therefore safe to add this annotation.

The following two methods are changed:

- add @SafeVarargs to Jackson2ObjectMapperBuilder#modulesToInstall
  and make it final
- add @SafeVarargs to
  Jackson2ObjectMapperFactoryBean#setModulesToInstall and make it final

This is a backwards incompatible change as these methods now have to be
declared final. Existing subclasses that override one of these methods
will break.

Closes gh-25311
2020-06-24 15:38:21 +02:00
Sam Brannen b33d2fe683 Clean up warnings in Gradle build, polishing, etc. 2020-06-24 15:02:24 +02:00
Arjen Poutsma 51cc719c00 Remove UndertowDataBuffer
This commit removes the UndertowDataBuffer, in favor of using regular
DataBuffers from the DataBufferFactory. During the development of the
DefaultPartHttpMessageReader, it was determined that invoking various
slicing and releasing operators on the UndertowDataBuffer resulted in
memory leaks. This commit fixes that.
2020-06-24 10:31:48 +02:00
Arjen Poutsma 973ee9b852 (Re)introduce DefaultMultipartMessageReader
This commit introduces the DefaultMultipartMessageReader, a fully
reactive multipart parser without third party dependencies.

An earlier version of this code was introduced in fb642ce, but removed
again in 77c24aa because of buffering issues.

Closes gh-21659
2020-06-24 10:31:48 +02:00
Rossen Stoyanchev 57f868fcbd Direct matches by URL path work again
This commit fixes a recent regression as a result of 5225a57411
with the determination of non-pattern vs pattern URLs. That in turn affects the ability to perform
direct matches by URL path.

There is also a fix in PathPattern to recognize "catch-all" patterns as pattern syntax.

See gh-24945
2020-06-24 08:07:40 +01:00
Juergen Hoeller 7e71749e34 Merge branch '5.2.x' 2020-06-23 23:26:52 +02:00
Juergen Hoeller b0cabb29f3 Polishing 2020-06-23 23:20:45 +02:00
Rossen Stoyanchev 19fb0f113b Merge branch '5.2.x' 2020-06-23 20:47:49 +01:00
Rossen Stoyanchev 22bf62def1 Replace remaining use of deprecated Processors in tests
See gh-25085
2020-06-23 20:29:35 +01:00
Rossen Stoyanchev 21d069695f Refine solution for 21de09
The following was reported after the change and is related to it:
https://github.com/reactor/reactor-netty/issues/1170. An HTTP HEAD with the body
not consumed. Connection is disposed and closed leading to subsequent request to
fail. Adding toBodilessEntity() helps.

This change does not close the connection but rather drains the body which does
not impact subsequent re-use of the connection. This however may compete with a
late subscriber actually attempting to read the response. At that point there is
little choice but to raise an ISE with a more specific description.

See gh-25216
2020-06-23 19:58:57 +01:00
Juergen Hoeller d0209e5f1f Nullability refinements and related polishing 2020-06-23 16:55:09 +02:00
Juergen Hoeller 97efacc9a4 Merge branch '5.2.x'
# Conflicts:
#	spring-aspects/src/main/java/org/springframework/beans/factory/aspectj/AnnotationBeanConfigurerAspect.aj
2020-06-23 12:01:24 +02:00
Juergen Hoeller 9e12a20324 Polishing 2020-06-23 11:35:22 +02:00
Kamil Szymanski 23aeba0e46 Fix typos in WebRequest.checkNotModified docs
Closes gh-1035
2020-06-23 09:45:07 +02:00
Brian Clozel 1f78cede72 Merge branch '5.2.x' 2020-06-22 19:21:32 +02:00
Brian Clozel c4326cb0f5 Fix missing contextPath when mutating ServerHttpRequest
This commit ensures that when mutating `ServerHttpRequest` instances,
the original contextPath information is copied to the request being
built.

Note that mutation on the `contextPath(String)` or `path(String)` should
be reflected to the other. (See their Javadoc for more information).

Fixes gh-25279
2020-06-22 19:13:10 +02:00
Sam Brannen eeb6c10fb7 Polishing 2020-06-22 14:03:06 +02:00
Sam Brannen b733474c64 Polish contribution
See gh-25292
2020-06-22 13:23:40 +02:00
Undefined 53df8ca1f5 Introduce unit tests for IntegerToEnumConverterFactory
Closes gh-25292
2020-06-22 13:12:37 +02:00
Arjen Poutsma ed648b793b Merge branch '5.2.x' 2020-06-22 09:50:04 +02:00
Arjen Poutsma 405fdd3a57 Map from charset name rather than Charset
With this commit it is no longer assumed that all charset names in the
JsonEncoding can be resolved by Charset.forName. Instead, we store the
charset name itself, rather than the Charset object.
2020-06-22 09:48:41 +02:00
Rossen Stoyanchev 96bbec7ab2 Restore use of tcpConfiguration method
The method wasn't available at first but has been added since to allow
being compatible with both Reactor Netty 0.9 and 1.0.

See gh-25085
2020-06-22 05:45:41 +01:00
Rossen Stoyanchev d627f6049e Update "Forwarded: for" contribution
Closes gh-23582
2020-06-22 05:40:13 +01:00
Kirill Serebrennikov 883ad098f9 Add support for X-Forwarded-For and Forwarded for
See gh-23260, gh-23582
2020-06-22 05:40:13 +01:00
Sam Brannen ab0e651547 Polish SerializationTestUtils, clean up warnings, etc. 2020-06-20 18:17:03 +02:00
Sam Brannen 9d5881e0ad Suppress warnings, remove unused code, etc. 2020-06-20 17:15:35 +02:00
Sébastien Deleuze 2f0970b184 Fix an AllEncompassingFormHttpMessageConverter regression
Restore previous behavior to configure
Jaxb2RootElementHttpMessageConverter when JAXB but not Jackson are present.

Closes gh-25291
2020-06-20 17:05:13 +02:00
Rossen Stoyanchev 78d1591e2d Merge branch '5.2.x' 2020-06-19 22:09:43 +01:00
Rossen Stoyanchev f35903f23d Catch IllegalReferenceCountException
Closes gh-22594
2020-06-19 21:58:03 +01:00
Rossen Stoyanchev 21de098756 Dispose on cancel if response not subscribed
Closes gh-25216
2020-06-19 21:58:03 +01:00
Brian Clozel e0e1c12402 Merge branch '5.2.x' 2020-06-19 16:45:35 +02:00
Brian Clozel 9b615ed8c6 Fix missing sslInfo with Reactor Netty and http/2
Prior to this commit, the `SslInfo` would be missing for WebFlux apps
when deployed on Reactor Netty with http/2.

This commit ensures that the request adapter checks the current channel
and the parent channel for the presence of the `SslHander`.
In the case of http/2, the `SslHander` is tied to the parent channel.

Fixes gh-25278
2020-06-19 16:43:34 +02:00
Sébastien Deleuze 1e501f2583 Provide a flag to disable XML support
This commit introduces a spring.xml.ignore system property
which when set to true avoid initializing XML infrastructure.

A typical use case is optimizing GraalVM native image footprint
for applications not using XML. In order to be effective, those
classes should be initialized at build time:

- org.springframework.util.DefaultPropertiesPersister
- org.springframework.core.io.support.PropertiesLoaderUtils
- org.springframework.web.servlet.function.support.RouterFunctionMapping
- org.springframework.web.client.RestTemplate
- org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver
- org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport
- org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter
- org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter
- org.springframework.http.codec.support.BaseDefaultCodecs
- org.springframework.beans.PropertyEditorRegistrySupport

Closes gh-25151
2020-06-19 09:42:12 +02:00
Rossen Stoyanchev ce728a6c4b Update docs for PathPattern support in WebMvc
Closes gh-24945
2020-06-18 21:16:43 +01:00
Sébastien Deleuze 6b355df903 Revert "Upgrade to Kotlin 1.4 M2"
This reverts commit 2a74eff10f.

Some regressions require to wait at least Kotlin 1.4 M3.
2020-06-18 14:06:39 +02:00
Brian Clozel 6615e9c5ef Support multi-value X-Forwarded-Prefix headers
Prior to this commit, the Forwarded headers for Spring MVC and Spring
WebFlux did not support multiple prefix values for the
`"X-Forwarded-Prefix"` HTTP header.

This commit splits and processes multiple prefixes defined in the
dedicated header.

Closes gh-25254
2020-06-18 13:18:02 +02:00
Rossen Stoyanchev bc33ae3f8b Update multipart RequestMatcher
See gh-23772
2020-06-18 07:49:27 +01:00
Сергей Цыпанов 7949937655 Remove redundant assignment of default values to volatile fields 2020-06-17 10:50:51 +02:00
Sam Brannen 8099fc8178 Use try-with-resources language construct where feasible
Closes gh-2063

Co-authored-by: igor-suhorukov <igor.suhorukov@gmail.com>
2020-06-16 22:57:45 +02:00
Sébastien Deleuze 2a74eff10f Upgrade to Kotlin 1.4 M2
- The compiler is configured to retain compatibility with Kotlin 1.3.
- Explicit API mode is not yet enabled but could be in the future.
- A workaround for Gradle build is required for now, see
  https://youtrack.jetbrains.com/issue/KT-39610 for more details.
- Some exceptions thrown by Kotlin have changed to NullPointerException,
  see https://youtrack.jetbrains.com/issue/KT-22275 for more details.

Closes gh-24171
2020-06-16 15:21:57 +02:00
Arjen Poutsma 97aba77cc1 Merge branch '5.2.x' 2020-06-16 14:30:43 +02:00
Arjen Poutsma 9c3417f703 Convert non-unicode input when reading w/ Jackson
This commit makes sure that Jackson-based message converters and
decoders can deal with non-unicode input. It does so by reading
non-unicode input messages with a InputStreamReader.

This commit also adds additional tests forthe canRead/canWrite methods
on both codecs and message converters.

Closes: gh-25247
2020-06-16 11:45:53 +02:00
Rossen Stoyanchev 5225a57411 Support for parsed PathPatterns in Spring MVC
See gh-24945
2020-06-15 11:25:35 +01:00
Rossen Stoyanchev a0f4d81db7 Remove http -> web package dependency
See gh-24406
2020-06-15 11:25:35 +01:00
Sam Brannen bc4945d677 Ensure non-null condition comes 1st in ternary operator
See gh-25232
2020-06-11 15:11:48 +02:00
GardenLee e866fac8e7 Wrap ternary operator within parentheses as outlined in Code Style
Closes gh-25232
2020-06-11 15:11:48 +02:00
Arjen Poutsma 202799e6fe Rethrow XMLStreamExceptions as DecodingExceptions
Prior to this commit, Jaxb2XmlDecoder and XmlEventDecoder threw
XMLStreamExceptions instead of DecodingExceptions (as the Decoder
contract defines).

This commit resolves this issue.

Closes: gh-24778
2020-06-10 15:56:45 +02:00
Sam Brannen b9e52a8089 Delete dead code in MockServerHttpRequest 2020-06-09 17:38:34 +02:00
Rossen Stoyanchev 1984cfe9d7 Merge branch '5.2.x' 2020-06-08 21:20:44 +01:00
Rossen Stoyanchev a2d516d526 Replace "whitelist" with alternative words 2020-06-08 21:19:28 +01:00
Juergen Hoeller 21b1f30660 Merge branch '5.2.x'
# Conflicts:
#	build.gradle
2020-06-08 20:26:14 +02:00
Juergen Hoeller c777468056 Polishing 2020-06-08 19:37:58 +02:00
Juergen Hoeller a34f1e3759 Merge branch '5.2.x'
# Conflicts:
#	build.gradle
#	spring-test/src/main/java/org/springframework/mock/http/server/reactive/MockServerHttpRequest.java
#	spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/server/reactive/MockServerHttpRequest.java
#	spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClientBuilder.java
2020-06-06 18:52:51 +02:00
Juergen Hoeller 65154170d3 Polishing 2020-06-06 18:49:32 +02:00
Juergen Hoeller d71957ce7c Polishing 2020-06-06 17:45:12 +02:00
Juergen Hoeller 7244f03064 Avoid unnecessary creation of not-found entity in ResponseEntity#of
Closes gh-25183
2020-06-06 17:44:30 +02:00
Juergen Hoeller 65b09be669 Polishing 2020-06-06 16:10:20 +02:00
Juergen Hoeller 5051d7302d Merge branch '5.2.x'
# Conflicts:
#	build.gradle
#	spring-test/src/main/java/org/springframework/mock/http/server/reactive/MockServerHttpRequest.java
#	spring-web/src/main/java/org/springframework/http/HttpHeaders.java
#	spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/server/reactive/MockServerHttpRequest.java
2020-06-06 15:27:15 +02:00
Juergen Hoeller f3d4df2fd4 Consistently check available local/remote addresses for non-null 2020-06-06 15:15:16 +02:00
Juergen Hoeller ad5710c1d1 Restore original readOnlyHttpHeaders signature for binary compatibility
Closes gh-25034
2020-06-06 13:14:47 +02:00
Arjen Poutsma 5f1326f233 Respect MimeType charset in Jackson codecs
Before this commit, Jackson2CodecSupport and subclasses
did not check media type encoding in the supportsMimeType
method (called from canEncode/canDecode).
As a result, the encoder reported that it can write
(for instance) "application/json;charset=ISO-8859-1", but in practice
wrote the default charset (UTF-8).

This commit fixes that bug.

Closes: gh-25076
2020-06-05 15:09:05 +02:00
Arjen Poutsma 6a829a322a Respect MediaType charset in Jackson converters
Before this commit, AbstractJackson2HttpMessageConverter and subclasses
did not check media type encoding in the canRead and canWrite
methods. As a result, the converter reported that it can write
(for instance) "application/json;charset=ISO-8859-1", but in practice
wrote the default charset (UTF-8).

This commit fixes that bug.

See: gh-25076
2020-06-05 15:09:05 +02:00
Arjen Poutsma 847629412f Respect MimeType charset in Jackson codecs
Before this commit, Jackson2CodecSupport and subclasses
did not check media type encoding in the supportsMimeType
method (called from canEncode/canDecode).
As a result, the encoder reported that it can write
(for instance) "application/json;charset=ISO-8859-1", but in practice
wrote the default charset (UTF-8).

This commit fixes that bug.

Closes: gh-25076
2020-06-05 10:53:28 +02:00
Arjen Poutsma eb0aae066c Respect MediaType charset in Jackson converters
Before this commit, AbstractJackson2HttpMessageConverter and subclasses
did not check media type encoding in the canRead and canWrite
methods. As a result, the converter reported that it can write
(for instance) "application/json;charset=ISO-8859-1", but in practice
wrote the default charset (UTF-8).

This commit fixes that bug.

See: gh-25076
2020-06-05 10:52:42 +02:00
Rossen Stoyanchev a7f8120164 Merge branch '5.2.x' 2020-06-03 06:14:20 +01:00
Rossen Stoyanchev 1e25556049 Shared PathPatternParser instance
See gh-25143
2020-06-03 05:58:10 +01:00
Rossen Stoyanchev 8d449471c7 Polishing contribution
See gh-25148
2020-05-29 17:37:43 +01:00
Mihai Dumitrescu b31b8ce6c1 Polishing in MockServerHttpRequest
Closes gh-25109
2020-05-29 16:31:19 +01:00
Rossen Stoyanchev 6d6269f1ee Switch to Reactor 2020.0.0 snapshots
A switch to RSocket 1.0.1 snapshots is also required to pick up a
for froward compatibility with Reactor Netty 1.0.

See gh-25085
2020-05-29 15:14:01 +01:00
Juergen Hoeller 42ff01b5aa Merge branch '5.2.x' 2020-05-29 15:57:32 +02:00
Juergen Hoeller 914425eefa Polishing 2020-05-29 15:52:39 +02:00
Sam Brannen 7e2b81729e Polish ContentDisposition 2020-05-28 14:57:53 +02:00
Sam Brannen 967478b3a7 Merge branch '5.2.x' 2020-05-28 14:45:44 +02:00
Sam Brannen 3201671ceb Polish contribution
See gh-25149
2020-05-28 14:37:18 +02:00
dlsrb6342 fce972eec8 Fix BaseCodecConfigurer clone bug
Prior to this commit, ExchangeStrategies custom codec's reader and
writer were not registered due to a bug in BaseCodecConfigurer.

This commit fixes this by correcting the implementation of the
DefaultCustomCodecs constructor used within BaseCodecConfigurer.

Closes gh-25149
2020-05-28 12:34:29 +02:00
Rossen Stoyanchev 90ccabd60b Merge branch '5.2.x' 2020-05-27 19:12:57 +01:00
Rossen Stoyanchev c0c3c01afd Fix race condition in WriteResultPublisher
between subscription and error from the Publish

Closes gh-25096
2020-05-27 19:11:29 +01:00
Rossen Stoyanchev 955f77bf5d Add error message to MockServerHttpRequest
Closes gh-25109
2020-05-27 18:57:02 +01:00
Yanming Zhou 94f1d77e22 Polish StringHttpMessageConverter.getContentTypeCharset()
Closes gh-25126
2020-05-26 18:26:21 +02:00
Sam Brannen 5392ac2e07 Add dependency on BouncyCastle for JDK 15+
With a recent upgrade to an early access build for JDK 15,
ServerHttpsRequestIntegrationTests began failing since Netty's
SelfSignedCertificate could not be properly initialized.

This commit adds a test fixture dependency on BouncyCastle which is now
needed by Netty's SelfSignedCertificate on JDK 15 or higher, since JDK 15
no longer supports the javax.security.cert.X509Certificate.

See: https://bugs.openjdk.java.net/browse/JDK-8241039
2020-05-25 17:30:27 +02:00
Rossen Stoyanchev b5d9f27ca4 Merge branch '5.2.x' 2020-05-24 21:20:12 +01:00
Rossen Stoyanchev 4f65ba4e74 Simplify creation of HttpContext for Apache HttpClient
Closes gh-25066
2020-05-24 21:09:49 +01:00
Rossen Stoyanchev 23a66e016e UriBuilder javadoc update
Closes gh-25055
2020-05-24 21:09:13 +01:00
Rossen Stoyanchev c3e55d537e DefaultResponseErrorHandler javadoc update
Closes gh-25067
2020-05-23 10:41:35 +01:00
Rossen Stoyanchev d7a29bbcef DefaultClientResponseBuilder copies logPrefix
Closes gh-25069
2020-05-23 10:41:07 +01:00
Rossen Stoyanchev 8204055924 MockServerHttpRequest accepts custom HTTP method
Closes gh-25109
2020-05-23 10:40:25 +01:00
Sam Brannen da071c1fce Remove unused code 2020-05-19 15:59:17 +02:00
Sam Brannen 59cab5e7d9 Polishing 2020-05-19 15:54:34 +02:00
Rossen Stoyanchev 5ca7928153 Use Servlet 4 mapping type if available
See gh-25100
2020-05-19 10:34:15 +01:00
Rossen Stoyanchev 23233c3041 Shared read-only instance of UrlPathHelper
In many places UrlPathHelper is created and used without any
customizations, in some cases repeatedly. This commit adds a
shared read-only UrlPathHelper instance with default settings.

See gh-25100
2020-05-19 10:34:15 +01:00
Juergen Hoeller 16f1414e5c Merge branch '5.2.x'
# Conflicts:
#	build.gradle
2020-05-18 20:18:31 +02:00
Juergen Hoeller 9631db71c4 Direct exposure of StringBuilder instead of intermediate String
Closes gh-25024
2020-05-18 20:09:24 +02:00
Juergen Hoeller 9999414b3b Merge branch '5.2.x' 2020-05-18 14:24:33 +02:00
Juergen Hoeller c35b21b49f Consistent not-null assertions for configured interceptors
Closes gh-25088
2020-05-18 14:23:05 +02:00
Сергей Цыпанов 703d54677e Avoid unnecessary boxing/unboxing of primitives
Closes gh-25080
2020-05-15 18:01:59 +02:00
Brian Clozel 567265123b Avoid using regex matching for static patterns
Prior to this commit (and the previous one), the `AntPathStringMatcher`
(inner class of `AntPathmatcher`) would compile `Pattern` instances and
use regex matching even for static patterns such as `"/home"`.

This change introduces a shortcut in the string matcher algorithm to
skip the `Pattern` creation and uses `String` equality instead.
Static patterns are quite common in applications and this change can
bring performance improvements, depending on the mix of patterns
configured in the web application.

In benchmarks (added with this commit), we're seeing +20% throughput
and -40% allocation. This of course can vary depending on the number of
static patterns configured in the application.

Closes gh-24887
2020-05-15 17:07:58 +02:00
Sam Brannen fe3b36af68 Polishing 2020-05-14 13:18:49 +02:00
Juergen Hoeller 3c1ee64b7f Explicit nullability declarations for all AOP Alliance methods
Includes consistent declarations in AOP Alliance related Spring AOP code.

Closes gh-24117
2020-05-13 23:33:47 +02:00
Brian Clozel 60fac67884 Polish 2020-05-13 21:59:16 +02:00
Brian Clozel 612a63c0f1 Optimize MediaType parsing
Prior to this commit, `MediaType.parseMediaType` would already rely on
the internal LRU cache in `MimeTypeUtils` for better performance. With
that optimization, the parsing of raw media types is skipped for cached
elements.
But still, `MediaType.parseMediaType` would first get a cached
`MimeType` instance from that cache and then instantiate a
`new MediaType(type, subtype, parameters)`. This constructor not only
replays the `MimeType` checks on type/subtyme tokens and parameters, but
it also performs `MediaType`-specific checks on parameters.
Such checks are not required, as we're using an existing `MimeType`
instance in the first place.

This commit adds a new protected copy constructor (skipping checks) in
`MimeType` and uses it in `MediaType.parseMediaType` as a result.

This yields interesting performance improvements, with +400% throughput
and -40% allocation/call in benchmarks. This commit also introduces a
new JMH benchmark for future optimization work.

Closes gh-24769
2020-05-13 21:36:06 +02:00
Juergen Hoeller 5de6ae6fca Ignore resolved bean from non-active scope in getIfAvailable/getIfUnique
Closes gh-24822
2020-05-13 19:25:20 +02:00
Rossen Stoyanchev e88eb0ecf7 Option for advanced ObjectMapper customization
Closes gh-23017
2020-05-13 12:31:19 +01:00
Rossen Stoyanchev e881d4b144 Allow use of JsonInclude.Value
Closes gh-24824
2020-05-13 12:31:19 +01:00
Rossen Stoyanchev b31f2bdad2 @ExceptionHandler resolves nested exceptions
See gh-23380
2020-05-13 12:31:19 +01:00
Sam Brannen 3809d885b6 Fix Checkstyle violation 2020-05-12 18:49:41 +02:00
Сергей Цыпанов 6305a69cc1
Avoid StringBuilder.append(Object) in ContentDisposition
This commit avoids invoking StringBuilder.append(Object) in favor
of explicit method calls to append(String) and append(char) in
ContentDisposition.escapeQuotationsInFilename(String).

Closes gh-25056
2020-05-12 18:36:31 +02:00
Brian Clozel e4cb25f365 Reject "/path/**/other" patterns in PathPatternParser
Prior to this commit, patterns like `"/path/**/other"` would be treated
as `"/path/*/other"` (single wildcard, i.e. matching zero to many chars
within a path segment). This will not match multiple segments, as
expected by `AntPathMatcher` users or by `PathPatternParser` users when
in patterns like `"/resource/**"`.

This commit now rejects patterns like `"/path/**/other"` as invalid.
This behavior was previously warned against since gh-24958.

Closes gh-24952
2020-05-11 19:08:21 +02:00
Rossen Stoyanchev 94824e30a4 Avoid parse cookies when mutating request or response
When mutating a ServerHttpRequest or ClientResponse, the respective
builders no longer access cookies automatically which causes them to
be parsed and does so only if necessary. Likewise re-applying the
read-only HttpHeaders wrapper is avoided.

See gh-24680
2020-05-11 08:49:28 +01:00
Rossen Stoyanchev c908ec1937 Wrappers for native headers on the client side
Native server request headers have been wrapped rather than copied
since 5.1. This commit applies the same change to the client side
where, to make matters worse, headers were copied repeatedly on every
access, see also previous commit ca897b95.

For Netty and Jetty the wrappers are the same as on the server side
but duplicated in order to remain package private.

See gh-24680
2020-05-11 08:49:28 +01:00
Rossen Stoyanchev df99889aa6 Avoided repeated creation of ReadOnlyHttpHeaders wrapper
See gh-24680
2020-05-11 08:49:28 +01:00
Rossen Stoyanchev 3276f81851 Avoid one layer of HttpHeaders wrapping
See gh-24680
2020-05-11 08:49:28 +01:00
Rossen Stoyanchev 7f59381c7d Add support for RxJava 3
Closes gh-24170
2020-05-11 08:48:48 +01:00
Rossen Stoyanchev 8a59a63ade Merge branch '5.2.x' 2020-05-08 09:38:50 +01:00
Rossen Stoyanchev 19ba9087f5 HttpHeaders#equals handles wrapping correctly
Closes gh-25034
2020-05-08 09:37:37 +01:00
Rossen Stoyanchev 1da903dd59 Add PartHttpMessageWriter
Closes gh-24535
2020-05-08 07:54:50 +01:00
Sam Brannen 12e05280ad Upgrade to AssertJ 3.16 2020-05-06 15:22:23 +02:00
Rossen Stoyanchev f28e08eceb Improving contribution
See gh-24406
2020-05-06 10:50:51 +01:00
Parviz ROzikov 816466e492 #24406 - Add String based URI template variants 2020-05-06 10:50:51 +01:00
Rossen Stoyanchev d1708460e7 Log message for unused @ModelAttribute name
Closes gh-23877
2020-05-06 10:37:44 +01:00
Rossen Stoyanchev 66bb145247 Fix typo
See gh-23915, gh-25018
2020-05-06 06:35:43 +01:00
Rossen Stoyanchev a7c736915a Polishing and completing contribution
See gh-24866
2020-05-05 18:20:45 +01:00
Rossen Stoyanchev 147b8fb755 Turn off use of path extensions by default
Closes gh-23915
2020-05-05 08:04:40 +01:00
Rossen Stoyanchev 153690e717 Merge branch '5.2.x' 2020-05-04 10:55:25 +01:00
Rossen Stoyanchev aa97563853 Add UnknownContentTypeException
Closes gh-24964
2020-05-01 17:32:19 +01:00
Rossen Stoyanchev c35b3e5c82 Fix race condition in WriteResultPublisher
Closes gh-24989
2020-05-01 17:06:18 +01:00
Arjen Poutsma 7bd524e9d7 Add ClientHttpConnector test suite
This commit introduces a test suite for ClientHttpConnector
implementations, as well as fixes that resolve issues identified by
these tests.

Closes gh-24941
2020-04-29 15:21:22 +02:00
martin-tarjanyi 3bc1d42dcd Integrate Apache http client with WebClient
This commit introduces a ClientHttpConnector implementation backed by
Apache HttpComponents HttpClient 5.0.

Fixes gh-24700
2020-04-29 15:02:09 +02:00
Rossen Stoyanchev 583435d068 Consistent ordering in MethodNotAllowedException
This caused random failures in a newly added test. Also remove defensive
check in ResponseStatusExceptionResolver.

See gh-24944
2020-04-25 07:33:30 +01:00
Rossen Stoyanchev 18474c921d Document IAE in HttpHeaders methods that parse ETags
See gh-24950
2020-04-24 13:02:12 +01:00
Brian Clozel dc4cda1b13 WARN against invalid patterns with PathPatternParser
As of gh-24952, `PathPatternParser` will strictly reject patterns with
`"**"` in the middle of them. `"**"` is only allowed at the end of the
pattern for matching multiple path segments until the end of the path.

Currently, if `"**"` is used in the middle of a pattern it will be
considered as a single `"*"` instead. Rejecting such cases should
clarify the situation.

This commit prepares for that upcoming change and:

* logs a warning message if such a case is used by an application
* expands the MVC and WebFlux documentation about URI matching in
general

Closes gh-24958
2020-04-23 13:03:05 +02:00
Rossen Stoyanchev 8d31dcaa29 Clarification on path extension deprecations
Closes gh-24642
2020-04-20 14:43:07 +01:00
Deycoesr 87f28ce48e
Simplify some control flow code
Closes gh-24925
2020-04-17 18:32:02 +02:00
Sam Brannen b8835c9f32 Copy MockHttpServletRequest changes to spring-web
See gh-24916
2020-04-17 16:20:42 +02:00
Oliver Degener df291a39b1
Fix Javadoc link in DefaultCorsProcessor
Closes gh-24921
2020-04-17 09:26:53 +02:00
Sébastien Deleuze 67955dfb35 Prevent duplicated Vary headers in CORS processing
Closes gh-24829
2020-04-15 11:23:59 +02:00
Juergen Hoeller de0d06fab5 Polishing 2020-04-09 11:49:35 +02:00
Lars Grefer 8682a5d89a Honor overriden AccepptHeaderLocaleContextResolver.getDefaultLocale() 2020-04-09 11:37:50 +02:00
Sam Brannen 9f0ce09cf0 Update copyright date 2020-04-02 16:33:50 +02:00
Sam Brannen c9e13d448a
Revert change to PathPattern Javadoc 2020-04-02 16:28:26 +02:00
Gurps Bassi 4aca91c3b0 corrected javadoc 2020-04-01 22:05:53 +01:00
Rossen Stoyanchev 7d0f48289b Improve error handling in WebAsyncManager
See gh-24835
2020-04-01 18:35:22 +01:00
陈其苗 13970ae528 Use autoboxing instead of explicit wrapping in tests
Closes gh-24801
2020-04-01 14:34:20 +02:00
Sam Brannen d8567749b8 Fix Javadoc 2020-03-31 19:14:56 +02:00
Sam Brannen 89d282125a Ensure logPrefix is not null or blank in AbstractListenerWriteProcessor 2020-03-31 18:49:05 +02:00
Sam Brannen e87ab6f4ee Update Javadoc for AbstractListenerWriteProcessor.write()
Co-authored-by: Rossen Stoyanchev <rstoyanchev@pivotal.io>
2020-03-31 18:47:06 +02:00
Sam Brannen ddaf0029ae Polishing 2020-03-31 16:31:34 +02:00
Sam Brannen 329f08ad08 Suppress warnings in Gradle build 2020-03-31 12:17:58 +02:00
Sam Brannen e26764d249 Remove duplicate words in documentation and polish Javadoc 2020-03-31 12:17:58 +02:00
Sam Brannen 9e30620ac2 Polish contribution
See gh-24805
2020-03-30 13:47:00 +02:00
Сергей Цыпанов e63d1cf12d Improve usage of ByteArrayOutputStream/ByteArrayInputStream
Closes gh-24805
2020-03-30 13:22:21 +02:00
Qimiao Chen f8ff4e42b9
Use try-with-resource to close resources
Closes gh-24807
2020-03-30 12:05:29 +02:00
Qimiao Chen 7c831d2ef4
Replace anonymous inner classes with lambdas in tests
Closes gh-24808
2020-03-30 12:02:23 +02:00
Rossen Stoyanchev 3175f0771e Remove dumpString from DataBufferTestUtils
See gh-24786
2020-03-26 21:42:12 +00:00
Rossen Stoyanchev 7aa06b8610 Polishing contribution
See gh-24786
2020-03-26 21:42:12 +00:00
Сергей Цыпанов f17b0125ff Simplify conversion of DataBuffer to String
See gh-24786
2020-03-26 21:42:12 +00:00
Rossen Stoyanchev dd3dd5d67d UriComponentsBuilder.cloneBuilder copies uriVariables
Closes gh-24772
2020-03-26 16:31:25 +00:00
Johnny Lim 0f50a9a60a Fix empty domain handling in ResponseCookie
This commit also updates its test to use its intended inputs.
2020-03-25 08:18:03 +00:00
Juergen Hoeller 1800b10717 Expose parameter annotations from interfaces across entire class hierarchy
Closes gh-24127
2020-03-23 17:57:44 +01:00
Juergen Hoeller 7ebd850b85 Mark MediaTypeNotSupportedStatusException as deprecated
Closes gh-24743
2020-03-23 17:56:28 +01:00
Rossen Stoyanchev e11373fe69 Unwrap XMLStreamException from cause
Closes: gh-24622
2020-03-23 12:22:43 +00:00
Rossen Stoyanchev a7fe6b8f5c Avoid NPE in ResponseCookie on null domain
See gh-24663
2020-03-19 12:18:29 +00:00
Rossen Stoyanchev b121c0e2ea Avoid ClassCastException in TomcatHttpHandlerAdapter
Closes gh-24707
2020-03-19 12:17:24 +00:00
Sam Brannen 17140c8d4b Polish contribution
See gh-24595
2020-03-17 17:15:12 +01:00
Andrew Woodbury 2fb13d410d Include response body in UnknownHttpStatusCodeException
Spring Framework 5.2.2 introduced a regression in
DefaultResponseErrorHandler.handleError(ClientHttpResponse)
Specifically, for use cases where the InputStream had already been
consumed by the first invocation of getResponseBody(), the second
invocation of getResponseBody() resulted in the response body being
absent in the created UnknownHttpStatusCodeException.

This commit fixes this by invoking getResponseBody() only once in
DefaultResponseErrorHandler.handleError(ClientHttpReponse) in order to
reuse the retrieved response body for creating the exception message
and as a separate argument to the UnknownHttpStatusCodeException
constructor.

Closes gh-24595
2020-03-17 17:06:57 +01:00
Sam Brannen a8feb792da Fix broken Javadoc links 2020-03-16 16:30:27 +01:00
Rossen Stoyanchev a599859595 ServerCookie ignores empty domain with double quotes
Closes gh-24663
2020-03-12 12:21:19 +00:00
Juergen Hoeller 6df80a8f70 Restore original JsonMappingException handling (assuming invalid input)
Closes gh-24610
Closes gh-24630
Closes gh-24646
2020-03-11 14:51:36 +01:00
Rossen Stoyanchev a98bf30ee6 ShallowEtagHeaderFilter checks for pre-existing eTag
The filter now checks for an explicitly set eTag and uses it instead of
generating one, and also suppresses caching.

Closes gh-24635
2020-03-04 19:17:56 +00:00
Rossen Stoyanchev d3da7a50ec Polishing and minor refactoring
See gh-24635
2020-03-04 19:17:56 +00:00
Rossen Stoyanchev 2afae430eb Update list of support multipart media types
See gh-24582
2020-03-03 15:38:00 +00:00
Johnny Lim 8285666ee8
Polish ReactorResourceFactory
Closes gh-24620
2020-03-02 13:48:19 +01:00
Adrian Cole 7f5395a216
Fix typos in AbstractClientHttpRequest
Closes gh-24623
2020-03-02 13:36:47 +01:00
ZhangT c5fb7b9fb7
Simplify some redundant code
Closes gh-24586

Co-authored-by: Sam Brannen <sbrannen@pivotal.io>
2020-02-26 12:29:09 +01:00
Juergen Hoeller d72c90cd7a Assign TokenBuffer field with createToken() result 2020-02-25 15:21:28 +01:00
Rossen Stoyanchev b6f502db4e Polishing 2020-02-25 10:07:29 +00:00
Brian Clozel f1680e5cee Configure quiet period for shutting down Reactor resources
This commit adds two new properties to the `ReactorResourceFactory`.
This allows to configure the quiet and timeout periods when shutting
down Reactor resources. While we'll retain Reactor Netty's default for
production use, this option is useful for tests and developement
environments when developers want to avoid long waiting times when
shutting down resources.

Fixes gh-24538
2020-02-24 18:15:59 +01:00
Rossen Stoyanchev de608a08ed Polishing contribution
See gh-24518
2020-02-20 15:56:13 +00:00
Robert Gründler ae9268004d Added debug logging to DefaultWebSessionManager
See gh-24518
2020-02-20 15:55:59 +00:00
Arjen Poutsma 4882eb278d Convert non-UTF-8 JSON
Jackson's asynchronous parser does not support any encoding except UTF-8
(or ASCII). This commit converts non-UTF-8/ASCII encoded JSON to UTF-8.

Closes gh-24489
2020-02-20 11:14:53 +01:00
Sam Brannen e029dbf607 Polish Javadoc for ClientHttpResponse 2020-02-19 11:46:03 +01:00
Hyunjin Choi 37ba57a921
Polish some test classes by using predefined constants
Closes gh-24532
2020-02-18 12:24:10 +01:00
Juergen Hoeller a4179b4795 Polishing 2020-02-12 18:32:32 +01:00
Juergen Hoeller 9f6572a095 Add missing final declaration for static field 2020-02-12 16:49:19 +01:00
Juergen Hoeller b889700548 Differentiate MismatchedInputException versus ValueInstantiationException
Closes gh-24455
2020-02-12 16:48:32 +01:00
Rossen Stoyanchev 9277b47040 Polishing: remove use of cast where avoidable 2020-02-11 16:51:35 +00:00
Rossen Stoyanchev e35d3b8bb5 Update advice on RestTemplate
Closes gh-24503
2020-02-11 14:02:50 +00:00
Rossen Stoyanchev 28a95e89f3 Upgrade to Dysprosium SR5 snapshots
See gh-24355
2020-02-11 12:52:04 +00:00
Rossen Stoyanchev df706f4c7c Restore use of Flux-based encode method in HTTP
Closes gh-24441
2020-02-07 21:44:44 +00:00
Arjen Poutsma a03a116f6b Force TokenBuffer to use BigDecimal if elementtype
This commit makes the Jackson2Tokenizer enable
TokenBuffer.forceUseOfBigDecimal if the element type given to the
Decoder is BigDecimal. Previous to this commit, values would be
converted to floats.

Closes gh-24479
2020-02-07 14:16:21 +01:00
Arjen Poutsma 45555f77a6 Honour ObjectMapper feature in Jackson2Tokenizer
After this commit, Jackson2Tokenizer honours ObjectMapper's
DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS feature when creating
TokenBuffers.

Closes gh-24479
2020-02-07 10:45:00 +01:00
Rossen Stoyanchev ba5fc21ab4 Option to pair AnnotationIntrospector instances
Closes gh-22830
2020-02-05 20:49:07 +00:00
Rossen Stoyanchev f5df422de9 Polishing contribution
See gh-24470
2020-02-03 20:32:36 +00:00
Hyunjin Choi 273812f9c5 Remove unnecessary escapes in regular expressions
See gh-24470
2020-02-03 20:22:40 +00:00
Rossen Stoyanchev 547342b27d Status code as Integer methods in ServerHttpResponse
Closes gh-24400
2020-01-30 10:06:58 +00:00
Rossen Stoyanchev cc4261c30b Only non-null input resets scheme specific part
Closes gh-24444
2020-01-30 06:16:43 +00:00
Rossen Stoyanchev 2fcee5ae58 Append unique number to WebFlux server log prefix
Closes gh-22039
2020-01-24 15:57:56 +00:00
Rossen Stoyanchev d499e14b78 Update default value in ReactorResourceFactory
We used ConnectionProvider#elastic only to customize the name. Now that
Reactor Netty's TcpResources itself uses fixed 500 by default, we
update to have the same value which would apply when global resources
are not used.

Closes gh-24424
2020-01-24 15:40:16 +00:00
Rossen Stoyanchev b142f8e660 Remove no-op code in URI encoding
Closes gh-24413
2020-01-24 15:37:01 +00:00
Johnny Lim 5a0b768a3d Fix typo in Javadoc 2020-01-23 15:52:46 +00:00
Rossen Stoyanchev 992e75303d Improve support for generics in Jackson codecs
Closes gh-23791
2020-01-23 12:31:00 +00:00
Rossen Stoyanchev c69703ffdb Deprecate path extension strategies
This commit deprecates PathExtensionContentNegotiationStrategy and
ServletPathExtensionContentNegotiationStrategy and also updates code
that depends on them internally to remove that dependence.

See gh-24179
2020-01-22 13:35:09 +00:00
Rossen Stoyanchev 542e187831 Expose media type mappings in ContentNegotiationManager
ContentNegotiationManagerFactoryBean now ensures that
ContentNegotiationManager contains the MediaType mappings even if the
path extension and the parameter strategies are off.

There are also minor fixes to ensure the media type mappings in
ContentNegotiationManagerFactoryBean aren't polluted when mapping keys
are not lowercase, and likewise MappingMediaTypeFileExtensionResolver
filters out duplicates in the list of all file extensions.

See gh-24179
2020-01-22 13:35:09 +00:00
Rossen Stoyanchev 214ba63127 Deprecate config options for content negotiation by path extension
See gh-24179
2020-01-22 13:35:09 +00:00
Arjen Poutsma 54669c51c9 Use Jackson SequenceWriter for streaming
Before this commit, the AbstractJackson2Encoder instantiated a
ObjectWriter per value. This is not an issue for single values or
non-streaming scenarios (which effectively are the same, because in the
latter values are collected into a list until offered to Jackson).
However, this does create a problem for SMILE, because it allows for
shared references that do not match up when writing each value with a
new ObjectWriter, resulting in errors parsing the result.

This commit uses Jackson's SequenceWriter for streaming scenarios,
allowing Jackson to reuse the same context for writing multiple values,
fixing the issue described above.

Closes gh-24198
2020-01-21 14:22:00 +01:00
Rossen Stoyanchev 5e9d29d813 Ability to customize default Smile codecs
Closes gh-24382
2020-01-20 17:29:59 +00:00
Rossen Stoyanchev 5d8c5b0d9b Avoid NPE on comment SSE event
Closes gh-24389
2020-01-20 11:26:58 +00:00
Brian Clozel 59bef22235 Avoid setting special Content-* response headers for Tomcat
As of gh-21783, Spring WebFlux uses a `TomcatHeadersAdapter`
implementation to directly address the native headers used by the
server.

In the case of Tomcat, "Content-Length" and "Content-Type" headers are
processed separately and should not be added to the native headers map.

This commit improves the `HandlerAdapter` implementation for Tomcat and
removes those headers, if previously set in the map. The adapter
already has a section that handles the Tomcat-specific calls for such
headers.

Fixes gh-24361
2020-01-17 15:01:58 +01:00
Rossen Stoyanchev ac8eaca475 HttpWebHandlerAdapter#formatRequest is protected
Closes gh-24352
2020-01-16 14:54:29 +00:00
Sam Brannen 1c270d8d06 Fix Checkstyle violation 2020-01-13 18:21:36 +01:00
Rossen Stoyanchev 29fe65d23c Upgrade to Dysprosium snapshots
See gh-24349
2020-01-13 16:49:42 +00:00
Rossen Stoyanchev cbc57460b7 Support for maxInMemorySize in SSE reader
Closes gh-24312
2020-01-13 14:57:14 +00:00
Sébastien Deleuze bc7d010485 Update CORS support
This commit updates CORS support in order to check Origin header
in CorsUtils#isPreFlightRequest which does not change how Spring
MVC or WebFlux process CORS request but is more correct in term
of behavior since it is a public API potentially used in another
contexts.

It also removes an unnecessary check in
AbstractHandlerMethodMapping#hasCorsConfigurationSource and processes
every preflight request with PreFlightHandler.

Closes gh-24327
2020-01-13 08:33:14 +01:00
Juergen Hoeller 4936a637fe Polishing 2020-01-09 17:03:17 +01:00
Rossen Stoyanchev 08e9372ded Restore response after beforeCommit action errors
See gh-24186
2020-01-09 11:10:44 +00:00
Rossen Stoyanchev 01827389ef Polishing contribution
See gh-24292
2020-01-08 16:19:25 +00:00
Oleh Faizulin e96b71acf3 contentLength support for Resource decoding
Expose the known content length, if known, in the InputStreamResource returned by ResourceHttpMessageConverter or
ResourceDecoder.

See gh-24292
2020-01-08 16:19:11 +00:00
Rossen Stoyanchev 9d963abb7d Concrete MediaType check in StringHttpMessageConverter
Closes gh-23287
2020-01-07 15:02:39 +00:00
Brian Clozel ffc1f960f9 Polish
See gh-24238
2020-01-07 09:05:49 +01:00
Rossen Stoyanchev ea6d2ea1ce Multi-value headers in ResponseStatusException
Closes gh-24261
2020-01-06 22:13:55 +00:00
Brian Clozel f9c1565f4e Remove Content-* response headers for error handling
Prior to this commit, when WebFlux handlers added `"Content-*"` response
headers and an error happened while handling the request, all those
headers would not be cleared from the response before error handling.

This commit clears those headers from the response in two places:
* when invoking the handler and adapting the response
* when writing the response body

Not removing those headers might break HTTP clients since they're given
wrong information about how to interpret the HTTP response body: the
error response body might be very different from the original one.

Fixes gh-24238
2020-01-06 16:55:08 +01:00
Rossen Stoyanchev 03ea92df99 Improve RestClientException Javadoc
Closes gh-24288
2020-01-03 11:12:01 +00:00
Sam Brannen 7b6d83a106 Use Gradle test fixture support for spring-web
See gh-23550
2020-01-02 16:01:35 +01:00
Sam Brannen 726b1bb1d0 Rename test fixture package in spring-context
See gh-23550
2020-01-02 16:01:35 +01:00
Sam Brannen 7cd4ddf5fc Rename test fixture package in spring-beans
See gh-23550
2020-01-02 16:01:35 +01:00
Sam Brannen 4260c34b47 Rename test fixture package in spring-core
See gh-23550
2020-01-02 16:01:34 +01:00
Sam Brannen 61d4ee594d Use Gradle test fixture support for spring-beans and spring-context
See gh-23550
2020-01-02 16:01:34 +01:00
Sam Brannen 5718bf424b Use Gradle test fixture support for spring-core
See gh-23550
2020-01-02 16:01:34 +01:00
Rossen Stoyanchev 956ffe6858 ContentDisposition refactoring
See gh-24220
2019-12-26 17:30:15 +00:00
Rossen Stoyanchev 261956fd08 Improve UriBuilder Javadoc on query params
Add a note on encoding for query parameters specifically mentioning the
"+" sign and a link to the reference docs.

Also remove duplicate Javadoc in UriComponentsBuilder which is already
inherited from UriBuilder.
2019-12-20 11:03:08 +00:00
Rossen Stoyanchev ea4f1ca5d5 Update ContentDisposition to RFC 6266
Close gh-24231
2019-12-19 16:27:40 +00:00
Rossen Stoyanchev 15321a3163 Fix checkstyle violations 2019-12-19 13:06:53 +00:00
Rossen Stoyanchev 41f40c6c22 Escape quotes in filename
Closes gh-24220
2019-12-19 12:23:12 +00:00
Rossen Stoyanchev 0eacb443b0 Reuse InputStream in ResourceRegionHttpMessageConverter
The converter now tries to keep reading from the same InputStream which
should be possible with ordered and non-overlapping regions. When
necessary the InputStream is re-opened.

Closes gh-24214
2019-12-18 16:22:53 +00:00
Rossen Stoyanchev 1dd0a0f009 Fix since tags from prior commit 2019-12-12 22:03:38 +00:00
Rossen Stoyanchev b23617637d Fix cloning issue in CodecConfigurer for multipart writers
Closes gh-24194
2019-12-12 21:58:14 +00:00
Rossen Stoyanchev 11e321b8e7 Add register methods to CodecConfigurer.CustomCodecs
The new register methods replace the now deprecated
encoder, decoder, reader, and writer methods, and also offer a choice
to opt into default properties such maxInMemorySize, if configured.

See gh-24124
2019-12-12 21:58:14 +00:00
Rossen Stoyanchev 9d65830133 CodecConfigurer implementation refactoring
See gh-24124
2019-12-12 21:57:45 +00:00
Rossen Stoyanchev 9b30d46ff4 JSON charset handling in StringHttpMessageConverter
This commit restores the interpretation of JSON as UTF-8 by default that
was removed in #bc205e0 and also ensures a charset is not appended
automatically to "application/json".

Closes gh-24123
2019-12-10 16:52:23 +00:00
Rossen Stoyanchev c8bce9686f ContentDisposition trims charset in filename
Closes gh-24112
2019-12-10 15:38:28 +00:00
Rossen Stoyanchev f180bf7652 Add "application/*+xml" to XML decoders
Closes gh-24164
2019-12-10 15:18:04 +00:00
Rossen Stoyanchev 1b172c1d20 Expose localAddress in WebFlux server
Closes gh-24174
2019-12-10 15:10:13 +00:00
Johnny Lim 1e83e889aa Use hasSize() where possible
See gh-24172
2019-12-10 07:58:53 +01:00
Juergen Hoeller 119dd04ae5 Avoid ByteArrayOutputStream for source values without the need to be encoded
Closes gh-24152
2019-12-09 13:28:39 +01:00
Sam Brannen fc42ca2866 Polish contribution
See gh-24157
2019-12-07 13:41:43 +01:00
yokotaso d7d474f658 Do not cache prototype @ControllerAdvice beans
Spring Framework 5.2 introduced support for caching @ControllerAdvice
beans; however, this caching was also applied incorrectly to
non-singleton beans.

This commit addresses this regression by only caching singleton
@ControllerAdvice beans.

Closes gh-24157
2019-12-07 13:39:30 +01:00
stsypanov 484006ce90 Hoist Class.getName() from String concatenation to dodge an issue related to profile pollution 2019-12-06 17:36:07 +01:00
Rossen Stoyanchev b866d4209c Add UriUtils.encodeQueryParams
Closes gh-24043
2019-12-04 17:33:31 +00:00
Brian Clozel 21053780ef Polish 2019-12-02 23:13:44 +01:00
Brian Clozel decbb9ccf9 Provide default codecs config callback to custom codecs
As a follow-up of gh-23961, this change provides a way for custom codecs
to align with the default codecs' behavior on common features like
buffer size limits and logging request details.

Closes gh-24118
Co-authored-by: Rossen Stoyanchev <rstoyanchev@pivotal.io>
2019-12-02 22:52:55 +01:00
Rossen Stoyanchev acfeb77d41 Polishing
See gh-23961
2019-12-02 14:12:59 +00:00
Brian Clozel d4209392d2 Allow ExchangeStrategies customizations in WebClient
Prior to this commit, developers could configure their WebClient to use
their custom `ExchangeStrategies`, by providing it in the
`WebClient.Builder` chain.
Once created, an `ExchangeStrategies` instance is not mutable, which
makes it hard for further customizations by other components. In the
case of the reported issue, other components would override the default
configuration for the codecs maxInMemorySize.

This commit makes the `ExchangeStrategies` mutable and uses that fact to
further customize them with a new `WebClient.Builder#exchangeStrategies`
`Consumer` variant. This commit is also deprecating those mutating
variants in favor of a new `WebClient.Builder#exchangeStrategies` that
takes a `ExchangeStrategies#Builder` directly and avoids mutation issues
altogether.

Closes gh-23961
2019-12-02 14:12:59 +00:00
Brian Clozel 1560bbd81e Revert "Allow ExchangeStrategies customizations in WebClient"
This reverts commit b3020bc484.
2019-12-02 10:39:53 +01:00
Juergen Hoeller 567c7695dd Polishing 2019-12-01 00:20:00 +01:00
Brian Clozel b3020bc484 Allow ExchangeStrategies customizations in WebClient
Prior to this commit, developers could configure their WebClient to use
their custom `ExchangeStrategies`, by providing it in the
`WebClient.Builder` chain.
Once created, an `ExchangeStrategies` instance is not mutable, which
makes it hard for further customizations by other components. In the
case of the reported issue, other components would override the default
configuration for the codecs maxInMemorySize.

This commit makes the `ExchangeStrategies` mutable and uses that fact to
further customize them with a new `WebClient.Builder#exchangeStrategies`
`Consumer` variant. This commit is also deprecating those mutating
variants in favor of a new `WebClient.Builder#exchangeStrategies` that
takes a `ExchangeStrategies#Builder` directly and avoids mutation issues
altogether.

Closes gh-23961
2019-11-29 22:26:52 +01:00
Rossen Stoyanchev 395c1e415c Polishing contribution
See gh-24074
2019-11-29 15:54:58 +00:00
Rossen Stoyanchev 25f3465f1f Polishing contribution
See gh-24087
2019-11-29 15:53:37 +00:00
Rossen Stoyanchev b44daa8b71 Remove the few remaining usages of UriTemplate
Also update Javadoc of UriTemplate to point to UriComponentsBuilder and
UriBuilderFactory as more flexible options.

See gh-24094
2019-11-28 11:28:49 +00:00
Rossen Stoyanchev df2ed75df0 MultipartBodyBuilder Javadoc update
Closes gh-24031
2019-11-28 10:40:28 +00:00
Johnny Lim 4aa013c508 Remove duplicate checks in ResponseCookieTests 2019-11-28 07:15:15 +00:00
Rossen Stoyanchev 70a3dbff24 WebSession creation does not block
Closes gh-24027
2019-11-26 10:48:39 +00:00
Arjen Poutsma ddb38eefee Expose method to determine form content type
This commit exposes the method that returns the media type used to write
forms. By default, it includes the charset in the content type, which
can cause issues with certain consumers. This commit changes the method
from a private to a protected method, so that users can override the
default behavior.

Closes: gh-22971
2019-11-26 10:50:08 +01:00
Arjen Poutsma 2d86f221ce Remove println 2019-11-25 18:27:34 +01:00
Arjen Poutsma 5f3c7ca559 Fix NullPointerException in Jackson2SmileDecoder
Fix uncommon case in Jackson2SmileDecoder, where a null token,
incicating a document separator in streaming mode, is followed by
NOT_AVAILABLE.

Closes gh-24009
2019-11-25 16:23:27 +01:00
Christoph Dreis b234c77b67 Add missing verify() in EncoderHttpMessageWriterTests
Closes gh-24062
2019-11-25 10:51:00 +00:00
Rossen Stoyanchev 7bed4f36da Add missing verify() in Jackson2TokenizerTests
Closes gh-24056
2019-11-22 16:38:43 +00:00
Rossen Stoyanchev 51b35e64cf Extra isReady-onWritePossible after last write
Closes gh-24050
2019-11-22 15:57:21 +00:00
Rossen Stoyanchev 21b2fc1f01 Improve HttpHandlerConnection completion
Before this commit the connector waited for a completed response (via
ServerHttpResponse#setComplete or ServerHttpResponse#writeWith) or an
error signal in handling, but it didn't deal explicitly with the case
where both can occur.

This commit explicitly waits for the completion of handling (success
or error) before passing the response downstream. If an error occurs
after response completion, it is wrapped in a dedicated exception that
also provides access to the completed response.

Close gh-24051
2019-11-22 10:28:05 +00:00
stsypanov 1f3b595a03 Use String.isEmpty() instead of String.equals("") 2019-11-21 16:42:01 +01:00
Rossen Stoyanchev f4e0288357 Remove mentions of Tomcat async request timeout value
Close gh-24030
2019-11-19 17:08:43 +00:00
Sam Brannen b4e1d48322 Ignore scoped proxy targets for @ControllerAdvice beans
Prior to this commit, methods in a @ControllerAdvice bean were
registered and invoked twice if the advice was a scoped bean (e.g.,
request or session scoped). In other words, both the proxy bean and the
target bean were wrapped in ControllerAdviceBean instances.

This commit fixes this bug by modifying the findAnnotatedBeans() method
in ControllerAdviceBean so that it filters out targets of scoped
proxies.

Closes gh-24017
2019-11-19 14:20:25 +01:00
Sam Brannen 3a39b7fe82 Support scoped @ControllerAdvice beans again
Spring Framework 5.2 introduced support for implementing the Ordered
interface in a @ControllerAdvice bean. This support requires that
@ControllerAdvice beans be eagerly resolved from the BeanFactory in
order to invoke the getOrder() method defined in the Ordered interface.
Unfortunately doing so resulted in a regression in that an attempt to
eagerly resolve a scoped @ControllerAdvice bean throws a
BeanCreationException due to the lack of an active scope (e.g., request
or session scope).

This commit fixes this regression by avoiding eager resolution of scoped
@ControllerAdvice beans. As a direct consequence, the Ordered interface
is not supported for scoped @ControllerAdvice beans.

Closes gh-23985
2019-11-18 22:29:00 +01:00
Juergen Hoeller 1607f1db0b Fix Checkstyle nohttp violation 2019-11-15 10:50:28 +01:00
Rossen Stoyanchev c33cb26a73 Polishing contribution
See gh-1885
2019-11-14 17:38:01 +00:00
Mark Hobson 46fe74d2f9 Preserve media type parameters when setting charset
Issue: SPR-17040
2019-11-14 17:38:01 +00:00
Juergen Hoeller 22211a01ce Polishing 2019-11-13 17:23:23 +01:00
Rossen Stoyanchev 2c1afca9c5 Reject null form data names
...or skip if there are no values either.

Closes gh-22372
2019-11-13 15:03:22 +00:00
Rossen Stoyanchev 04aa3d05da Refactor solution for respones error details
See gh-1956
2019-11-13 14:24:12 +00:00
jerzykrlk 91ec274b10 SPR-17130 http error details in the exception message 2019-11-13 14:24:12 +00:00
Arjen Poutsma a7a88371e7 Allow for decode method to return null in AbstractJackson2Decoder
Prior to this commit, the decoder did not allow for a null value
returned from the Jackson object reader.

Closes: gh-23935
2019-11-11 16:48:30 +01:00
Juergen Hoeller 6d47e1e0a1 Fix getHeaderPredicate visibility to be declared as protected
Closes gh-23976
2019-11-11 15:55:06 +01:00
Rossen Stoyanchev ffe69a51e1 Javadoc update for content negotiation
Closes gh-23409
2019-11-11 12:04:28 +00:00
Tomo Suzuki 21d390a018 Replacing netty-all with specific dependencies 2019-11-08 13:00:37 +00:00
Rossen Stoyanchev 1261e64465 Minor refactoring
Apply default Accept header for HttpUrlConnection only.

See gh-23855
2019-11-08 08:44:04 +00:00
Lorenzo Torracchi afae8c3045 Avoid default "Accept" from HttpUrlConnection
Closes gh-23740
2019-11-08 08:43:25 +00:00
Arjen Poutsma 55f3f128c9 Polishing 2019-11-07 14:29:47 +01:00
Arjen Poutsma bf36f49dc5 Corrupt multipart should not hang SynchronossPartHttpMessageReader
This commit notifies the Synchronoss listener that the buffer stream
has ended.

Closes gh-23768
2019-11-07 09:10:07 +01:00
Rossen Stoyanchev 3a241b546f Relax domain name checks in ResponseCookie
Closes gh-23924
2019-11-06 17:54:39 +00:00
Sam Brannen 29599a93a4 Re-enable support for invalid Expires attributes in MockCookie
Changes introduced in commit 9b2087618b
caused a regression for Cookie support in MockHttpServletResponse.
Specifically, an Expires attribute that cannot be parsed using
`ZonedDateTime.parse()` now results in an exception; whereas,
previously an entry such as `Expires=0` was allowed.

This commit fixes this issue in MockCookie by catching and ignoring any
DateTimeException thrown while attempting to parse an Expires attribute.

Closes gh-23911
2019-11-06 18:28:28 +01:00
Sam Brannen 92228f0fc0 Test status quo for @RequestHeader UUID conversion support
See gh-23939
2019-11-06 13:49:44 +01:00
AlexeyAnufriev 2d208de145 Clear connection pool for OkHttpClient
Closes gh-23628
2019-11-01 11:44:16 +00:00
Rossen Stoyanchev fd9678833f Use int for maxParts instead of long 2019-10-31 14:13:44 +00:00
Brian Clozel 3b724c72b6 Polish
See gh-23884
2019-10-30 19:57:17 +01:00
Sam Brannen 9f00eb68e9 Clean up warnings 2019-10-30 19:14:58 +01:00
Sam Brannen cef4478b7b Treat InvalidPathException like an IOException in MockServletContext
Prior to this commit, if MockServletContext was configured with a
FileSystemResourceLoader, invocations of the following methods on a
Microsoft Windows operating system resulted in an InvalidPathException
if the supplied path contained a colon (such as "C:\\temp"). This is
inconsistent with the behavior on non-Windows operating systems. In
addition, for comparable errors resulting in an IOException, those
methods (except getRealPath()) return null instead of throwing the
exception.

- getResourcePaths()
- getResource()
- getResourceAsStream()
- getRealPath()

This commit makes handling of InvalidPathException and IOException
consistent for these methods: both exceptions now result in null be
returned by these methods.

Closes gh-23717
2019-10-30 15:59:44 +01:00
Juergen Hoeller 19ff7d84ab Polishing 2019-10-30 14:31:46 +01:00
Juergen Hoeller 19107649d2 Revise concurrent JAXBContext creation towards computeIfAbsent
Closes gh-23879
2019-10-30 14:31:34 +01:00
Rossen Stoyanchev 422c26832b Minor follow-up to previous commit
See gh-23741
2019-10-30 12:38:26 +00:00
Rossen Stoyanchev 34cfbe5d26 ResponseStatusException associated headers
A ResponseStatus exception now exposes extra method to return headers
for the response. This is used in ResponseStatusExceptionHandler to
apply the headers to the response.

Closes gh-23741
2019-10-30 12:10:45 +00:00
Juergen Hoeller 046380988b Nullability refinements 2019-10-30 00:26:11 +01:00
Rossen Stoyanchev 5abf24e7d7 Expose maxInMemorySize via CodecConfigurer
Centralized maxInMemorySize exposed via CodecConfigurer along with
ability to plug in an instance of MultipartHttpMessageWrite.

Closes gh-23884
2019-10-29 12:33:16 +00:00
Rossen Stoyanchev 00ead7a756 Refine multipart parsing limits
See gh-23884
2019-10-29 12:33:16 +00:00
Brian Clozel ea6f51e9e3 Configurable limits with Synchronoss
See gh-23884
2019-10-29 12:33:16 +00:00
Brian Clozel 69bcdfc17f Polishing 2019-10-29 12:33:16 +00:00
Rossen Stoyanchev 89d053d7f4 Limits on input stream in codecs
- Add maxInMemorySize property to Decoder and HttpMessageReader
  implementations that aggregate input to trigger
  DataBufferLimitException when reached.

- For codecs that call DataBufferUtils#join, there is now an overloaded
  variant with a maxInMemorySize extra argument. Internally, a custom
  LimitedDataBufferList is used to count and enforce the limit.

- Jackson2Tokenizer and XmlEventDecoder support those limits per
  streamed JSON object.

See gh-23884
2019-10-29 12:33:16 +00:00
Sam Brannen ce0b012f43 Polish contribution
See gh-23769
2019-10-29 13:27:39 +01:00
Vedran Pavic 9b2087618b Preserve expires attribute in MockCookie
At present, MockCookie doesn't preserve expires attribute. This has a
consequence that a cookie value set using
MockHttpServletResponse#addHeader containing an expires attribute will
not match the cookie value obtained from
MockHttpServletResponse#getHeader, since the expires attribute will get
calculated based on current time.

This commit enhances MockCookie to preserve the expires attribute.

Closes gh-23769
2019-10-29 12:56:24 +01:00
Rossen Stoyanchev 780eef8d36 Update comment in HttpWebHandlerAdapter
See gh-23780
2019-10-23 17:31:59 +01:00
Johnny Lim 33bf09d513 Polish HttpWebHandlerAdapter.handleUnresolvedError() 2019-10-23 16:57:20 +01:00
Rossen Stoyanchev 2733511ea2 Charset argument in RestClientResponseException
See gh-23764
2019-10-23 16:49:32 +01:00
Rossen Stoyanchev 4932196b87 RestClientResponseException defaults to UTF-8
Closes gh-23764
2019-10-23 16:26:57 +01:00
Sam Brannen 112bbe859c Fix grammar in Javadoc 2019-10-22 18:07:41 +02:00
Brian Clozel a65c6f6884 Fix APPLICATION_PROBLEM_JSON_UTF8 media type value
This commit adds the missing "+json" suffix to the "application/problem"
media type for its deprecated UTF-8 variant.

Fixes gh-23825
2019-10-17 09:36:05 +02:00
Sam Brannen 972337e8f9 Introduce common .gitattributes file
Closes gh-23376
2019-10-02 15:22:39 +02:00
Juergen Hoeller 2861fc65bd Polishing 2019-09-27 10:17:56 +02:00
Sam Brannen f05b4625de Merge branch '5.1.x' 2019-09-26 10:55:55 +02:00
Sam Brannen 7d126d3288 Improve documentation regarding "annotated classes"
See gh-23638
2019-09-26 10:26:36 +02:00
Juergen Hoeller 3616e96792 Upgrade to SLF4J 1.7.28, Groovy 2.5.8, RxJava 2.2.12, Joda-Time 2.10.4, Rome 1.12.2, OkHttp 3.14.3, Apache HttpClient 4.5.10, Apache Johnzon 1.1.13 2019-09-25 22:27:41 +02:00
Rossen Stoyanchev 2995b6f224 Merge branch '5.1.x' 2019-09-25 17:28:24 +01:00
Rossen Stoyanchev 17c423f5af Support for sameSite attribute in WebFlux
Bypass server cookie and write Set-Cookie header directly for Reactor
Netty, and Servlet API which do not provide options.

For Undertow use the sameSite attribute.

Closes gh-23693
2019-09-25 17:16:48 +01:00
Rossen Stoyanchev 30e1257dda Merge branch '5.1.x' 2019-09-24 13:39:42 +01:00
Sam Brannen 402046f3c7 Polish data buffer allocation tests 2019-09-24 14:24:36 +02:00
Rossen Stoyanchev 4edc7196fb Refine disconnected client handling in WebFlux
If an error looks like a "disconnected client" but the response is not
yet committed then it can't be an I/O error from writing to the server
response. It is most likely as a result of a remote call as part of
request handling.

Not setting the response to 500 in this case results in a 200 response
status despite the error. Even if it was an I/O error from the server
response, setting the status won't impact a failed response.

Closes gh-23319
2019-09-24 11:09:42 +01:00
Sam Brannen 2572cd0503 Make PathPatternParserTests compatible with JDK 13
Closes gh-23669
2019-09-21 17:33:28 +02:00
Brian Clozel 4cfcc108fe Merge branch '5.1.x' 2019-09-17 09:49:47 +02:00
Brian Clozel ca2b2f5533 Wait for complete disposal of Reactor Netty resources
Fixes gh-23631
2019-09-17 09:49:05 +02:00
Phillip Webb d945ae9191 Add blank line between java and javax imports
See gh-23539

Co-authored-by: Sam Brannen <sbrannen@pivotal.io>
2019-09-16 13:41:59 +02:00
Sam Brannen bd28bb1f56 Add additional tests for HttpHeaders.keySet() operations
See gh-22821
2019-09-16 12:36:05 +02:00
Phillip Webb aa69703f3b Fix LinkedCaseInsensitiveMap collection methods
Ensure that results returned from keySet, entrySet & values are tracked
to remove case insensitive keys from the source map.

Closes gh-22821
2019-09-16 12:36:05 +02:00
Sam Brannen a871f609ea Introduce failing tests for HttpHeaders
See gh-22821
2019-09-16 12:28:38 +02:00
Sam Brannen 52128fe863 Polish RequestLoggingFilterTests 2019-09-16 11:35:26 +02:00
Napster 33cee066e5 Log HTTP method in logging filters and revise log message format
Closes gh-23567
2019-09-16 11:35:26 +02:00
Sam Brannen cf5cb9484a Add additional tests for HttpHeaders.keySet() operations
See gh-22821
2019-09-15 15:48:37 +02:00
Sam Brannen 957f0fac7a Polishing 2019-09-13 12:55:59 +02:00
Phillip Webb 5d785390eb Add `ClientHttpRequestInitializer` support
Add `ClientHttpRequestInitializer` interface that can be used with any
`HttpAccessor` to initialize each `ClientHttpRequest` before it's used.

This provides a useful alternative to `ClientHttpRequestInterceptor`
when users need to configure things like `HttpHeaders`.

Closes gh-22002
2019-09-12 16:01:46 -07:00
Rossen Stoyanchev 7194261961 Merge branch '5.1.x' 2019-09-12 21:17:00 +01:00
Rossen Stoyanchev 23be5dfb0e Handle invalid MediaType in Jetty/Tomcat adapters
See: gh-23553
2019-09-12 20:58:47 +01:00
Rossen Stoyanchev b7eaab4c5d Handle very early completion notification
On a Servlet container a completion notification may come at any time
even in the UNSUBSCRIBED state, i.e. before the write Publisher has
called onSubscribe.

See: gh-23553
2019-09-12 14:14:11 +01:00
Rossen Stoyanchev 07b0fa132e doFilterNestedErrorDispatch delegates to filter chain
Closes: gh-23596
2019-09-12 13:42:12 +01:00
Sam Brannen 30cff46e7f Prevent improper use of testing framework APIs
Prior to this commit, a lot of work had been done to prevent improper
use of testing Framework APIs throughout the codebase; however, there
were still some loopholes.

This commit addresses these loopholes by introducing additional
Checkstyle rules (and modifying existing rules) to prevent improper use
of testing framework APIs in production code as well as in test code.

- Checkstyle rules for banned imports have been refactored into
  multiple rules specific to JUnit 3, JUnit 4, JUnit Jupiter, and
  TestNG.
- Accidental usage of org.junit.Assume has been switched to
  org.junit.jupiter.api.Assumptions.
- All test classes now reside under org.springframework packages.
- All test classes (including abstract test classes) now conform to the
  `*Tests` naming convention.
  - As an added bonus, tests in the renamed
    ScenariosForSpringSecurityExpressionTests are now included in the
    build.
- Dead JUnit 4 parameterized code has been removed from
  DefaultServerWebExchangeCheckNotModifiedTests.

Closes gh-22962
2019-09-12 11:20:56 +02:00
Sam Brannen 5d5f9aceca Avoid accidental usage of JUnit 4 assumptions
This commit also avoids starting a server if an assumption fails.
2019-09-06 16:03:36 +02:00
Sam Brannen 591995ecc8 Polish and revive disabled tests
This commit revives some previously disabled tests and converts
some usage of @Disabled to @EnabledForTestGroups(...).
2019-09-06 15:57:27 +02:00
Sam Brannen d9e3b8b9a5 Introduce default constructor in TomcatHttpServer 2019-09-05 13:45:38 +02:00
Sam Brannen 73f5d05fd9 Avoid deprecation warning in RandomHandlerIntegrationTests 2019-09-05 13:29:01 +02:00
Phillip Webb deba2ed1b3 Add blank line between java and javax imports
See gh-23539
2019-09-04 22:05:46 -07:00
Rossen Stoyanchev bc81fa520e Reject range starting above resource length
Closes: gh-23576
2019-09-04 18:05:59 +01:00
Brian Clozel 0c7359911a Re-enable StreamingSimpleClientHttpRequestFactoryTests
Since the okhttp3 3.14 downgrade, we don't need to ignore this test
anymore.
2019-09-04 16:02:43 +02:00
Brian Clozel cccd9c8bb0 Fix okhttp3 downgrade 2019-09-04 15:07:17 +02:00
Sam Brannen 00983a1141 Update @Disabled for StreamingSimpleClientHttpRequestFactoryTests.interceptor() 2019-09-04 14:37:37 +02:00
Sam Brannen 4d819128db Fix Javadoc 2019-09-04 14:33:02 +02:00
Sam Brannen 513ce7824f Disable StreamingSimpleClientHttpRequestFactoryTests.interceptor() test 2019-09-03 16:43:48 +02:00
Rossen Stoyanchev d927d31e13 Remove reflection from ContentDispositionTests
Also minor refactoring in decoding in order to tolerate the absence of
a charset and treat as US_ASCII.

See gh-23485
2019-09-03 12:31:13 +01:00
Rossen Stoyanchev c97580035e Polish ContentDispositionTests
Closes gh-23485
2019-09-03 12:31:13 +01:00
Jonathan Bluett-Duncan f084b63286 Fix "array index out of bounds" problem reported by LGTM.com 2019-09-03 12:31:13 +01:00
Sam Brannen 5fd81d2a26 Avoid deprecation warning in AbstractMockWebServerTests
MockResponse.setHeaders(Headers) is now deprecated.
2019-09-03 12:13:09 +02:00
Brian Clozel d4089747b8 Use dependency management in Framework build
Prior to this commit, the Spring Framework build would partially use the
dependency management plugin to import and enforce BOMs.

This commit applies the dependency management plugin to all Java
projects and regroups all version management declaration in the root
`build.gradle` file (versions and exclusions).

Some versions are overridden in specific modules for
backwards-compatibility reasons or extended support.

This commit also adds the Gradle versions plugin that checks for
dependency upgrades in artifact repositories and produces a report; you
can use the following:

    ./gradlew dependencyUpdates
2019-09-02 18:01:09 +02:00
Sebastien Deleuze ca02cc1194 Migrate to AssertJ in Kotlin tests
Closes gh-23475
2019-09-02 15:59:26 +02:00
康智冬 a6f4862f13 Fix typos related to indefinite articles
Closes gh-23555
2019-09-01 15:45:49 +02:00
Sam Brannen 0103fec5de Convert assertions to AssertJ
See gh-23551
2019-08-31 13:13:44 +02:00
Sam Brannen 5a22eafcb4 Merge branch '5.1.x' 2019-08-31 13:10:58 +02:00
Sam Brannen 9729b460f1 Retain entry set order in read-only HttpHeaders
Prior to this commit, the entry set of read-only HttpHeaders lost the
original headers' ordering.

The changes in commit ce7278aaf4 introduced a regression in the read-only
HttpHeaders support. Specifically, the implementation of entrySet() in
the internal ReadOnlyHttpHeaders class converted the original entry set
to an immutable, non-ordered set of immutable entries.

This commit fixes this issue by converting the original entry set to an
immutable, ordered set of immutable entries.

Closes gh-23551
2019-08-31 13:10:07 +02:00
Sam Brannen a496353770 Delete dead code 2019-08-31 11:44:04 +02:00
Arjen Poutsma 67d48ed821 Merge branch '5.1.x' 2019-08-29 17:18:22 +02:00
Arjen Poutsma d709a69ff1 Remove buffering of encoded parts in MultipartHttpMessageWriter
Closes gh-23518
2019-08-29 16:34:36 +02:00
Rossen Stoyanchev 117119a88d Merge branch '5.1.x' 2019-08-29 15:13:36 +03:00
Rossen Stoyanchev 88e9dcef0c Consistently apply onCompletion/onError handling
Follow-up change in addition to dd22b8fd.

See gh-23096
2019-08-29 09:20:50 +03:00
Sebastien Deleuze f65cc9a438 Remove explicit disabling of buffer recycling in Jackson codec
Since now https://github.com/FasterXML/jackson-core/issues/476
and https://github.com/FasterXML/jackson-core/issues/479 are fixed.

This commit also raises the minimum version of Jackson to 2.9.7.

Closes gh-23522
2019-08-28 18:47:21 +02:00
Sam Brannen c004ef888c Configure index in @ParameterizedTest display names
This commit prepends "[{index}] " to all custom display names
configured via @ParameterizedTest.

This provides better diagnostics between the "technical names" reported
on the CI server vs. the "display names" reported within a developer's
IDE.

See gh-23451
2019-08-28 17:06:23 +02:00
Rossen Stoyanchev 4e39450dbe Merge branch '5.1.x' 2019-08-27 21:49:51 +03:00
Rossen Stoyanchev dd22b8fd39 Fix race condition with onCompletion/onError
Closes gh-23096
2019-08-27 21:43:33 +03:00
Сергей Цыпанов 6ef75d76cd Simplify String concatenation
Closes gh-23470
2019-08-27 18:22:44 +02:00
Sam Brannen b2ad16aaa7 Merge branch '5.1.x' 2019-08-27 17:37:25 +02:00
Sam Brannen 8189c90741 Allow Set-Cookie header to be overwritten in MockHttpServletResponse
Prior to this commit, there was no way to replace the Set-Cookie header
via MockHttpServletResponse. Specifically, an invocation of setHeader()
for the Set-Cookie header resulted in an additional Set-Cookie header
instead of replacing the existing one, which is in violation of the
contract for javax.servlet.http.HttpServletResponse.setHeader(...).

This commit refactors the internals of MockHttpServletResponse to ensure
that an existing Set-Cookie header is overwritten when set via an
invocation of setHeader(). This commit also verifies the expected
behavior for addHeader() and addCookie() with regard to multiple cookies.

Closes gh-23512
2019-08-27 17:20:38 +02:00
Sam Brannen ad6231ad29 Add missing @Override annotations 2019-08-23 13:50:58 +02:00
Sam Brannen 3e2b977d5d Re-enable shadowed, overridden @Test and lifecycle methods
Due to a bug (or "unintentional feature") in JUnit 4, overridden test
and lifecycle methods not annotated with @Test, @Before, @After, etc.
are still executed as test methods and lifecycle methods; however,
JUnit Jupiter does not support that. Thus, prior to this commit, some
overridden test and lifecycle methods were no longer executed after the
migration from JUnit 4 to JUnit Jupiter.

This commit addresses this issue for such known use cases, but there
are likely other such use cases within Spring's test suite.

See gh-23451
2019-08-23 13:50:57 +02:00
Arjen Poutsma 8e4f2c89ff Add headers(Consumer<HttpHeaders>) to RequestEntity and ResponseEntity
Closes gh-23404
2019-08-23 11:23:26 +02:00
Rossen Stoyanchev 274eab7c5d Merge branch '5.1.x' 2019-08-21 13:36:11 +03:00
Rossen Stoyanchev a7bb5ca473 Remove unnecessary iteration over headers
The use of LinkedCaseInsensitiveMap, going back to 3.0, makes it
unnecessary to iterate over keys which can cause
ConcurrentModificationException.

Closes gh-23460
2019-08-21 13:34:17 +03:00
Rossen Stoyanchev 78abc27432 Remove statusCode state tracking
Closes gh-23490
2019-08-21 11:45:56 +03:00
Rossen Stoyanchev 0a7fdb380f Fix checkstyle error 2019-08-21 11:02:10 +03:00
Rossen Stoyanchev ff6ccd0d04 Adapt tests changed in 5.1.x to master 2019-08-21 10:24:46 +03:00
Rossen Stoyanchev 364c7c459d Merge branch '5.1.x' 2019-08-21 10:21:32 +03:00
Rossen Stoyanchev b86c11cc9b Respect existing content-length for HTTP HEAD
Closes gh-23484
2019-08-21 02:28:19 +03:00
Brian Clozel e9523161f0 Revert "Revert "Refactor Gradle tasks in Spring Framework build""
This reverts commit fb0d618751.
2019-08-20 20:26:43 +02:00
Stephane Nicoll fb0d618751 Revert "Refactor Gradle tasks in Spring Framework build"
This reverts commit 1539ba8991.
2019-08-20 20:07:11 +02:00
Brian Clozel 1539ba8991 Refactor Gradle tasks in Spring Framework build
This commit reorganizes tasks and scripts in the build to only apply
them where they're needed. We're considering here 3 "types" of projects
in our build:
* the root project, handling documentation, publishing, etc
* framework modules (a project that's published as a spring artifact)
* internal modules, such as the BOM, our coroutines support and our
integration-tests

With this change, we're strealining the project configuration for all
spring modules and only applying plugins when needed (typically our
kotlin support).

See gh-23282
2019-08-20 18:17:02 +02:00
Sam Brannen cf1bf3d98c Polish parameterized tests 2019-08-20 12:43:31 +02:00
Sam Brannen 288461a541 Introduce @EnabledForTestGroups in Spring's test suite
Closes gh-23476
2019-08-17 14:47:24 +02:00
Sam Brannen bbe33832cf Clean up warnings in Javadoc 2019-08-17 13:21:28 +02:00
Sam Brannen 979508a7f3 Remove JUnit 4 dependency from all modules except spring-test
This commit removes the JUnit 4 dependency from all modules except
spring-test which provides explicit JUnit 4 support.

This commit also includes the following.

- migration from JUnit 4 assertions to JUnit Jupiter assertions in all
  Kotlin tests
- migration from JUnit 4 assumptions in Spring's TestGroup support to
  JUnit Jupiter assumptions, based on org.opentest4j.TestAbortedException
- introduction of a new TestGroups utility class than can be used from
  existing JUnit 4 tests in the spring-test module in order to perform
  assumptions using JUnit 4's Assume class

See gh-23451
2019-08-17 11:37:21 +02:00
Sam Brannen 3f3e41923f Migrate rest of test suite from JUnit 4 to JUnit Jupiter
This commit migrates the rest of Spring's test suite to JUnit Jupiter,
except spring-test which will be migrated in a separate commit.

See gh-23451
2019-08-17 11:36:58 +02:00
Sam Brannen 3df85c783f Migrate parameterized tests in spring-core
This commit migrates parameterized tests in spring-core using the
"composed @ParameterizedTest" approach. This approach is reused in
follow-up commits for the migration of the remaining modules.

For a concrete example, see AbstractDataBufferAllocatingTests and its
subclasses (e.g., DataBufferTests).

Specifically, AbstractDataBufferAllocatingTests declares a custom
@ParameterizedDataBufferAllocatingTest annotation that is
meta-annotated with @ParameterizedTest and
@MethodSource("org.springframework.core.io.buffer.AbstractDataBufferAllocatingTests#dataBufferFactories()").

Individual methods in concrete subclasses are then annotated with
@ParameterizedDataBufferAllocatingTest instead of @ParameterizedTest or
@Test.

The approach makes the migration from JUnit 4 to JUnit Jupiter rather
straightforward; however, there is one major downside. The arguments
for a @ParameterizedTest test method can only be accessed by the test
method itself. It is not possible to access them in an @BeforeEach
method (see https://github.com/junit-team/junit5/issues/944).
Consequently, we are forced to declare the parameters in each such
method and delegate to a custom "setup" method. Although this is a bit
cumbersome, I feel it is currently the best way to achieve fine grained
parameterized tests within our test suite without implementing a custom
TestTemplateInvocationContextProvider for each specific use case.

Once https://github.com/junit-team/junit5/issues/878 is resolved, we
should consider migrating to parameterized test classes.

See gh-23451
2019-08-17 11:36:47 +02:00
Daniel Le 60ec736264 Fix */* in Javadoc
This commit changes {@code &#42;&#47;&#42;} to <code>&#42;&#47;&#42;</code>
so that "*/*" is rendered correctly.

Closes gh-23439
2019-08-09 13:32:18 +02:00
Phillip Webb 62a3e41473 Deprecate mutable methods of MethodParameter
Deprecate all mutation methods in `MethodParameter` in favor of factory
methods that return a new instance. Existing code that previously relied
on mutation has been updated to use the replacement methods.

Closes gh-23385
2019-08-01 08:05:14 +01:00
Juergen Hoeller 6eca9e7cc9 Drop logger field in HandlerMethodArgumentResolverComposite 2019-07-31 23:58:02 +02:00
Juergen Hoeller dea9ad6cb2 Merge branch '5.1.x' 2019-07-31 23:53:32 +02:00
Juergen Hoeller ea4f7d365f Deprecate logger field in HandlerMethodArgumentResolverComposite 2019-07-31 23:48:21 +02:00
Juergen Hoeller 3b235a098f Merge branch '5.1.x' 2019-07-30 22:52:20 +02:00
Juergen Hoeller 59064f0780 Upgrade to Undertow 2.0.23 and Apache Johnzon 1.1.12 2019-07-30 22:27:09 +02:00
Juergen Hoeller 960079e5f5 Retain non-null HttpStatus return value in Client(Http)Response
See gh-23366
2019-07-30 22:26:46 +02:00
Arjen Poutsma ac9a11a581 Merge branch '5.1.x' 2019-07-30 18:03:01 +02:00
Arjen Poutsma 29ef985411 Add support for non-standard status codes
Added support for status codes that do not occur in HttpStatus in
DefaultClientResponseBuilder and made ClientResponse::statusCode
ClientHttpResponse::getStatusCode @Nullable.

Closed gh-23366
2019-07-30 17:44:47 +02:00
Juergen Hoeller 8ef557df2f Merge branch '5.1.x' 2019-07-30 17:34:29 +02:00
Juergen Hoeller c4622dbebc Polishing 2019-07-30 16:59:01 +02:00
Juergen Hoeller cc57506474 Add status code 425 ("Too Early") to HttpStatus enum
Closes gh-23384
2019-07-30 16:05:00 +02:00
Rossen Stoyanchev 9648b1c2c6 Merge branch '5.1.x' 2019-07-30 12:06:39 +01:00
Rossen Stoyanchev 7b697266be PathPatternParser allows '-' in variables
The isJavaIdentifier check is not really required, but also seems
intuitive for variables to be Java identifier-like. This commit relaxes
the constraint a bit by also allowing "-".

Closes gh-23101
2019-07-30 12:04:47 +01:00
Sam Brannen 9655fc5007 Introduce ServerHttpRequest.Builder.header() variant for setting headers
Prior to this commit, the `header(String, String)` method in the
ServerHttpRequest.Builder API actually added a header value instead of
setting or overriding a header value. Since this conflicted with the
stated behavior in the Javadoc as well as the original intention of the
method, we have decided to introduce an overloaded variant
`header(String, String...)` which accepts a var-args list of header
values to set or override.

In addition, this commit deprecates the existing `header(String, String)`
method for removal in Spring Framework 5.2.

In order not to be a breaking change for custom implementations of the
builder API, this commit implements the new `header(String, String...)`
method as an interface `default` method, with the intent to remove the
default implementation in Spring Framework 5.2

closes gh-23333
2019-07-25 13:45:39 +02:00
Sam Brannen db3990d031 Merge branch '5.1.x' 2019-07-25 13:44:31 +02:00
Sam Brannen 5034d1e7b3 Introduce ServerHttpRequest.Builder.header() variant for setting headers
Prior to this commit, the `header(String, String)` method in the
ServerHttpRequest.Builder API actually added a header value instead of
setting or overriding a header value. Since this conflicted with the
stated behavior in the Javadoc as well as the original intention of the
method, we have decided to introduce an overloaded variant
`header(String, String...)` which accepts a var-args list of header
values to set or override.

In addition, this commit deprecates the existing `header(String, String)`
method for removal in Spring Framework 5.2.

In order not to be a breaking change for custom implementations of the
builder API, this commit implements the new `header(String, String...)`
method as an interface `default` method, with the intent to remove the
default implementation in Spring Framework 5.2

closes gh-23333
2019-07-25 13:02:09 +02:00
Stephane Nicoll f95372d757 Merge branch '5.1.x' 2019-07-25 08:39:31 +02:00
Johnny Lim 946fc39d42 Add Javadoc since for Jaxb2XmlDecoder(MimeType...)
See gh-23353
2019-07-25 08:38:46 +02:00
Rossen Stoyanchev acb3d1cf88 Fix typo in test from previous commit
See gh-23310
2019-07-22 14:59:52 +01:00
Rossen Stoyanchev 358a6d6f10 Improve separator support in PathContainer
To make the switching of separators complete, it is also important to
know whether the decoding of path segment values and the parsing of
path param should be done as those are applied transparently.

This commit replaces the recently added separator argument to
PathContainer.parsePath with an Options type with two predefined
constants. One for HTTP URLs with automatic decoding and parsing of
path params, and another for "." separated message routes without
decoding except for encoded sequences of the separator itself.

See gh-23310
2019-07-22 11:28:38 +01:00
Sam Brannen b0939a8af0 Suppress deprecation warnings in Gradle build 2019-07-21 13:12:02 +02:00
Juergen Hoeller 45136aabd4 Upgrade to Protobuf 3.9 (plus consistent XMLUnit declarations) 2019-07-20 19:06:54 +02:00
Juergen Hoeller cdeb1fef5f Merge branch '5.1.x' 2019-07-20 18:23:00 +02:00
Juergen Hoeller 92890232df Upgrade to OpenPDF 1.2.21, Rome 1.12.1, XStream 1.4.11.1
Includes updated javadoc links for 5.1.x branch.
2019-07-20 18:20:03 +02:00
Arjen Poutsma c8704ce473 Introduce DataBufferWrapper
This commit introduces the DataBufferWrapper, a wrapper for DataBuffers,
and uses it in applicable use cases.
2019-07-19 12:45:24 +02:00
Rossen Stoyanchev 24e96b6c79 Merge branch '5.1.x' 2019-07-19 10:52:30 +01:00
Rossen Stoyanchev 153ac82380 Polish 2019-07-19 10:44:23 +01:00
Andreas Kluth 4973e110ee An empty X-Forwarded-Prefix with a path containing escape sequences leads to exceptions. 2019-07-19 10:44:23 +01:00
Rossen Stoyanchev 2b94205ba9 Update docs on multipart with RestTemplate
Replace docs on using MultipartBodyBuilder for the RestTemplate with
examples that show MultiValueMap. Originally the idea was to make
MultipartBodyBuilder accessible to the RestTemplate too, but with
support for async parts that's no longer a good fit.

Closes gh-23295
2019-07-19 10:43:50 +01:00
Sebastien Deleuze 095fd5bcb3 Use Kotlin BOM
Close gh-23316
2019-07-19 10:43:54 +02:00
Sam Brannen 38f6d270f8 Delete dead code in tests 2019-07-18 12:20:26 +02:00
Juergen Hoeller 94e3210ae7 Fix nullability warnings and javadoc-triggered package cycles 2019-07-17 22:34:07 +02:00
Sebastien Deleuze d6e3394b81 Polishing
See gh-23219
2019-07-16 19:23:21 +02:00
Sam Brannen b2b79ae1e6 Polish contribution
See gh-23219
2019-07-16 14:57:32 +02:00
Rossen Stoyanchev 1ff29b0f6b Merge branch '5.1.x' 2019-07-15 11:34:35 +01:00
Rossen Stoyanchev 99c4a9eeba Filtering for nested ERROR dispatch
OncePerRequestFilter now has a doFilter method that allows separate
processing of nested ERROR dispatches. This is useful for filters
that wrap the request and response.

Closes gh-23196
2019-07-15 11:23:12 +01:00
Rossen Stoyanchev 2eba010c1b Merge branch '5.1.x' 2019-07-13 11:00:57 +01:00
Rossen Stoyanchev 235858e4e5 Exposes supported mime types in Jaxb2Decoder
Closes gh-23278
2019-07-13 11:00:43 +01:00
Rob Winch fde92793b5 Fix http URLs
See gh-22839
2019-07-11 18:14:20 +02:00
Stephane Nicoll 4a5063f4c0 Merge branch '5.1.x' 2019-07-11 09:55:13 +02:00
桂坤 81eb911c09 Fix typo in UrlPathHelper
See gh-23274
2019-07-11 09:54:03 +02:00
Сергей Цыпанов 1728bf17fc Avoid unnecessary boxing where primitives can be used
Closes gh-23267
2019-07-10 16:51:18 +02:00
Arjen Poutsma 2909de8829 Remove ServerWebExchange::getParts and ServerRequest::parts
Revert to state before DefaultMultipartMessageReader
2019-07-10 16:20:20 +02:00
Arjen Poutsma 77c24aac2f Remove DefaultMultipartMessageReader
The DefaultMultipartMessageReader has been removed for 5.2 and will be
part of a future release. This commit switches back to the
SynchronossPartHttpMessageReader.

gh-21659
2019-07-10 16:00:11 +02:00
Rossen Stoyanchev c199cb9054 @ConnectMapping for RSocket handling
The new annotation helps to differentiate the handling of connection
level frames (SETUP and METADATA_PUSH) from the 4 stream requests.

Closes gh-23177
2019-07-08 17:04:23 +01:00
Sebastien Deleuze 2b4d6ce354 Add body methods with Object parameter to WebFlux
The commit deprecates syncBody(Object) in favor of body(Object)
which has the same behavior in ServerResponse, WebClient and
WebTestClient. It also adds body(Object, Class) and
body(Object, ParameterizedTypeReference) methods in order to support
any reactive type that can be adapted to a Publisher via
ReactiveAdapterRegistry. Related BodyInserters#fromProducer
methods are provided as well.

Shadowed Kotlin body<T>() extensions are deprecated in favor of
bodyWithType<T>() ones, including dedicated Publisher<T> and
Flow<T> variants. Coroutines extensions are adapted as well, and
body(Object) can now be used with suspending functions.

Closes gh-23212
2019-07-07 22:27:57 +02:00
Sam Brannen 0fbc9bf461 Fix broken Javadoc links 2019-07-07 19:50:34 +02:00
Sam Brannen 575027af24 Polishing 2019-07-07 16:34:15 +02:00
Sam Brannen fae75cb238 Polish contribution
See gh-23237
2019-07-07 16:29:03 +02:00
Johnny Lim 6dcf390fa2 Rename PathPatternRouteMatcherTest to PathPatternRouteMatcherTests
Closes gh-23239
2019-07-07 16:28:09 +02:00
Сергей Цыпанов 9f81ffa5ae Use StringJoiner where possible to simplify String joining
Closes gh-23237
2019-07-07 16:19:01 +02:00
Sam Brannen 8f5b2b2231 Merge branch '5.1.x' 2019-07-07 14:49:34 +02:00
Sam Brannen efab6eb55d Ignore empty entries when parsing MediaTypes and MimeTypes
Prior to Spring Framework 5.1.3, MimeTypeUtils.parseMimeTypes() and
MediaType.parseMediaTypes() ignored empty entries, but 5.1.3 introduced
a regression in that an empty entry -- for example, due to a trailing
comma in the list of media types in an HTTP Accept header -- would result
in a "406 Not Acceptable" response status.

This commit fixes this by filtering out empty entries before parsing
them into MimeType and MediaType instances. Empty entries are therefore
effectively ignored.

Fixes gh-23241
2019-07-07 12:39:46 +02:00
Rossen Stoyanchev fbb72eff2e Polish 2019-07-05 09:02:24 +01:00
Dmytro Nosan ea10ee5265 queryParam and replaceParam with List
See gh-23114
2019-07-05 09:02:24 +01:00
Phillip Webb 932f771380 Improve performance of FormContentFilter
Improve the performance of `FormContentFilter` by checking directly if
`contentType` is empty. This saves the need for an exception to thrown
then immediately caught.

Closes gh-23216
2019-06-29 22:31:11 -07:00
Sam Brannen 896496341a Add explicit support for multipart/mixed in FormHttpMessageConverter
Commit 5008423408 added support for
multipart/* media types in FormHttpMessageConverter, but users still had
to manually register multipart/mixed as a supported media type in order
to POST multipart data with that content type.

This commit removes the need to manually register multipart/mixed as a
supported media type by registering it automatically in
FormHttpMessageConverter. In addition, this commit introduces
MULTIPART_MIXED and MULTIPART_MIXED_VALUE constants in MediaType.

Closes gh-23209
2019-06-29 11:41:15 +03:00
Sam Brannen 75d1428e24 Polishing 2019-06-29 11:41:15 +03:00
Sam Brannen 3e41f5e6b6 Cache the encoded credentials in BasicAuthenticationInterceptor
Prior to this commit, the Basic Authentication credentials were encoded
for each request.

This commit addresses this minor performance issue by caching the
encoded credentials in BasicAuthenticationInterceptor.

In addition, this commit introduces new encodeBasicAuth() and
setBasicAuth(String encodedCredentials) methods in HttpHeaders to
support this feature.

Closes gh-23204
2019-06-28 18:48:59 +03:00
Sam Brannen 5008423408 Support multipart/* MediaTypes in RestTemplate
Prior to this commit, RestTemplate posted multipart with Content-Type
"multipart/form-data" even if the FormHttpMessageConverter configured
in the RestTemplate had been configured to support additional multipart
subtypes. This made it impossible to POST form data using a content
type such as "multipart/mixed" or "multipart/related".

This commit addresses this issue by updating FormHttpMessageConverter
to support custom multipart subtypes for writing form data.

For example, the following use case is now supported.

MediaType multipartMixed = new MediaType("multipart", "mixed");

restTemplate.getMessageConverters().stream()
    .filter(FormHttpMessageConverter.class::isInstance)
    .map(FormHttpMessageConverter.class::cast)
    .findFirst()
    .orElseThrow(() ->
        new IllegalStateException("Failed to find FormHttpMessageConverter"))
    .addSupportedMediaTypes(multipartMixed);

MultiValueMap<String, Object> parts = new LinkedMultiValueMap<>();
parts.add("field 1", "value 1");
parts.add("file", new ClassPathResource("myFile.jpg"));

HttpHeaders requestHeaders = new HttpHeaders();
requestHeaders.setContentType(multipartMixed);
HttpEntity<MultiValueMap<String, Object>> requestEntity =
    new HttpEntity<>(parts, requestHeaders);

restTemplate.postForLocation("https://example.com/myFileUpload", requestEntity);

Closes gh-23159
2019-06-28 17:13:18 +03:00
Sam Brannen 7bc727c895 Convert addSupportedMediaType() to var-args in FormHttpMessageConverter
This commit changes the new addSupportedMediaType(MediaType) method
to addSupportedMediaTypes(MediaType...), in order to allow registration
of multiple supported media types simultaneously.

See gh-23203
2019-06-27 16:55:03 +03:00
Sam Brannen 1ef60f2d3b Polishing 2019-06-27 16:05:38 +03:00
Sam Brannen 91ae711a54 Fix Javadoc for MediaType 2019-06-27 16:05:38 +03:00
Sam Brannen 4e7d8a8873 Introduce addSupportedMediaType() in FormHttpMessageConverter
Closes gh-23203
2019-06-27 16:05:38 +03:00
Sam Brannen 8e1cb9a059 Improve diagnostics for all server failures in RestTemplateIntegrationTests 2019-06-27 14:16:19 +03:00
Sam Brannen d522e9835f Polish AbstractMockWebServerTestCase 2019-06-27 13:45:32 +03:00
Sam Brannen 0b6239cecc Improve diagnostics for failures in RestTemplateIntegrationTests 2019-06-26 15:16:54 +03:00
Sam Brannen 7d6be2e26e Polishing 2019-06-26 15:12:32 +03:00
Sam Brannen 0f1d16bb05 Fix Checkstyle violation 2019-06-24 17:54:04 +03:00
Sam Brannen d0231cb29a Presort beans in ControllerAdviceBean.findAnnotatedBeans()
Prior to this commit, all clients of
ControllerAdviceBean.findAnnotatedBeans() sorted the returned list
manually. In addition, clients within the core Spring Framework
unnecessarily used AnnotationAwareOrderComparator instead of
OrderComparator to sort the list.

This commit presorts the ControllerAdviceBean list using OrderComparator
directly within ControllerAdviceBean.findAnnotatedBeans().

Closes gh-23188
2019-06-24 16:26:11 +03:00
Sam Brannen d5a2bdee8d Improve Javadoc for @ControllerAdvice regarding ordering
Closes gh-23163
2019-06-24 14:36:04 +03:00
Sam Brannen 9239ab1891 Support Ordered interface for @ControllerAdvice beans
Closes gh-23163
2019-06-23 19:31:35 +03:00
Sam Brannen 978adbdae7 Avoid duplicate lookups of @ControllerAdvice annotations
See gh-23163
2019-06-23 18:31:04 +03:00
Sam Brannen 7576d0d40c Polishing
See gh-23163
2019-06-22 19:06:58 +03:00
Sam Brannen 4568edf6c4 Simplify ControllerAdviceBean constructors
See gh-23163
2019-06-22 19:02:49 +03:00
Sam Brannen 8f30639a0a Test status quo for Ordered support for @ControllerAdvice beans
See gh-23163
2019-06-22 18:18:57 +03:00
Sam Brannen 21267e56b7 Cache resolved bean instance in ControllerAdviceBean
Prior to this commit, the resolveBean() method in ControllerAdviceBean
looked up the @ControllerAdvice bean instance in the ApplicationContext
by name for every web request that involved lookups for global methods
annotated with @ExceptionHandler, @InitBinder, and @ModelAttribute.

This commit avoids the need for such repeated lookups in the
ApplicationContext by caching the resolved @ControllerAdvice bean
instance within ControllerAdviceBean once it has been resolved.
2019-06-21 18:27:33 +03:00
Sam Brannen 59901592d2 Introduce regression tests for ControllerAdviceBean
This commit introduces unit tests for the status quo in
ControllerAdviceBeanTests to serve as regression tests for future
changes to ControllerAdviceBean.
2019-06-21 17:21:50 +03:00
Sam Brannen 52f1a3aef9 Polish ControllerAdviceBean 2019-06-21 17:11:12 +03:00
Rossen Stoyanchev 030caea9cf Merge branch '5.1.x' 2019-06-21 14:15:26 +01:00
Rossen Stoyanchev 594c5806a6 Handle error in apply of writeFunction
Closes gh-23175
2019-06-21 14:15:14 +01:00
Sam Brannen 0e5a38591f Cache beanType in ControllerAdviceBean 2019-06-21 14:09:05 +03:00
Sam Brannen 2759b4b909 Avoid use of Stream API in ControllerAdviceBean 2019-06-21 13:49:49 +03:00
Sam Brannen d5554d5d8d Polish @ControllerAdvice and @RestControllerAdvice 2019-06-21 13:26:30 +03:00
Sam Brannen ad915f4a26 Document that Ordered is not supported for @ControllerAdvice beans
Closes gh-23172
2019-06-21 12:39:34 +03:00
Arjen Poutsma 11c7907a59 Add Flux<Part> ServerWebExchange.getParts()
This commit introduces ServerWebExchange.getParts(), as an alternative,
streaming way of accessing multipart data.
2019-06-21 10:59:12 +02:00
Brian Clozel cc05608ae9 PathPattern does not use custom separator
Prior to this commit, `PathPattern::extractPathWithinMapping`
would always use the default path pattern separator `/` when extracting
the path within the pattern of a matched route.

This commit ensures that `PathPattern` uses the configured separator
when extracting the path within the matched mapping.

Fixes gh-23168
2019-06-20 20:27:22 +02:00
Brian Clozel 5787fc16fb PathPatternRouteMatcher should use custom separator
Prior to this commit, the `PathPatternRouteMatcher` would always use the
default path pattern separator when parsing incoming route strings to
`RouteMatcher.Route` instances.
When the `PathPatternRouteMatcher` is configured with a
`PathPatternParser` that has a custom separator (e.g., `.`), then the
matching algorithm can't match routes against parsed patterns.

This commit ensures that the route matcher uses the configured separator
at all times.

Fixes gh-23167
2019-06-20 20:23:04 +02:00
Sam Brannen f56c54dfc8 Polishing 2019-06-20 18:09:22 +03:00
Sam Brannen d2e6d0269b Preliminary tests for multipart/related & multipart/mixed in RestTemplate
See gh-23159
2019-06-20 11:35:18 +03:00
Sebastien Deleuze 341385acfc Merge branch '5.1.x' 2019-06-19 13:59:59 +02:00
Sebastien Deleuze bcad276adb Fix Jackson documentation broken links
Closes gh-23153
2019-06-19 13:59:36 +02:00
Sam Brannen 4000b244ff Forbid null converters in RestTemplate & HttpMessageConverterExtractor
Prior to this commit, RestTemplate and HttpMessageConverterExtractor did
not validate that the supplied HttpMessageConverter list contained no
null elements, which can lead to a NullPointerException when the
converters are accessed.

This commit improves the user experience by failing immediately if the
supplied HttpMessageConverter list contains a null element. This applies
to constructors for RestTemplate and HttpMessageConverterExtractor as
well as to RestTemplate#setMessageConverters().

Note, however, that RestTemplate#getMessageConverters() returns a mutable
list. Thus, if a user modifies that list so that it contains null values,
that will still lead to a NullPointerException when the converters are
accessed.

This commit also introduces noNullElements() variants for collections in
org.springframework.util.Assert.

Closes gh-23151
2019-06-18 16:13:20 +03:00
Sam Brannen da903904c9 Fix Javadoc reference to MediaType#APPLICATION_CBOR_VALUE
{@value ...} cannot be used outside of the current type.
2019-06-18 13:00:00 +03:00
Sam Brannen aa0a8d66a8 Polishing 2019-06-18 10:19:03 +03:00
Johnny Lim 7f67cecd10 Polish MappingMediaTypeFileExtensionResolver.addFileExtension()
Closes gh-23145
2019-06-18 10:10:30 +03:00
Arjen Poutsma 30af01fd4e Use DataBufferUtils.write in DefaultFilePart.transferTo
This commit makes sure that in DefaultMultipartMessageReader's
DefaultFilePart, the file is not closed before all bytes are written,
by using DataBufferUtils.write (see c1b6885191d6a50347aeaa14da994f0db88f26fe).

The commit also improves on the logging of the
DefaultMultipartMessageReader.

Closes gh-23130
2019-06-14 14:13:18 +02:00
Sam Brannen 99d10a671c Merge branch '5.1.x' 2019-06-14 14:51:08 +03:00
Sam Brannen d18d4d865e Update Javadoc for HtmlUtils regarding Apache Commons Text
Closes gh-23122
2019-06-14 14:48:24 +03:00
Johnny Lim 293506013d Add since declarations for JettyClientHttpConnector constructor change
Closes gh-23128
2019-06-14 14:31:37 +03:00
Rossen Stoyanchev 14e2c6803e Support for RSocket composite metadata
Closes gh-22798
2019-06-12 17:11:30 -04:00
Juergen Hoeller 0a77477d32 Merge branch '5.1.x' 2019-06-12 18:16:30 +02:00
Juergen Hoeller fc46abf0b7 Polishing 2019-06-12 18:04:06 +02:00
Juergen Hoeller 42c0d8ec7f Merge branch '5.1.x' 2019-06-12 14:14:40 +02:00
Juergen Hoeller 627d37f73b Thread-safe removal of destruction callbacks in web scopes
Closes gh-23117
2019-06-12 14:11:13 +02:00
Juergen Hoeller bd76a160bb Merge branch '5.1.x' 2019-06-12 00:58:51 +02:00
Juergen Hoeller 4877736794 Polishing 2019-06-12 00:58:04 +02:00
Juergen Hoeller 7e02358166 Merge branch '5.1.x' 2019-06-12 00:05:01 +02:00
Juergen Hoeller 22aba8bf60 Upgrade to Apache HttpClient 4.5.9 2019-06-11 23:49:57 +02:00
Juergen Hoeller a89bfffd8c Merge branch '5.1.x' 2019-06-11 23:16:03 +02:00
Juergen Hoeller 7dc92aa05d Polishing 2019-06-11 20:57:27 +02:00
Juergen Hoeller 1956cb1e57 Defensive concurrent access to shared file extension data structures
Closes gh-23064
2019-06-11 20:57:17 +02:00
Rossen Stoyanchev 1f05bd4ef3 Merge branch '5.1.x' 2019-06-07 16:08:29 -04:00
Rossen Stoyanchev 9f8148419f Separate "filtered" attribute for ERROR dispatch
Closes gh-22989
2019-06-07 16:07:56 -04:00
Sam Brannen 61bf45c86f Merge branch '5.1.x' 2019-06-06 17:40:51 +03:00
Ilya Lukyanovich 2ed81be831 Fix MockHttpServletRequest.setCookies to produce single cookie header
Prior to this commit, MockHttpServletRequest.setCookies() produced one
Cookie header per supplied cookie, resulting in multiple Cookie headers
which violates the specification.

This commit fixes this by ensuring that all cookie name-value pairs are
stored under a single Cookie header, separated by a semicolon.

Closes gh-23074
2019-06-06 17:13:21 +03:00
Sebastien Deleuze 098ac0bbb8 Annotate Object#equals parameter with @Nullable
Closes gh-23093
2019-06-06 14:18:30 +02:00
Brian Clozel 33becd8258 Allow separator configuration in PathPatternParser
This commit allows to configure a custom path separator when parsing and
matching path patterns with `PathPatternParser`, but also when parsing
incoming paths as `PathContainer` instances.

Closes gh-23092
2019-06-06 11:39:53 +02:00
Rossen Stoyanchev ec91934730 Use correct file options for transferTo
Similar to fix applied to Synchronoss implementation in #cef98e.
2019-06-05 10:54:56 -04:00
Rossen Stoyanchev 1f35bb609b Fix checkstyle warning 2019-06-04 17:38:30 -04:00
Rossen Stoyanchev 69eba32284 Improved Part support in MultipartBodyBuilder
1. Add contentType and filename options to PartBuilder.

2. Revert recently committed #44659f since asyncPart can't properly
support Publisher of Part (only Mono, can't support filename), and
replace that with support for Part in the regular part method.

Closes gh-23083
2019-06-04 17:21:39 -04:00
Rossen Stoyanchev 8781c01edf Merge branch '5.1.x' 2019-06-04 16:42:13 -04:00
Rossen Stoyanchev 49e5c4dcf6 Polish MultipartBodyBuilder
Improve Javadoc
Consistently reject Publisher unless using asyncPart
Consistently set Content-Type when specified
2019-06-04 16:41:10 -04:00
Rossen Stoyanchev e89fd5c3be Merge branch '5.1.x' 2019-06-03 16:34:58 -04:00
Rossen Stoyanchev 4f05da7fed Support escape character in ContentDisposition
Closes gh-23077
2019-06-03 16:03:35 -04:00
Sebastien Deleuze 5b04b04b69 Merge branch '5.1.x' 2019-05-29 11:54:40 +02:00
Sebastien Deleuze 4523d01a50 Fix Javadoc for HttpHeaders#setContentLanguage
Closes gh-23051
2019-05-29 11:53:38 +02:00
Johnny Lim 83078eb6fd Add constants for application/cbor to MediaType
Closes gh-23042
2019-05-28 18:51:25 +02:00
Brian Clozel 1cfedb20b8 Add new constructor to JettyClientHttpConnector
This commit adds a new constructor to `JettyClientHttpConnector` and
deprecates another one. Jetty is not creating `HttpClient` instances
using a builder API, but rather setting immutable configuration at
constructor time and using setters for the rest.

This commit addresses that by deprecating the constructor variant
accepting a `Consumer` and just delegating to Spring's implementation
for setting the client resources as needed.

Closes gh-22977
2019-05-28 16:59:51 +02:00
Sam Brannen 141ef9082f Clean up Mockito usage
This commit migrates to the MockitoJUnitRunner where sensible, which
will later allow for an easier migration to Mockito's extension for
JUnit Jupiter.

In addition, this commit deletes unnecessary stubbing for various mocks
and polishes test fixture setup in various test classes.
2019-05-28 13:59:43 +02:00
Sebastien Deleuze bc205e0dbf Remove charset parameter from Spring MVC JSON content type
This change is a follow-up to the ones done as part of gh-22788.

Closes gh-22954
2019-05-27 18:14:19 +02:00
Phillip Webb 9d74da006c Migrate JUnit 4 assertions to AssertJ
Migrate all existing JUnit 4 `assert...` based assertions to AssertJ
and add a checkstyle rule to ensure they don't return.

See gh-23022
2019-05-23 15:52:49 -07:00
Phillip Webb 95a9d46a87 Migrate Hamcrest assertions to AssertJ
Migrate all existing `assertThat(..., Matcher)` assertions to AssertJ
and add checkstyle rules to ensure they don't return.

See gh-23022
2019-05-23 15:49:59 -07:00