Commit Graph

2870 Commits

Author SHA1 Message Date
Juergen Hoeller a82f049083 FormHttpMessageConverter officially supports non-String form values
Issue: SPR-17645
2019-01-08 17:11:07 +01:00
Rossen Stoyanchev b219c6ce15 Adjust UriComponentsBuilder#toUriString behavior
Commit #93b7a4 added support for pre-configuring URI variables at the
UriComponentsBuilder level, and also changed toUriString to encode
template and URI variables separately. However this went a bit too far
causing side effects for URLs with curly braces that don't represent
URI variables.

This commit restores the original toUriString behavior which is to
encode template and URI variables sepraately only if URI variables have
been pre-configured.

Issue: SPR-17630
2019-01-08 11:06:33 -05:00
王诗峣 b94e8c4bef Fix ClassCastException in FormHttpMessageConverter
We should not cast MultiValueMap<String, ?> to MultiValueMap<String, String>
2019-01-08 12:19:51 +01:00
Juergen Hoeller d37a18ff03 Upgrade to Hibernate Validator 6.0.14 and Apache Johnzon 1.1.11
Includes OkHttp MockWebServer 3.12.1.
2019-01-08 00:50:44 +01:00
Juergen Hoeller 6e3f974951 HttpHeaders.writableHttpHeaders properly handles HttpHeaders.EMPTY
Issue: SPR-17633
2019-01-08 00:32:27 +01:00
Juergen Hoeller 1faeeaea14 HandlerMethodParameter defensively handles interface annotation arrays
Issue: SPR-17629
2019-01-08 00:32:09 +01:00
Rossen Stoyanchev 673a20cb10 Defensive initialization of AsyncXMLInputFactory
Aalto's InputFactoryImpl already disables loading of external entities
by default (property "javax.xml.stream.isSupportingExternalEntities").
This commit goes further by applying the same defensive measures as we
do elsewhere for XMLInputFactory, which disables DTD completely.
Arguably there is no good reason to enable that by default in WebFlux.
2019-01-07 13:52:46 -05:00
Rossen Stoyanchev 63984800e4 Lenient URI template encoding
URI template encoding ignores mismatched curly braces, treating them as
literal parts instead.

Issue: SPR-17630
2019-01-02 16:36:08 -05:00
Rossen Stoyanchev 4b24bcb799 More accurate checks for presence of MediaType.ALL
Typically a straight up equals as well as Collections#contains
checks for MediaType.ALL is susceptible to the presence of
media type parameters.

This commits adds equalsTypeAndSubtype as well as an
isPresentIn(Collection<MimeType>) methods to MimeType to faciliate
with checks for MediaType.ALL.

Issue: SPR-17550
2019-01-02 14:32:50 -05:00
Juergen Hoeller 8d1de75b60 Upgrade to WebJars Locator 0.36 and OkHttp 3.12.1
Includes JRuby 9.2.5 and Jetty Reactive HttpClient 1.0.2.
2018-12-25 13:22:17 +01:00
Brian Clozel 6361b0cb23 Write CharSequence instances to DataBuffers
Prior to this commit, one could write a `CharSequence` to an existing
`DataBuffer` instance by turning it into a byte array or `ByteBuffer`
first. This had the following disadvantages:

1. Memory allocation was not efficient (not leveraging pooled memory
when available)
2. Dealing with `CharsetEncoder` is not always easy
3. `DataBuffer` implementations, like `NettyDataBuffer` can use
optimized implementations in some cases

This commit adds a new `DataBuffer#write(CharSequence, Charset)` method
for those cases and also an `ensureCapacity` method useful for checking
that the current buffer has enough capacity to write to it..

Issue: SPR-17558
2018-12-20 21:33:33 +01:00
Arjen Poutsma 5e4a8966ee Make TomcatHttpHandlerAdapter aware of request/response wrappers
This commit makes TomcatServerHttpRequest aware of
HttpServletRequestWrappers, and TomcatServerHttpResponse aware of
HttpServletResponseWrappers.

Issue: SPR-17611
2018-12-19 12:16:14 +01:00
Violeta Georgieva 09da10cc6c Propagate the cancel signal to the downstream
Issue: SPR-17609
2018-12-18 15:04:08 -05:00
Juergen Hoeller 0e8ed5931d Revised backport version 5.0.11
Issue: SPR-17410
Issue: SPR-17433
2018-12-17 18:19:21 +01:00
Juergen Hoeller a240cfcf2f Consistent support for if-(un)modified-since as ZonedDateTime/Instant
Includes DefaultRequestBodyUriSpec pre-resolving URI for HttpRequest.

Issue: SPR-17571
2018-12-17 16:21:39 +01:00
igor-suhorukov 93189a6733 String.indexOf() expressions can be replaced with a call to the String.contains() method available in Java 5 and newer. 2018-12-13 12:29:31 +01:00
Rossen Stoyanchev 38ae282c3b Update log category precision for all tests
Replace the full category capped at 36 chars with the class name only
and 1 char per package, e.g. org.apache.commons.Foo -> o.a.c.Foo
2018-12-12 11:40:33 -05:00
Rossen Stoyanchev 05d616240a StringHttpMessageConverter defaults to UTF-8 for JSON
Issue: SPR-17568
2018-12-12 11:40:33 -05:00
Rossen Stoyanchev 8eef97da33 HTTP header adapters print header values
Issue: SPR-17546
2018-12-12 11:40:33 -05:00
Juergen Hoeller 7b7a8196f5 Revised HttpHeaders javadoc 2018-12-12 13:20:58 +01:00
Juergen Hoeller 6eb0a60df9 Polishing 2018-12-12 11:16:53 +01:00
Juergen Hoeller 5bbbc82e19 Consistent handling of null header values in HttpHeaders
Issue: SPR-17588
2018-12-12 11:16:45 +01:00
wonwoo 9a13d93a6b Fix typo in javadoc
Closes gh-2049
2018-12-12 08:00:15 +01:00
Juergen Hoeller 6a012147c4 Consistent support for last-modified argument as Instant/ZonedDateTime
Issue: SPR-17571
2018-12-06 15:53:47 +01:00
Lars Grefer 9abd4ed33d Allow Instant and ZonedDateTime as Last-Modified header.
Issues: SPR-17571
2018-12-06 14:49:12 +01:00
Rossen Stoyanchev 7a5f8e03bc Refine check for multiple subscribers
Commit #c187cb2 introduced proactive rejection of multiple subscribers
in ReactorClientHttpResponse, instead of hanging indefinitely as per
https://github.com/reactor/reactor-netty/issues/503.

However FluxReceive also rejects subsequent subscribers if the response
is consumed fully, as opposed to being canceled, e.g. as with
bodyToMono(Void.class). In that case, a subsequent subscriber causes
two competing error signals to be sent, and one gets dropped and
logged by reactor-core.

This fix ensures that a rejection is raised in
ReactorClientHttpResponse only after a cancel() was detected.

Issue: SPR-17564
2018-12-04 21:27:37 -05:00
Juergen Hoeller 9efea7eb73 MockHttpServletRequest preserves original Accept-Language header value
Issue: SPR-17566
2018-12-04 22:07:43 +01:00
Juergen Hoeller 6d7827e36b Polishing 2018-12-03 23:53:00 +01:00
Francesco Komauli 66f822e600 Fix typo in Javadoc for UnsupportedMediaTypeStatusException
Response status 415 (unsupported media type) reported as of 416 (which is Range Not Satisfiable), mismatching with superclass constructor parameter HttpStatus.UNSUPPORTED_MEDIA_TYPE
2018-11-29 16:36:56 +01:00
Juergen Hoeller 97ac1c22c5 DefaultResponseErrorHandler makes use of HttpStatus.isError()
Issue: SPR-17439
2018-11-23 19:27:47 +01:00
Sebastien Deleuze 91de8d265e Fix ProtobufDecoder handling of split message size
This commit introduces a new readMessageSize(DataBuffer input) private
method, inspired from CodedInputStream#readRawVarint32(int, InputStream)
and adapted for DataBuffer using MessageDecoderFunction fields in
order to support use cases where the message size is split between
distinct chunks.

It also fixes handling of end of streams by using
DataBuffer#readableByteCount instead of -1 which is only relevant with
InputStream.

Issue: SPR-17429
2018-11-23 14:22:58 +01:00
Juergen Hoeller 77ab88b144 Polishing 2018-11-23 13:56:02 +01:00
Juergen Hoeller 738097def2 DefaultResponseErrorHandler detects non-standard error code as well
Issue: SPR-17439
2018-11-23 13:55:50 +01:00
Juergen Hoeller c16f36b537 Upgrade to Mockito 2.23.4, Selenium 3.141.59, JSON-P 1.1.4 2018-11-22 18:24:18 +01:00
Juergen Hoeller ae8f680d2e Polishing 2018-11-22 18:21:56 +01:00
Rossen Stoyanchev 7e9857a663 ForwardedHeaderTransformer handles encoding correctly
Issue: SPR-17525
2018-11-21 10:54:39 -05:00
Arjen Poutsma f3c29fe2e6 Add test for UriUtils.encode(String, Charset)
Issue: SPR-17451
2018-11-20 10:51:19 +01:00
Rossen Stoyanchev abf9ce8a34 Improve handling of empty response with Mono<T>
Issue: SPR-17560
2018-11-19 16:48:38 -05:00
Brian Clozel 3203d39821 Remove Content-Length response header from errors
Prior to this commit, when errors happened before the response was
committed, the `Content-Length` response header would be left as is.
This can be problematic since the error can be handled later in the
chain and the response body changed accordingly. For example, Spring
Boot renders error pages in those cases. If the `Content-Length` is set,
HTTP clients can get confused and only consider part of the error
response body.

This commit ensures that any `Content-Length` response header is removed
in case of errors, if the response is not already committed.

This is done at the `AbstractServerHttpResponse` level, since errors can
be handled in multiple places and the response itself is the safest
place to handle this case.

As a consequence, this commit also removes `Content-Length` checks in
`EncoderHttpMessageWriter` since we now consider that we should rely on
the response body we're about to write rather than any previously set
value.

Issue: SPR-17502
2018-11-19 15:49:54 +01:00
Juergen Hoeller ce5c65c0b0 Upgrade to JAXB 2.3.1, Groovy 2.5.4, Jetty 9.4.14, Tomcat 9.0.13
Includes JAX-WS 2.3.1, Awaitility 3.1.3, OkHttp 3.12, Woodstox 5.2.
2018-11-19 12:41:26 +01:00
Stephane Nicoll 7b6f2f8fb3 Polish contribution
Closes gh-2019
2018-11-19 08:45:33 +01:00
Hanope bfb49c7249 Fix typos
See gh-2019
2018-11-19 08:41:21 +01:00
HeemangHan 729ce4108d Correct typos (#2018) 2018-11-17 16:31:01 +01:00
Rossen Stoyanchev 1a37345e84 Fix checkstyle violation and polish 2018-11-16 19:42:42 -05:00
Arjen Poutsma 539cfc24c6 Refactor AbstractEncoderTestCase
Refactor AbstractEncoderTestCase to resemble AbstractDecoderTestCase

Issue: SPR-17449
2018-11-16 14:33:26 +01:00
Arjen Poutsma 39ce989d1a Add and use AbstractDecoderTestCase
Introduce new base test case for decoder tests, and use it.

Issue: SPR-17449
2018-11-16 14:33:26 +01:00
Rossen Stoyanchev ba3fef3e8a Refactor media types parsing improvements
Issue: SPR-17459
2018-11-13 23:02:09 -05:00
Dimitrios Liapis f4b05dc2e7 MediaType parsing supports comma inside quotes
Issue: SPR-17459
2018-11-13 16:59:57 -05:00
Rossen Stoyanchev 46a5fb7a91 Configurable Marshaller/Unmarshaller in JAXB2 codecs
Issue: SPR-17388
2018-11-13 16:56:56 -05:00
Juergen Hoeller 093254b2b3 Jackson2ObjectMapperBuilder stores visibility declarations in order
Issue: SPR-17489
2018-11-13 21:17:55 +01:00
Rossen Stoyanchev 75b1396768 Fall back on default server response status code
Update the ServerHttpRespnose contract to indicate that server specific
sub-classes should fall back on the default status, if a status code
has not been set explicitly.

Issue: SPR-17368
2018-11-13 14:10:48 -05:00
Arjen Poutsma 445b76bbe8 Polishing 2018-11-13 13:35:37 +01:00
Arjen Poutsma 3bab3515b1 Add and use AbstractEncoderTestCase
Introduce new base test case for encoder tests, and use it.

Issue: SPR-17449
2018-11-13 13:35:37 +01:00
Juergen Hoeller 40148c0560 Consistent use of ResolvableType.toClass() for assignability checks
Issue: SPR-17086
2018-11-12 20:29:37 +01:00
Juergen Hoeller 3a66927bd2 Polishing 2018-11-12 16:43:43 +01:00
Juergen Hoeller c58da71006 Synthesize parameter annotations from interface methods as well
Issue: SPR-17460
2018-11-12 16:23:14 +01:00
Rossen Stoyanchev e4c84ec757 Consistent default encoding in DefaultUriBuilderFactory
Issue: SPR-17465
2018-11-09 14:13:51 -05:00
Rossen Stoyanchev c187cb2fa1 Ensure client response is drained with onStatus hook
Issue: SPR-17473
2018-11-08 22:41:22 -05:00
Rossen Stoyanchev ed1d63dcc3 ResolvableMethod copy in spring-messaging src/test 2018-11-08 13:29:21 -05:00
Juergen Hoeller e71ff2901a Polishing 2018-11-05 22:59:33 +01:00
Juergen Hoeller 5e7a8b275d Polishing 2018-11-05 19:33:24 +01:00
Juergen Hoeller f65408f646 Avoid references to groovy-all artifact across all modules
Issue: SPR-17446
2018-11-05 12:27:07 +01:00
Rossen Stoyanchev 48654c6483 Polish 2018-11-01 14:21:00 -04:00
Rossen Stoyanchev 3f42e16172 Increase sharing among InvocableHandlerMethod variants
In particular between reactive and non-reactive web variants, but
also preparing for a messaing reactive variant.
2018-10-30 17:15:09 -04:00
Rossen Stoyanchev 7c36549e3a Consistent InvocableHandlerMethod implementations
This commit makes the 3 existing InvocableHandlerMethod types more
consistent and comparable with each other.

1. Use of consistent method names and method order.

2. Consistent error formatting.

3. Explicit for loops for resolving argument values in webflux variant
because that makes it more readable, creates less garabage, and it's
the only way to bring consistency since the other two variants cannot
throw exceptions inside Optional lambdas (vs webflux variant which can
wrap it in a Mono).

4. Use package private HandlerMethodArgumentComposite in webflux
variant in order to pick up the resolver argument caching that the
other two variants have.

5. Polish tests.

6. Add missing tests for messaging variant.
2018-10-30 16:36:01 -04:00
Arjen Poutsma e68bf010da Fix memory leak for ServerSentEventHttpMessageWriter
Issue: SPR-17419
2018-10-26 11:36:05 +02:00
Juergen Hoeller 67bd3f670f Upgrade to AspectJ 1.9.2, Rome 1.11.1, OpenPDF 1.2.5, POI 4.0 2018-10-25 15:15:47 +02:00
Arjen Poutsma 95542778ad Fix MultipartHttpMessageWriterTests
Issue: SPR-17419
2018-10-25 12:13:03 +02:00
Arjen Poutsma 7a8a2d9608 Fix HttpMessageWriter tests
Issue: SPR-17419
2018-10-25 12:13:03 +02:00
Arjen Poutsma 256a6fe6cb Fix memory leak for ServerSentEventHttpMessageWriter
This commit fixes a memory leak in ServerSentEventHttpMessageWriter
that occurs when the input stream contains an error. Test added as well.

Issue: SPR-17419
2018-10-25 12:13:03 +02:00
Juergen Hoeller ffa032e78f Polishing 2018-10-24 20:46:26 +02:00
Juergen Hoeller f0f1979fc5 Support for @RequestParam Map declared with MultipartFile/Part values
Issue: SPR-17405
2018-10-24 20:44:58 +02:00
Arjen Poutsma 611019b73c Fix memory leak for Jaxb2XmlEncoder
This commit fixes a memory leak in Jaxb2XmlEncoder that occurs when
the input stream contains an error. Test added as well.

Issue: SPR-17419
2018-10-24 16:28:21 +02:00
Arjen Poutsma 11a017d8b7 Add error stream tests for ProtobufEncoderTests
Issue: SPR-17419
2018-10-24 16:28:21 +02:00
Rossen Stoyanchev 2439f87a48 Add onDiscard hook to Jetty client request
The flatMap operation in writeAndFlushWith could buffer internally.

Issue: SPR-17424
2018-10-23 21:41:27 -04:00
Rossen Stoyanchev 2ba5ded306 Polish Jetty reactive HttpClient connector 2018-10-23 21:34:42 -04:00
Rossen Stoyanchev feeec344e5 ForwardedHeaderFilter works with Servlet FORWARD
Issue: SPR-16983
2018-10-23 11:53:46 -04:00
Rossen Stoyanchev 41e6aa6de2 Restore log level for resolved exceptions
The fix for SPR-17178 switched from debug to warn level warning for
all sub-classes of AbstractHandlerExceptionResolver where the request
concerned the DefaultHandlerExceptionResolver only.

This commit restores the original DEBUG level logging that was in
AbstractHandlerExceptionResolver from before SPR-17178. In addition
DefaultHandlerExceptionResolver registers a warnLogCategory by default
which enables warn logging and hence fulfilling the original goal
for SPR-17178.

Issue: SPR-17383
2018-10-22 12:13:18 -04:00
Arjen Poutsma 0176d362be Add error stream tests for Jackson2JsonDecoder
Issue: SPR-17418
2018-10-22 16:00:32 +02:00
Arjen Poutsma 946ec7e22e Fix memory leaks in ProtobufDecoder
Issue: SPR-17418
2018-10-22 16:00:32 +02:00
Arjen Poutsma 47fe05066d Add error stream tests for Jaxb2XmlDecoderTests
Issue: SPR-17418
2018-10-22 16:00:32 +02:00
Arjen Poutsma a37efc9881 Add error stream tests for XmlEventDecoder
Issue: SPR-17418
2018-10-22 16:00:32 +02:00
Brian Clozel 85262a7932 Fix Map.put contract for HeadersAdapter impl.
This commit fixes the `Map.put` contract for both Reactor Netty and
Tomcat specific `HeadersAdapter` implementations.

Issue: SPR-17415
2018-10-22 14:53:14 +02:00
Rossen Stoyanchev 862dd23975 Server adapters release buffers on error/cancel
Review and update Servlet and Undertow adapters to release any data
buffers they be holding on to at the time of error or cancellation.

Also remove onDiscard hooks from Reactor and Undertow request body.
For Reactor we expect it to be handled. For Undertow there isn't
any Reactor Core upstream for the callback to be useful.

Issue: SPR-17410
2018-10-19 21:45:14 -04:00
Juergen Hoeller 5b5f7190bf Declare InvocableHandlerMethod.getMethodArgumentValues as protected
Issue: SPR-17404
2018-10-18 18:05:07 +02:00
Arjen Poutsma 6f0c869afe Polishing 2018-10-18 17:16:34 +02:00
Arjen Poutsma 857b600675 Fix memory leak in AbstractJackson2Encoder
Fixes a DataBuffer memory leak where a created buffer was not release
if Jackson threw an exception.
2018-10-18 17:09:53 +02:00
Brian Clozel ab8310b5f3 Fix HeadersAdapters implementations
This commit harmonizes the `HeadersAdapter` implementations across all
supported servers with regards to the `get(Object key)` contract; some
server implementations are not sticking to a `Map`-like contract and
return empty `List` instead of `null` when a header is not present.

This also fixes the `size()` implementations to reflect the number of
header keys, as some implementations consider multiple values for the
same header as different entries.

Issue: SPR-17396
2018-10-18 11:18:29 +02:00
Rossen Stoyanchev fdaceeb6c9 Remove checks and updates to transfer-encoding
Issue: SPR-17393
2018-10-16 16:49:46 -04:00
Rossen Stoyanchev 423aa28ed5 HttpRange validates requested ranges
Issue: SPR-17318
2018-10-14 22:49:25 -04:00
Juergen Hoeller 608fd766cb Upgrade to Checkstyle 8.13, Groovy 2.5.3, Aalto XML 1.1.1 2018-10-15 00:01:45 +02:00
Juergen Hoeller 58b3af9475 Nullability fine-tuning and related polishing
Issue: SPR-17250
2018-10-14 23:29:46 +02:00
Juergen Hoeller bfc5ad890e MockHttpServletRequest resets InputStream/Reader on setContent
Issue: SPR-17373
2018-10-12 16:00:31 +02:00
陈灵敏 4ee704cedf Supplier for timeout result in DeferredResult
Issue: SPR-17364
2018-10-11 20:26:01 -04:00
Brian Clozel 10d5de7d63 Handle special headers in Tomcat and Jetty
This commit adds special processing of some HTTP response headers in
Jetty and Tomcat; they both consider some headers like  "Content-Length"
as specific and require explicit calls on the `HttpServletResponse`
itself on top of setting the HTTP response header.

Issue: SPR-17250
2018-10-11 14:37:14 +02:00
Brian Clozel f12c28e402 Avoid copying in DefaultServerHttpRequestBuilder
This commit avoids copying HTTP headers when mutating an HTTP request.
Instead, we're now unwrapping the `ReadOnlyHttpHeaders` (which is most
likely backed by the native request headers).

Issue: SPR-17250
2018-10-11 12:11:47 +02:00
Brian Clozel ce7278aaf4 Optimize HTTP headers management
Several benchmarks underlined a few hotspots for CPU and GC pressure in
the Spring Framework codebase:

1. `org.springframework.util.MimeType.<init>(String, String, Map)`
2. `org.springframework.util.LinkedCaseInsensitiveMap.convertKey(String)`

Both are linked with HTTP request headers parsing and response headers
writin during the exchange processing phase.

1) is linked to repeated calls to `HttpHeaders.getContentType`
within a single request handling. The media type parsing operation
is expensive and the result doesn't change between calls, since
the request headers are immutable at that point.

This commit improves this by caching the parsed `MediaType` for the
`"Content-Type"` request header in the `ReadOnlyHttpHeaders` class.
This change is available for both Spring MVC and Spring WebFlux.

2) is linked to insertions/lookups in the `LinkedCaseInsensitiveMap`,
which is the data structure behind `HttpHeaders`.
Those operations are creating a lot of garbage (including a lot of
`String` created by `toLowerCase`). We could choose a more efficient
data structure for storing HTTP headers data.

As a first step, this commit is focusing on Spring WebFlux and
introduces `MultiValueMap` implementations mapped by native HTTP headers
for the following servers: Tomcat, Jetty, Netty and Undertow.
Such implementations avoid unnecessary copying of the headers
and leverages as much as possible optimized operations provided by the
native implementations.

This change has a few consequences:

* `HttpHeaders` can now wrap a `MultiValueMap` directly
* The default constructor of `HttpHeaders` is still backed by a
`LinkedCaseInsensitiveMap`
* The HTTP request headers for the websocket HTTP handshake now need to
be cloned, because native headers are likely to be pooled/recycled by
the server implementation, hence gone when the initial HTTP exchange is
done

Issue: SPR-17250
2018-10-11 12:11:47 +02:00
Juergen Hoeller e18149878c Upgrade to Mockito 2.23
Includes JSON-P 1.1.3.
2018-10-10 23:53:33 +02:00
Rossen Stoyanchev d05924165b Refactor FilterWebHandler and DefaultWebFilterChain
The chain is initialized once and re-used vs creating the "next" chains
on every request.
2018-10-10 14:33:51 -04:00
Juergen Hoeller 2b986af310 BasicAuthenticationInterceptor with HttpHeaders.setBasicAuth alignment
Issue: SPR-17326
2018-10-09 23:13:46 +02:00
Juergen Hoeller efdbddd358 Full alignment of spring-test vs spring-web MockCookie variants
Issue: SPR-17321
2018-10-09 23:13:18 +02:00
Rossen Stoyanchev 1489457025 Restore calls to setLocale in MockHttpServletResponse
Issue: SPR-17284
2018-10-05 13:50:41 -04:00
Rossen Stoyanchev 9064ef59f9 Workaround for Synchronoss content-length limitation
Issue: SPR-17345
2018-10-05 12:12:49 -04:00
Sebastien Deleuze 3ff5731429 Leverage ObjectProvider instead of autowired containers
In order to be able to leverage WebFlux configuration in a functional
way, WebHttpHandlerBuilder and RouterFunctionMapping should leverage
new ObjectProvider capabilities to get a sorted list of beans by type
instead of using autowired containers.

Issue: SPR-17327
2018-10-03 14:14:47 +02:00
Rossen Stoyanchev 7aa933437c Update links to http://java.net/jira 2018-10-01 12:01:28 -04:00
Juergen Hoeller 255015fc6b Prepared for backport to 4.3.20 and 5.0.10
Issue: SPR-17295
2018-09-29 17:08:57 +02:00
Juergen Hoeller a76b8deda5 Consistent copyright header and fine-tuned javadoc in test/web mocks
Issue: SPR-17295
2018-09-24 00:27:50 +02:00
Stephane Nicoll 7ca6b9f7d2 Fix copyright header 2018-09-23 17:26:40 +02:00
Juergen Hoeller 51ba322947 MockHttpServletRequest allows for removing registered header values
Includes full alignment of spring-test vs spring-web mock variants.

Issue: SPR-17295
2018-09-23 14:44:15 +02:00
Juergen Hoeller 80e52de231 Upgrade to HtmlUnit 2.33 and Apache Johnzon 1.1.10 2018-09-20 11:55:50 +02:00
Arjen Poutsma 8a4835368d Use doOnDiscard to free internally queued data buffers
Issue: SPR-17246
2018-09-19 13:24:45 +02:00
Brian Clozel d94e9225f4 Switch to Reactor Californium SNAPSHOTs 2018-09-18 18:50:37 +02:00
Juergen Hoeller 51f7a3e40f Polishing 2018-09-17 14:26:56 +02:00
Juergen Hoeller 34663300a6 Avoid regex pattern matching for simple String replacement steps
Issue: SPR-17279
2018-09-17 14:22:19 +02:00
Rossen Stoyanchev db8e9eafb2 Add LogFormatUtils
1. Helper method to eliminate duplication in formatting (de-)serialized
   values for logging introduced with prior commit #e62298.

2. Helper method for TRACE vs DEBUG logging with different details.

Issue: SPR-17254
2018-09-14 18:06:46 -04:00
Rossen Stoyanchev 12240c7524 Apply formatValue to a few remaining places
Issue: SPR-17254
2018-09-14 12:37:00 -04:00
Rossen Stoyanchev e62298eaad Truncate logged encoded and decoded values if necessary
At DEBUG show up to 100 chars, at TRACE show full formatted value.

Note that the formatValue helper method is duplicated a number of times
in this commit. A utility method will likely be added in spring-core
through an extra commit.

Issue: SPR-17254
2018-09-14 12:20:03 -04:00
Juergen Hoeller 66c66baa8f Upgrade to Rhino 1.7.10
Includes reordering of web dependency declarations.
2018-09-14 14:03:53 +02:00
Arjen Poutsma 09af706af6 Use concatWith instead of mergeWith 2018-09-11 13:36:44 +02:00
Juergen Hoeller e47355078c Correct linkplain javadoc in BufferingClientHttpRequestFactory
Issue: SPR-17261
2018-09-10 12:36:40 +02:00
Juergen Hoeller 28208310dc Unit test with assertion for merged query params
Issue: SPR-17256
2018-09-10 12:36:07 +02:00
Juergen Hoeller c06b9525ac UriComponentsBuilder copies query params through MultiValueMap.addAll
Issue: SPR-17256
2018-09-10 11:31:37 +02:00
Juergen Hoeller e49896d95f Upgrade to Mockito 2.22, XMLUnit 2.6.2, JavaMail 1.6.2
Also includes Apache Johnzon 1.1.9.
2018-09-10 10:52:24 +02:00
Juergen Hoeller 90a4740279 Polishing 2018-09-07 12:56:53 +02:00
Rossen Stoyanchev f30d19b724 Disable Jackson's buffer recyling feature for WebFlux
Issue: SPR-17193
2018-09-06 16:20:03 -04:00
Rossen Stoyanchev 2163fa94a7 Fix initialization issue in ReactorResourceFactory
Follow-up on recent commit #d537a1c.

Issue: SPR-17243
2018-09-06 15:16:01 -04:00
Rossen Stoyanchev d537a1cfb4 Refine ReactorResourceFactory
1. Rename globalResources to useGlobalResources.
2. Use of global resources is mutually exlusive with explicit config.
3. Allow Consumer<HttpResources> to configure global resources.
4. Allow ConnectionProvider + LoopResources Supplier to customize
   creation and initialization.
5. Do not manage externally provided ConnectionProvider + LoopResources
   instances.

Issue: SPR-17243
2018-09-05 21:17:04 -04:00
Arjen Poutsma 259b2ca5f4 Added tests for errors in the source stream
This commit adds decoder/message-reader tests for errors in
the source data buffer publisher. Because the tests extend
AbstractDataBufferAllocatingTestCase, they also check whether
the buffers that precede the error in the stream are properly
released.

Issue: SPR-17025
2018-09-05 11:08:07 +02:00
Brian Clozel 1bdbc7bdef Optimize for Flux to/from Mono conversions
This commit optimizes Flux <-> Mono conversions in our codebase by
avoiding to hide that conversion from Reactor.

This tries to keep conversions sequentially so that they can be detected
by Reactor and optimized. In Spring WebFlux, this means keeping the
conversions at the edges of a method implementation (right when getting
an input parameter, and before returning it as a result). If those
conversions are made between other operators, Reactor might not be able
to detect those conversions and optimize them.

Issue: SPR-17203
2018-09-04 16:42:46 +02:00
Brian Clozel 280da61d5c Fix empty body writing in EncoderHttpMessageWriter
Prior to this commit, an bug introduced in SPR-16949 prevented
`Mono.empty` bodies from being written to the response.

This commit ensures that empty bodies still trigger the writing to the
response and does not hang the processing of the exchange.

Issue: SPR-17220
2018-08-27 21:17:10 +02:00
Juergen Hoeller 03f1920106 Support Jackson filters in combination with serialization view
Issue: SPR-17209
2018-08-24 12:06:52 +02:00
Sam Brannen 2bb15f7ed2 Fix grammar in JavaDoc for fully qualified links
This commit represents a best effort attempt at fixing remaining
"a" vs. "an" grammatical errors related links specified via a fully
qualified class name.

Issue: SPR-17208
2018-08-23 17:59:44 +02:00
Brian Clozel 709b185177 Clear global resources reference from HttpResources
When used as global Netty resources, ReactorResourceFactory creates and
sets those resources on Reactor's HttpResources directly.

When that ReactorResourceFactory bean is destroyed, those resources are
disposed but HttpResources still holds a reference to those and may try
to use them again.

This commit uses HttpResources to clear those resources and its
references to it, when the ReactorResourceFactory is treating those as
global.

Issue: SPR-17199
2018-08-21 16:16:28 +02:00
Sam Brannen a8fbac8472 Polish JavaDoc
Issue: SPR-17174
2018-08-18 18:15:05 +02:00
Juergen Hoeller a6a6cf7d97 Upgrade to Java Activation Framework 1.2 as API dependency
Includes XMLUnit 2.6.1 and Undertow 2.0.13.

Issue: SPR-16115
2018-08-17 16:01:15 +02:00
Sebastien Deleuze 0dd9e8ce02 Polish JettyResourceFactory
Issue: SPR-17179
2018-08-16 21:47:02 +02:00
Juergen Hoeller 6bcb454a0d Polishing 2018-08-16 19:31:10 +02:00
Juergen Hoeller 84300b796c Fix recent javadoc errors
Issue: SPR-17174
2018-08-16 18:51:31 +02:00
Sebastien Deleuze 1eb06fcd90 Introduce JettyResourceFactory
JettyResourceFactory, similar to ReactorResourceFactory, allows
to share resources (Executor, ByteBufferPool, Scheduler) between
Jetty clients and servers.

Issue: SPR-17179
2018-08-16 18:17:07 +02:00
Juergen Hoeller 2ec8fa9cac SmartLifecycle default methods for auto-startup in default phase
Issue: SPR-17188
2018-08-16 12:08:02 +02:00
Brian Clozel cd403f4180 Polish 2018-08-15 20:56:27 +02:00
Brian Clozel 23fc6f6b1d Drain JDK HTTP client response body in all cases
Prior to this commit, when using the `SimpleClientHttpRequestFactory`
as a driver for `RestTemplate`, the HTTP response body would only be
drained if there was an attempt to read it in the first place.

This commit ensures that, even if there's no attempt at reading the
response body, it is properly drained when the response is closed to
make sure that the connection is released in a proper state and can be
put back in the connection pool for reuse.

Issue: SPR-17181
2018-08-15 20:52:40 +02:00
Brian Clozel 432cdd7802 Add ResponseEntity.of(Optional) variant
When dealing with `Optional` values in a Controller handler (for
example, values coming from a Spring Data repository), developers might
reuse this code snippet quite often:

```
@GetMapping("/user")
public ResponseEntity<Optional<User>> fetchUser() {
  Optional<User> user = //...
  return user.map(ResponseEntity::ok).orElse(notFound().build());
}
```

This commit adds a new static method on `ResponseEntity` for that,
simplifying the previous snippet with `return ResponseEntity.of(user);`

Note that in case more specific HTTP response headers are required by
the application, developers should use other static methods to
explicitly tell  which headers should be used in each case.

Issue: SPR-17187
2018-08-15 20:24:14 +02:00
Rossen Stoyanchev 04141dee65 Consistent logging of resolved exceptions
Issue: SPR-17178
2018-08-15 10:57:51 +03:00
Juergen Hoeller 6027cf2255 Polishing 2018-08-14 20:42:40 +02:00
Rossen Stoyanchev 3e4d305291 Polish ReactorResourceFactory 2018-08-14 17:34:17 +03:00
Rossen Stoyanchev 7a0c03e05e Update section in reference on WebClient
Rename "Builder" sub-section to "Configuration" and move it in the
beginning before all others since it explains how to create a client
in the first place.

Update content on Reactor Netty connector based on the API in 0.8 and
specifically address Reactor Netty resources and lifecycle.

Issue: SPR-16963
2018-08-14 15:48:46 +03:00
Rossen Stoyanchev 2f732a8dea Fix checkstyle errors 2018-08-14 13:01:09 +03:00
Rossen Stoyanchev 1bc08c61e1 Add ReactorResourceFactory
Issue: SPR-16963
2018-08-14 12:29:31 +03:00
Sam Brannen 8126ffbc8c Fix broken links in JavaDoc
Issue: SPR-17174
2018-08-13 12:22:52 +02:00
Sam Brannen 1dcb6236a6 Fix broken links in JavaDoc
First step (as proof of concept) toward addressing SPR-17174.

Issue: SPR-17174
2018-08-13 11:54:05 +02:00
Rossen Stoyanchev 99f0129711 Fix URI var encoding issue with '$'
When expanding and strictly encoding URI variables, there is no need to
quote `/` and `$` which will be encoded anyway.

Issue: SPR-17168
2018-08-13 11:56:34 +03:00
Sam Brannen cfb1ed1009 Clean up warnings and delete dead code 2018-08-12 15:55:11 +02:00
Sebastien Deleuze 6b6384a09e Improve WebFlux Protobuf support
- Update javadoc for decoding default instances
 - Refactor and simplify tests
 - Add missing tests
 - Refactor decoding with flatMapIterable instead of
   concatMap and avoid recursive call

Issue: SPR-15776
2018-08-09 15:47:45 +02:00
Juergen Hoeller 247ec572b2 Consistent hasAnnotation check for findMergedAnnotation lookup
Issue: SPR-16933
2018-08-08 23:54:56 +02:00
Sebastien Deleuze 1c628293a2 Add doc & tests to Jaxb2XmlEncoder for collections
Issue: SPR-16363
2018-08-08 17:16:23 +02:00
Rossen Stoyanchev eacf1d35ee Proper use of setComplete in ContextPathCompositeHandler
Issue: SPR-17144
2018-08-08 16:35:47 +03:00
Rossen Stoyanchev c90ab5fb0a Polish Http[Client|Server]ErrorException hierarchy 2018-08-08 15:34:08 +03:00
Kazuhiro Sera be211ceead Fix typos detected by github.com/client9/misspell 2018-08-08 12:50:46 +02:00
Sebastien Deleuze 896eb5687a Check scheme in (WebUtils|CorsUtils)#isSameOrigin
Issue: SPR-16362
2018-08-08 12:19:42 +02:00
Juergen Hoeller 2b051b8b32 Deprecate support classes for Sun's JDK HTTP server
Issue: SPR-17143
2018-08-07 20:35:53 +02:00
Juergen Hoeller a4c750e94c Upgrade to OpenPDF 1.2 and Apache HttpAsyncClient 4.1.4 2018-08-07 11:24:20 +02:00
Rossen Stoyanchev 4a18488f30 Update deprecated basic auth client filters.
1. Update ExchangeFilterFunctions to delegate internally to
HttpHeaders.setBasicAuth(user, password).

2. Remove deprecation from
ExchangeFilterFunctions.basicAuthentication(String user, String password)
It is still useful as a filter to insert the header.

3. Update deprecation notes.

Issue: SPR-17099
2018-08-07 10:10:27 +03:00
Juergen Hoeller 943b394992 Polishing 2018-08-06 18:34:00 +02:00
Rossen Stoyanchev a9a38fe67e Consistent initialiazation of Forwarded header set 2018-08-06 14:32:18 +03:00
Rossen Stoyanchev 2216964b54 Polish RestTemplate exception hierarchy
Issue: SPR-15404
2018-08-06 14:29:10 +03:00
jerzykrlk 7f0e3481a5 Fine-grained RestTemplate exception hierarchy
Issue: SPR-15404
2018-08-06 14:29:10 +03:00
Sebastien Deleuze 2054fa2191 Upgrade to Jetty reactive HTTP client 1.0.1
Issue: SPR-17124
2018-08-06 12:01:29 +02:00
Juergen Hoeller 821ab62492 Upgrade to RxJava 2.2 and Kotlin 1.2.60
Includes latest dependency updates (Mockito 2.21, Log4J 2.11.1, Hibernate ORM 5.3.4, Protobuf 3.6.1, JRuby 9.2, HtmlUnit 2.32, Selenium 3.14) for Spring Framework 5.1.

Issue: SPR-16388
Issue: SPR-16239
2018-08-03 23:18:10 +02:00
Rossen Stoyanchev c55c9eb029 Polish 2018-08-03 17:41:38 +03:00
Vedran Pavic bb2db87c2f Add support for adding cookies as headers in MockHttpServletResponse
Issue: SPR-17110
2018-08-03 16:44:14 +03:00
Rossen Stoyanchev a8a1fc6de5 Earlier processing of forwarded headers
Forwarded headers are now processed before ServerWebExchange is created
through ForwardedHeaderTransformer which has the same logic as the
ForwardedHeaderFilter but works on the request only.

ForwardedHeaderFilter is deprecated as of 5.1 but if registered it is
removed from the list of filters and ForwardedHeaderTransformer is used
instead.

Issue: SPR-17072
2018-08-03 15:16:09 +03:00
Juergen Hoeller 217aa38cbb Polishing 2018-08-02 18:00:42 +02:00
Juergen Hoeller 2474c48749 Polishing 2018-08-02 16:55:53 +02:00
stsypanov b5c691bdac SPR-17074 Replace pointless wrapping with Arrays.asList with iteration over array 2018-08-02 12:07:00 +02:00
Juergen Hoeller 78eda961f2 Polishing 2018-08-01 13:11:35 +02:00
Vedran Pavic 70dbaf9751 Publish binding event for replaced attributes in MockHttpSession
Issue: SPR-17109
2018-08-01 13:07:41 +02:00
Juergen Hoeller 92eaf99067 Polishing 2018-07-31 21:04:36 +02:00
Сергей Цыпанов f8340838b3 Use lambda expressions for lazy instantiation (#1911)
Issue: SPR-17074
2018-07-31 13:03:18 +02:00
Juergen Hoeller 4a147d26fc Initialize pre-filled HashMaps with large enough capacity
Empty Maps are preferably initialized without capacity (not initializing them at all or lazily initializing with default capacity when needed).

Issue: SPR-17105
2018-07-30 22:07:31 +02:00
stsypanov 457d586859 SPR-17074 pass argument of addAll/putAll into constructor 2018-07-30 21:27:55 +02:00
Pascal Schumacher aa656c47b8 Fix typo in notes on future deprecation of the RestTemplate
Issue: SPR-16993

Obvious Fix
2018-07-27 14:13:19 -04:00
Rossen Stoyanchev 91d17cf628 Add notes on future deprecation of the RestTemplate
Issue: SPR-16993
2018-07-27 08:41:20 -04:00
Rossen Stoyanchev bcb485b5ed bindToApplicatonContext uses WebSessionManager bean
Issue: SPR-17094
2018-07-26 15:53:41 -04:00
Rossen Stoyanchev 14d0fee86c Improve context-related logging on web startup
Sample output at TRACE:
```
DispatcherServlet - Initializing Servlet 'org.springframework.web.servlet.DispatcherServlet-7a8c8dcf'
AnnotationConfigWebApplicationContext - Refreshing WebApplicationContext for namespace 'org.springframework.web.servlet.DispatcherServlet-7a8c8dcf-servlet', started on Wed Jul 25 17:46:38 EDT 2018
AnnotationConfigWebApplicationContext - Registering [org.springframework.web.servlet.mvc.method.annotation.RequestPartIntegrationTests$CommonsMultipartResolverTestConfig]
AnnotationConfigWebApplicationContext - No 'messageSource' bean, using [Empty MessageSource]
AnnotationConfigWebApplicationContext - No 'applicationEventMulticaster' bean, using [SimpleApplicationEventMulticaster]
AnnotationConfigWebApplicationContext - No 'lifecycleProcessor' bean, using [DefaultLifecycleProcessor]
...
DispatcherServlet - Initialization completed in 3361 ms
```

Issue: SPR-16946
2018-07-25 17:50:03 -04:00
Juergen Hoeller 2b2bf27933 Polishing 2018-07-25 15:26:52 +02:00
Juergen Hoeller 3881a4aded Polishing 2018-07-25 14:16:02 +02:00
Juergen Hoeller 3899b7a909 Refactor DefaultCodecs.protobufWriter into protobufEncoder
Includes nullability declarations for the protobuf package.

Issue: SPR-15776
2018-07-25 14:15:50 +02:00
Juergen Hoeller fd8e4abe5d Introduce ResolvableType.toClass() shortcut
Issue: SPR-17086
2018-07-25 14:15:19 +02:00
Sebastien Deleuze d3b244a81b Optimize class detection by sharing the ClassLoader
Issue: SPR-17083
2018-07-25 11:09:42 +02:00
sdeleuze 36a07aa897 Support Protobuf serialization in WebFlux
This commit introduces Protobuf support in WebFlux via dedicated
codecs.

Flux<Message> are serialized/deserialized using delimited Protobuf
messages with the size of each message specified before the message
itself. In that case, a "delimited=true" parameter is added to the
content type.

Mono<Message> are expected to use regular Protobuf message
format (without the size prepended before the message).

Related HttpMessageReader/Writer are automatically registered when the
"com.google.protobuf:protobuf-java" library is detected in the classpath,
and can be customized easily if needed via CodecConfigurer, for example
to specify protocol extensions via the ExtensionRegistry based
constructors.

Both "application/x-protobuf" and "application/octet-stream" mime types
are supported.

Issue: SPR-15776
2018-07-25 01:17:06 +02:00
Juergen Hoeller 4475c67ba8 Fix checkstyle violation 2018-07-24 22:44:54 +02:00
Rossen Stoyanchev 2e4f5a7923 Consistently remove forwarded headers in WebFlux
Preparation for SPR-17072
2018-07-24 16:05:47 -04:00
Rossen Stoyanchev 41aa4218af Polish WebFlux ForwardedHeaderFilter and tests
Preparation for SPR-17072
2018-07-24 16:05:47 -04:00
Sebastien Deleuze 36bbbab02d Deprecate ExtensionRegistryInitializer in protobuf support
In order to be consistent with SPR-15776, and since it does not
provide clear added value, this commit deprecates
ExtensionRegistryInitializer and uses ExtensionRegistry
parameter instead in ProtobufHttpMessageConverter and
ProtobufJsonFormatHttpMessageConverter constructors.

Issue: SPR-17081
2018-07-24 17:25:55 +02:00
Juergen Hoeller 47d8fe83df Upgrade to Interceptor API 1.2.2, Moneta 1.3, Rome 1.11 2018-07-24 14:44:56 +02:00
Juergen Hoeller fac2e35f96 Refactor util.log.LogUtils into core.log.LogDelegateFactory
Issue: SPR-17012
2018-07-24 14:44:34 +02:00
Juergen Hoeller 1b09718104 Polishing 2018-07-24 00:45:21 +02:00
Vedran Pavic 82194f4ee0 Set SameSite default to Lax
Issue: SPR-16418
2018-07-23 18:23:05 +02:00
Sebastien Deleuze b09fad13a1 Catch errors when adding SourceHttpMessageConverter
This commit ignores errors like TransformerFactoryConfigurationError
that can be thrown when instantiating SourceHttpMessageConverter on
platforms where no TransformerFactory implementation is available,
like when compiling/running as GraalVM native images.

Issue: SPR-17007
2018-07-23 10:39:26 +02:00
Brian Clozel 390bb871d8 Switch order of multipart Content-Type directives
Since SPR-15205, the `FormHttpMessageConverter` is adding a `charset`
directive to the `Content-Type` request header in order to help servers
understand which charset is being used to encode headers of each part.

As reported in SPR-17030 and others, some servers are not parsing
properly such header values and assume that `boundary` is the last
directive in the `Content-Type` header.

This commit reorders the charset information right before the boundary
declaration to get around those issues.

Issue: SPR-17030
2018-07-20 18:11:05 +02:00
Juergen Hoeller 9a43d2ec20 Revised log levels: less WARN and INFO, fine-tuned DEBUG vs TRACE
Issue: SPR-16946
2018-07-20 15:05:16 +02:00
Rossen Stoyanchev 93b7a4838e UriComponentsBuilder method to configure URI variables
See Javadoc on UriComponentsBuilder#uriVariables for details.

This helps to prepare for SPR-17027 where the MvcUriComponentsBuilder
already does a partial expand but was forced to build UriComonents
and then create a new UriComponentsBuilder from it to continue. This
change makes it possible to stay with the same builder instance.

Issue: SPR-17027
2018-07-19 19:07:42 -04:00
Rossen Stoyanchev 28cd6978b5 Minor fixes: UriComponentsBuilder, UriComponents, docs
After the latest changes, two small fixes in the clone method to copy
the encode flag, and in the encodeUriTemplate method to account for
possible null query params.

Improvements in the URI encoding section.

Issue: SPR-17039, SPR-17027
2018-07-19 19:07:42 -04:00
Juergen Hoeller 51c7ceb95d Polishing 2018-07-20 00:17:37 +02:00
Juergen Hoeller 867b3d233d Upgrade to OkHttp 3.11, Apache HttpClient 4.5.6, Hibernate Validator 6.0.11 2018-07-19 17:52:08 +02:00
Juergen Hoeller 1f5d0faf1f HandlerMethod caches interface parameter annotations
Issue: SPR-11055
2018-07-19 11:38:10 +02:00
Vedran Pavic b1e28a554a Polish WebSession javadoc
Issue: SPR-17051

Closes gh-1888
2018-07-19 11:26:49 +02:00
Rossen Stoyanchev 9498da5910 Clarify behavior of WebSession#save()
+ minor update to the InMemoryWebSession to match the defined behavior.

Issue: SPR-17051
2018-07-18 22:14:02 -04:00
Juergen Hoeller 9c08a482d1 Prefer ArrayList/ArrayDeque over LinkedList for multi-element holders
LinkedList remains in place where a List is likely to remain empty or single-element (in order to avoid unused capacity).

Issue: SPR-17037
2018-07-18 22:17:42 +02:00
Rossen Stoyanchev 4d6f2df3cb Add LogUtils and HttpLogging
SPR-17012
2018-07-18 15:32:50 -04:00
Juergen Hoeller c77dbbb1e6 Specific exception for missing request header, cookie, matrix variable
Issue: SPR-14818
2018-07-18 18:56:51 +02:00
Juergen Hoeller 790d515f8c HandlerMethod exposes interface parameter annotations as well
The HandlerMethodParameter arrangement uses an approach similar to ModelAttributeMethodProcessor's FieldAwareConstructorParameter, merging the local parameter annotations with interface-declared annotations.

Issue: SPR-11055
2018-07-18 17:13:55 +02:00
sdeleuze a87764f1fd Add support for Jetty Reactive Streams HTTP client
Leverage https://github.com/jetty-project/jetty-reactive-httpclient
to add support for Jetty in WebClient via JettyClientHttpConnector.

Implemented with buffer copy instead of optimized buffer wrapping
because the latter hangs since Callback#succeeded doesn't allow
releasing the buffer and requesting more data at different times
(required for Mono<DataBuffer> for example).
See https://github.com/eclipse/jetty.project/issues/2429.

Issue: SPR-15092
2018-07-18 14:49:49 +02:00
Sebastien Deleuze 3c9049d530 Leverage Jetty BOM
Issue: SPR-17058
2018-07-18 14:49:49 +02:00
Juergen Hoeller 5fcfe0fa8e Polishing 2018-07-18 14:27:16 +02:00
Rossen Stoyanchev 6c4289e238 Polish 2018-07-17 17:39:16 -04:00
Juergen Hoeller ef9027e1c1 Polishing 2018-07-17 17:59:16 +02:00
Juergen Hoeller 955665b419 Consistent processing of binding/validation failures for data classes
Includes an extension of SmartValidator for candidate value validation, as well as nullability refinements in Validator and BindingResult.

Issue: SPR-16840
Issue: SPR-16841
Issue: SPR-16854
2018-07-17 17:01:34 +02:00
Rossen Stoyanchev a41a1edd93 Switch to TEMPLATE_AND_VALUES as the default mode
DefaultUriBuilderFactory now uses EncodingMode.TEMPLATE_AND_VALUES by
default. However the RestTemplate explicitly sets it to the previous
setting EncodingMode.URI_COMPONENTS, so this affects mainly the
WebClient and any direct use of DefaultUriBuilderFactory to configure
either the RestTemplate or the WebClient.

Issue: SPR-17039
2018-07-16 21:21:37 -04:00
Rossen Stoyanchev 2a0eac47f9 Add TEMPLATE_AND_VALUES mode to DefaultUriBuilderFactory
Issue: SPR-17039
2018-07-16 21:21:37 -04:00
Rossen Stoyanchev 75e45103b5 Polish DefaultUriBuilderFactory 2018-07-16 21:21:34 -04:00
Rossen Stoyanchev 5fb4982026 Support for encode() in UriComponentsBuilder
The ability to request to encode before `build()`, and more importantly
before expanding, allows stricter encoding to be applied to URI vars
and consequently to neutralize the effect of characters with reserved
meaning in a URI.

Issue: SPR-17039
2018-07-16 09:16:11 -04:00
Rossen Stoyanchev 24a30baa2a Typos in InMemoryWebSessionStore 2018-07-13 17:51:23 -04:00
Rossen Stoyanchev 43fbd63254 Add maxSessions, getSessions, removeExpiredSessions
This commit removes the session threshold check added recently which
is not effective since maxIdleTime is usually much longer than the
frequency of checks. The lazy triggering of expiration checks during
create or retreive are simple and the most effective

This commit also adds a maxSessions limit on the total number of
sessions that can be created at any one time, a getSessions method
for management purposes, and a removeExpiredSessions public API
for manual triggering of expiration checks.

Issue: SPR-17020, SPR-16713
2018-07-12 16:12:19 -04:00
Rossen Stoyanchev 32b75221b3 Improve expired session check algorithm
1. Add session count threshold as am extra pre-condition.
2. Check pre-conditions for expiration checks on every request.

Effectively an upper bound on how many sessions can be created before
expiration checks are performed.

Issue: SPR-17020
2018-07-11 15:59:18 -04:00
Rossen Stoyanchev e9ed45ee3b Fix code completion typo 2018-07-11 11:13:57 -04:00
Rossen Stoyanchev 7b3a72f483 Warn when SimpleAsyncTaskExecutor is used
Issue: SPR-16203
2018-07-11 11:10:03 -04:00
Rossen Stoyanchev 1b1bc7f5b5 Switch defaults and model for logging sensitive data
Issue: SPR-17029
2018-07-11 11:10:03 -04:00
Brian Clozel d00f6f09a5 Polish ContentCachingRequestWrapper
Issue: SPR-15762
2018-07-09 19:15:29 +02:00
zilong6 4d0800f392 Improve ContentCachingRequestWrapper performance
This commit improves the performance of `read` method variants
to write to the cache in an optimized way.

Issue: SPR-15762
2018-07-09 19:15:21 +02:00
Arjen Poutsma 2ac6a15f6f Add setBearerAuth method
Issue: SPR-16997
2018-07-09 17:06:55 +02:00
Arjen Poutsma a663454fad Changed Basic Authentication consumer to setBasicAuth method
This commit changes the Basic Authentication Consumer<HttpHeaders> to
a basic setBasicAuth(String, String) method.

Issue: SPR-16913
2018-07-09 16:41:51 +02:00
Rossen Stoyanchev 4bd22eeb13 Fallback logger for logging in http and codec packages
Issue: SPR-17012
2018-07-07 10:54:03 -04:00
Rossen Stoyanchev bca9f51092 Polish hint for suppressing logging at Encoder/Decoder 2018-07-06 20:32:08 -04:00
Rossen Stoyanchev 2874dd75ca Fine-tune WebFlux logging at HTTP/WebSocket level
1. Use special category prefix "spring-web.reactivestreams" for logging
of reactive streams signals in spring-web, since those are quite
verbose would fill the logs at TRACE.

2. Add and use loggers in request and websocket session implementations
separate from reactive streams bridge for regular TRACE logging.

3. Improve log messages and add where missing (e.g. for Reactor)

Issue: SPR-16898
2018-07-06 17:33:16 -04:00
Rossen Stoyanchev 7746878b50 Remove workaround for Reactor Netty #171 2018-07-06 15:44:24 -04:00
Rossen Stoyanchev bc3cf0eeb8 Expose request id at the ServerHttpRequest level
Hiding it (at AbstractServerHttpRequest) complicates matters since
requests are often mutated and decorated, plus it's also possible to
implement the interface directly (we've one, albeit corner case).

Issue: SPR-16966
2018-07-06 15:44:24 -04:00
Rossen Stoyanchev 5dc49b16ea Correlated messages at HTTP adapter + WebSocket level
Issue: SPR-16966
2018-07-06 15:44:18 -04:00
Rossen Stoyanchev bb3061d112 Polish 2018-07-05 14:08:05 -04:00
Violeta Georgieva 22f6e5b9ff Adapt ReactorHttpsServer to lates Reactor Netty changes 2018-07-05 14:00:01 -04:00
Rossen Stoyanchev 39d5874441 Use connection id in server log messages if possible
Issue: SPR-16966
2018-07-05 08:32:27 -04:00
Rossen Stoyanchev 5cdc26770e Correlated WebClient log messages
Issue: SPR-16966
2018-07-05 08:30:23 -04:00
Rossen Stoyanchev 82310660fd Correlated encoding/decoding log messages via hints
Issue: SPR-16966
2018-07-05 08:28:15 -04:00
Rossen Stoyanchev fd90b73748 Correlated WebFlux server log messages
Issue: SPR-16966
2018-07-05 08:27:13 -04:00
Juergen Hoeller 83faee67d5 HttpMessageNotReadableException provides access to HttpInputMessage
Issue: SPR-15588
2018-07-04 22:46:09 +02:00
Rossen Stoyanchev 43d6ceb6f0 Align settings for sameSite and secure flag
After this change sameSite still gets a default value of "Strict" in
CookieWebSessionIdResolver but for changes to either sameSite or secure
it is now expected to use
addCookieInitializer(Consumer<ResponseCookie.ResponseCookieBuilder>).

Issue: SPR-16418, SPR-16980
2018-07-03 12:44:29 -04:00
Juergen Hoeller 9efddea5e0 Upgrade to Apache Johnzon 1.1.8 and JCA 1.7.1 2018-07-03 15:53:49 +02:00
Juergen Hoeller e485abbe56 Fix checkstyle violation (plus related polishing)
Issue: SPR-16913
2018-07-02 23:56:58 +02:00
Juergen Hoeller d08b72a75a Consistent throwing of HttpMessageNotReadableException vs IOException
Includes specific fine-tuning of ProtobufHttpMessageConverter and JAXB2 based message converters, as well as revised javadoc for abstract base classes.

Issue: SPR-16995
2018-07-02 22:37:29 +02:00
Arjen Poutsma 6bcf6ffb06 Add Basic Authentication Consumer
Issue: SPR-16913
2018-07-02 15:16:03 +02:00
Juergen Hoeller 4ff1e3e74b Consistent abstract declaration for utility classes (plus polishing)
Issue: SPR-16968
2018-07-01 02:31:20 +02:00
Rossen Stoyanchev e72f4ec501 Fix checkstyle error 2018-06-29 21:45:43 -04:00
Rossen Stoyanchev d74e09a925 Polish MockClientHttpRequest 2018-06-29 17:37:45 -04:00
Rossen Stoyanchev 7f555785dd Add getBodyAsString() to MockClientHttpRequest
Issue: SPR-16988
2018-06-29 17:34:23 -04:00
Rossen Stoyanchev 51ec7c6b4a Add hook for customizing response cookie
Issue: SPR-16980
2018-06-29 18:15:52 -03:00
Rossen Stoyanchev 5ec8db1adc Polish CookieWebSessionIdResolver 2018-06-29 18:15:52 -03:00
Rossen Stoyanchev 907a306ee2 Fix locally failing test in FlushingIntegrationTests 2018-06-29 18:15:52 -03:00
Damiano Albani 3165b3c024 Fix typo in Java doc 2018-06-29 18:12:43 -03:00
Juergen Hoeller e22466e9d5 Polishing 2018-06-29 19:44:15 +02:00
Juergen Hoeller d34e6f7f70 Polishing 2018-06-28 18:02:07 +02:00
Juergen Hoeller 40efcc933c Polishing 2018-06-28 14:51:33 +02:00
Juergen Hoeller bac68c8d3f StandardServletMultipartResolver accepts any HTTP method for multipart
Issue: SPR-16975
2018-06-28 14:15:16 +02:00
Phillip Webb a89e716cc7 Use tabs rather than spaces in tests
Update tests to ensure that tabs are used instead of spaces. Also
consistently apply a new line at the end of each file.

Issue: SPR-16968
2018-06-28 10:28:44 +02:00
Phillip Webb 1c25cec44f Polish test code
Polish a few issue identified when adding checkstyle to the
build. Although checkstyle is not enforcing rules on tests,
these are a few minor changes that are still worth making.

Issue: SPR-16968
2018-06-28 10:28:44 +02:00
Phillip Webb 81451aa800 Organize imports
Reorganize imports to ensure consistent ordering. This commit also
expands any `.*` static imports in favor of using fully-qualified
method references.

Issue: SPR-16968
2018-06-28 10:28:44 +02:00
Phillip Webb 5cedd0d5d4 Consistently use tabs rather than spaces
Update code that has accidentally used spaces instead of tabs.
Also remove all trailing whitespace.

Issue: SPR-16968
2018-06-28 10:28:44 +02:00
Phillip Webb 9de3689f63 Never use 'this.' when accessing loggers
Ensure that `this.` is never used when accessing loggers.

Issue: SPR-16968
2018-06-28 10:28:44 +02:00
Phillip Webb 0b53c1096a Always use 'this.' when accessing fields
Ensure that `this.` is used consistently when accessing class
fields.

Issue: SPR-16968
2018-06-28 10:28:44 +02:00
Phillip Webb eeebd51f57 Use consistent class design
Update all classes so that inner classes are always last. Also
ensure that utility classes are always final and have a private
constructor and make exceptions final whenever possible.

Issue: SPR-16968
2018-06-28 10:28:44 +02:00
Phillip Webb 0ad0f341bd Don't use single letter catch variables
Update existing catch blocks to ensure that `ex` is always used
in preference to `e` or `t` as the variable name.

Issue: SPR-16968
2018-06-28 10:28:44 +02:00
Phillip Webb 866e9d702e Use consistent block style
Update all code to use a consistent block style.

Issue: SPR-16968
2018-06-28 10:28:44 +02:00
Phillip Webb 04a8c285df Fix annotation styling issues
Update all annotations so that each is on its own line and
consistently use the short form (i.e. don't use `value=`) when
possible.

Issue: SPR-16968
2018-06-28 10:28:44 +02:00
Phillip Webb e9d1b39aff Apply consistent copyright header
Add copyright header to `package-info.java` files and fix a few
malformed headers on existing java files.

Issue: SPR-16968
2018-06-28 10:28:44 +02:00
Phillip Webb c3a17dfd47 Ensure all files end with a newline
Update all files to ensure that they always end with a new line.

Issue: SPR-16968
2018-06-28 10:28:44 +02:00
Phillip Webb e0480f75ac Fix javadoc checkstyle issues
Fix checkstyle violations for javadoc.

Issue: SPR-16968
2018-06-28 10:28:44 +02:00
Rossen Stoyanchev 7ccd2b024d Refine logging for async requests
Issue: SPR-16898
2018-06-25 14:42:29 -03:00
Juergen Hoeller 2a15962d7f WebHttpHandlerBuilder retains ApplicationContext in copy constructor
Issue: SPR-16972
2018-06-25 18:12:12 +02:00
Rossen Stoyanchev 900bc8a2e3 Logging improvements for WebFlux
Issue: SPR-16898
2018-06-22 22:44:24 -04:00
Juergen Hoeller eaffcbe3be Upgrade to Gradle 4.8.1
Includes Kotlin 1.2.50, RxJava 2.1.15 and Protobuf 3.6.

Issue: SPR-16475
2018-06-22 22:49:12 +02:00
Brian Clozel 4a26f93a0d WebClient writes Content-Length for Mono bodies
In SPR-16892, the `EncoderHttpMessageWriter` has been improved to write
`"Content-Length"` HTTP response headers if the response body is of type
`Mono` (i.e. the actual content length is easily accessible without
buffering a possibly large response body). That change was relying on
the fact that the server side is using a `ChannelSendOperator` to delay
the writing of the body until the first signal is received.

This strategy is not effective on the client side, since no such channel
operator is used for `WebClient`. This commit improves
`EncoderHttpMessageWriter` and delays, for `Mono` HTTP message bodies
only, the writing of the body so that we can write the
`"Content-Length"` header information once we've got the body resolved.

Issue: SPR-16949
2018-06-19 11:51:45 +02:00
Rossen Stoyanchev 28a5c3009e Improve DEBUG/TRACE logging for Spring MVC
Issue: SPR-16898
2018-06-18 18:33:11 -04:00
Juergen Hoeller 003d643adc Consistent support for new JsonMappingException wording in Jackson 2.9
Issue: SPR-16947
2018-06-17 21:42:20 +02:00
Mark Chesney e4666c17ec Support new exception message wording since Jackson 2.9
The wording changed from "Can not find" to "Cannot find" via PR #1682

Issues: SPR-16947
2018-06-17 13:27:20 +02:00
Rossen Stoyanchev ebdcc015a4 Correctly set maxAge and expires in ResponseCookie
Issue: SPR-16940
2018-06-14 13:07:17 -04:00
Brian Clozel 09d9450154 Add SameSite support in WebFlux SESSION cookies
This commit adds support for the "SameSite" attribute in response
cookies. As explained in rfc6265bis, this attribute can be used to limit
the scope of a cookie so that it can't be attached to a request unless
it is sent from the "same-site".

This feature is currently supported by Google Chrome and Firefox, other
browsers will ignore this attribute.

This feature can help prevent CSRF attacks; this is why this commit adds
this attribute by default for SESSION Cookies in WebFlux.

See: https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis

Issue: SPR-16418
2018-06-14 11:39:03 +02:00
Juergen Hoeller 1e5f8cc232 FilePart and MultipartFile provide transferTo(Path) variant
Also, ZeroCopyHttpOutputMessage provides writeWith(Path, int, int), enforcing that variant as the implementation target in 5.1 (analogous to FilePart).

Issue: SPR-16925
2018-06-14 00:42:36 +02:00
Rossen Stoyanchev 0b61c748f6 Protected methods for serializing form content
Issue: SPR-16855
2018-06-13 17:14:49 -04:00
Rossen Stoyanchev 278881b8df Polish form writer and converter 2018-06-13 17:05:34 -04:00
Juergen Hoeller 0dc434b35e Polishing 2018-06-13 22:04:10 +02:00
Juergen Hoeller 3fc8ec498c MockHttpServletRequest returns a single InputStream or Reader
Issue: SPR-16505
Issue: SPR-16499
2018-06-13 22:03:16 +02:00
Juergen Hoeller 0b64bcd319 Remove outdated Servlet environment constraints from annotation javadoc
Issue: SPR-16936
2018-06-12 11:28:13 +02:00
Allon Mureinik 2573a543b2 SPR-16936 Fix PathVariable javadoc
@PathVariable's javadoc states that it supports MultiValueMap
parameters (introduced by commit df0902), but by reading through the
code, that does not seem to be the case (compare, e.g.,
PathVariableMapMethodArgumentResolver to
RequestParamMapMethodArgumentResolver).

Moreover, parsing MultipleValueMap is done according to the ";"
character, and placing such a character in a path (e.g., consider
something like "/app/{param}/show" would just break the path.

This patch fixes PathVariable's javadoc by removing the mention of
MultiValueMap.
2018-06-12 11:12:57 +02:00
Brian Clozel 05ff8b722d Fix ResourceRegion HttpMessageConverter write checks
This commit fixes the write checks for
`ResourceRegionHttpMessageConverter`, which was previously not checking
properly the parameterized type (e.g. in case of a `List<Something>`).

Issue: SPR-16932
2018-06-11 22:53:55 +02:00
Juergen Hoeller 9c36b53833 Upgrade to JAXB 2.3.0.1, Aalto XML 1.1, Rome 1.10 2018-06-11 22:01:51 +02:00
Brian Clozel a5cd01a4c8 Restrict HTTP methods on Reactive HiddenHttpMethodFilter
This commit restricts the allowed HTTP methods on HiddenHttpMethodFilter
(Reactive variant) to the following: PUT, DELETE, PATCH.

This filter is meant to be used to simulate those methods from HTML
forms sent by browsers, so no other methods are allowed.

Issue: SPR-16836
2018-06-11 18:53:23 +02:00
Brian Clozel f64fa3dea1 Restrict HTTP methods on Servlet HiddenHttpMethodFilter
This commit restricts the allowed HTTP methods on HiddenHttpMethodFilter
(Servlet variant) to the following: PUT, DELETE, PATCH.

This filter is meant to be used to simulate those methods from HTML
forms sent by browsers, so no other methods are allowed.

Issue: SPR-16836
2018-06-11 18:53:23 +02:00
Brian Clozel 417354da8a Remove dependency management noise from POMs
Prior to this commit, the generated POMs for Spring Framework modules
would contain unneeded/harmful information from the Spring Framework
build:

1. The BOM imports applied to each module by the dependency
management plugin, for example for Netty or Reactor Netty.
Spring should not export that opinion to its POMs.

2. The exclusion of "org.slf4:jcl-over-slf4j" from *all* dependencies,
which made the POMs much larger than necessary and suggested to
developers that they should exclude it as well when using all those
listed dependencies. In fact, only Apache Tiles currently brings that
transitively.

This commit removes that information from the POMs.
The dependencyManagement Gradle plugin is disabled for POM generation
and we manually resolve the dependency versions during the generation
phase.
The Gradle build is streamlined to exclude "org.slf4:jcl-over-slf4j"
only when necessary.

Issue: SPR-16893
2018-06-11 15:57:54 +02:00
Rossen Stoyanchev 86c861516d Accept Predicate instead of HandlerTypePredicate
Issue: SPR-16336
2018-06-08 15:32:07 -04:00
Sebastien Deleuze ac37b678a3 Remove JSONP support
CORS is now widely supported and should be used instead for cross-domain
requests.

Issue: SPR-16914
2018-06-08 12:15:48 +02:00
Rossen Stoyanchev 31159a8506 Extract HandlerTypePredicate from ControllerAdviceBean
Issue: SPR-16336
2018-06-07 18:18:42 -04:00
Rossen Stoyanchev 72b1d4c648 Remove explicit references to Reactor Netty version
...now that 0.8 is also listed in the Reactor bom.

Issue: SPR-16387
2018-06-06 14:35:54 -04:00
Rossen Stoyanchev fd946b8157 Protected getContentType in DecoderHttpMessageReader
Issue: SPR-16856
2018-06-05 16:23:21 -04:00
Rossen Stoyanchev 010352163b Eliminate the need for Encoder#getContentLength
Issue: SPR-16892
2018-06-04 15:48:47 -04:00
Rossen Stoyanchev 124d4c833c Support for Servlet request params with HTTP DELETE
This commit adds FormContentFilter, which is the same as the
HttpPutFormContentFilter but also supports DELETE.

The HttpPutFormContentFilter is now deprecated.

Issue: SPR-16874
2018-06-04 15:48:47 -04:00
Rossen Stoyanchev a3216432b5 Polish
Issue: SPR-16387
2018-05-31 15:38:30 -04:00
Violeta Georgieva ffbc75ae47 Upgrade to Reactor Netty 0.8
Issue: SPR-16387
2018-05-31 15:37:39 -04:00
Juergen Hoeller c75423216c AbstractRequestLoggingFilter.isIncludeHeaders() declared as protected
Issue: SPR-16881
2018-05-29 21:52:31 +02:00
Juergen Hoeller 8593fec22c Avoid ConstantConditions warnings suppression (plus related polishing)
Issue: SPR-15756
2018-05-29 21:47:10 +02:00
Rossen Stoyanchev 2acf91a438 Polish 2018-05-26 09:24:23 -04:00
Rossen Stoyanchev 3ede3a4b34 Extension point in HttpMessageConverterExtractor 2018-05-25 13:45:10 -04:00
Rossen Stoyanchev c7c3e5585b X-Forwarded-Ssl is listed in ForwardedHeaderFilter
Issue: SPR-16863
2018-05-25 13:39:37 -04:00
Juergen Hoeller 836a09d5c0 Upgrade to Woodstox 5.1, XMLUnit 2.6, Gson 2.8.5 2018-05-25 00:18:06 +02:00
Rossen Stoyanchev 3eac2dd31e Support X-Forwarded-Ssl
Issue: SPR-16863
2018-05-24 16:14:12 -04:00
Rossen Stoyanchev 72022899de Polish Forwarded header support 2018-05-23 21:23:23 -04:00
Rossen Stoyanchev 1e4a3a2370 Return SslInfo only if X509Certificate[] present
Issue: SPR-16842
2018-05-23 21:23:23 -04:00
Rossen Stoyanchev d035593562 Update @RequestParam Javadoc and remove Portlet mentions 2018-05-23 11:52:14 -04:00
Rossen Stoyanchev 9b496b1264 CodecConfigurer internal refactoring
Improve how HTTP message writers are obtained for general use vs for
multipart requests.
2018-05-21 21:10:44 -04:00
Rossen Stoyanchev 6e5273f08e Polish CodecConfigurer support classes
Functionally equivalent updates to package private classes to improve
the code and make it easier to understand.
2018-05-21 21:09:42 -04:00
Rossen Stoyanchev fbd12e9d16 Support for SslInfo in ServerHttpRequest#mutate
Issue: SPR-16830
2018-05-17 17:27:52 -04:00
Sebastien Deleuze bdfee3417e Polishing 2018-05-15 10:45:20 +02:00
Eddú Meléndez 48c3fa9908 Add visibility support to Jackson2ObjectMapperBuilder
Issue: SPR-16411
2018-05-15 10:45:20 +02:00
Rossen Stoyanchev 7fd0cac6f2 Include FormHttpMessageReader in client codecs
Issue: SPR-16804
2018-05-14 23:16:36 -04:00
Rossen Stoyanchev 3af5f00ee7 UnsupportedMediaType[Status]Exception reports body type
Issue: SPR-16805
2018-05-14 23:16:36 -04:00
Rossen Stoyanchev f7d60b7f58 Add getResource to MultipartFile
Issue: SPR-16808
2018-05-14 09:04:33 -04:00
Rossen Stoyanchev ab6a6f4e17 Merge multipart and query param values
DefaultMultipartHttpServletRequest always returned mulitpart parameter
values only rather than aggregating with query parameters, which
contradicts with Servlet spec, section 3.1, and is inconsistent with
StandardMultipartHttpServletRequest.

Issue: SPR-16590
2018-05-14 09:03:55 -04:00
Rossen Stoyanchev 15182b29a4 Add MockWebSession for use with MockServerWebExchange
Issue: SPR-16772
2018-05-11 10:53:28 -04:00
Rossen Stoyanchev 4da43de7e1 Remove individual detection of forwarded headers
This commit removes all places where forwarded headers are checked
implicitly, on an ad-hoc basis.

ForwardedHeaderFilter is expected to be used instead providing
centralized control over using or discarding such headers.

Issue: SPR-16668
2018-05-11 09:31:39 -04:00
Rossen Stoyanchev d3f3b41f52 MockHttpServletResponse writer sets committed flag
Issue: SPR-16683
2018-05-10 16:22:54 -04:00
Rossen Stoyanchev 79e809be24 Public RequestCallback/ResponseExtractor factory methods
Issue: SPR-8604
2018-05-10 15:39:47 -04:00
Rossen Stoyanchev eef592d901 Add builder to MockServerWebExchange
Issue: SPR-16772
2018-05-10 15:16:13 -04:00
Juergen Hoeller c9f488363d Fine-tuned assertions and related polishing 2018-05-05 14:39:43 +02:00
Juergen Hoeller e17fc8d607 Upgrade to Tomcat 9.0.8, Undertow 2.0.6, Jetty 9.4.10, Gson 2.8.4 2018-05-05 12:47:34 +02:00
Sebastien Deleuze af0cb53742 Support decoding Mono in Jaxb2XmlDecoder
Issue: SPR-16759
2018-05-02 12:10:46 +02:00
Juergen Hoeller f8c2d7ab51 Nullable HttpMethod parameter only on internal doExecute delegate
Issue: SPR-15540
2018-05-01 23:52:12 +02:00
Juergen Hoeller 21fad8e205 SimpleClientHttpResponse catches any Exception on close
Issue: SPR-16773
2018-05-01 23:51:05 +02:00
Rossen Stoyanchev 8d157cb5b5 Consistent handling of URISyntaxException
Issue: SPR-16778
2018-04-30 21:02:36 -04:00
Rossen Stoyanchev 85ee36b385 Uncomment tests that now work 2018-04-30 19:47:14 -04:00
Juergen Hoeller 9bff5b48cf Fine-tuned assertions and related polishing in WebFlux builders 2018-04-27 23:36:58 +02:00
Johnny Lim 6519e7b22a Polish 2018-04-27 14:06:48 -04:00
Juergen Hoeller a683472daa Support for non-standard HTTP status in reactive ClientHttpResponse
Issue: SPR-16748
2018-04-27 18:25:11 +02:00
Juergen Hoeller 44cf002c00 Null-safe handling of response type in AcceptHeaderRequestCallback
Issue: SPR-16690
2018-04-27 18:24:59 +02:00
sdeleuze 75a41db071 Fine tune WebFlux server logging verbosity
With this commit, WebFlux server uses warning instead of error log level
for request handling, and also just print the message instead of the
stacktrace which is mostly meaningless in reactive world.

Complementary to this change, Reactor Netty removed additional logging
as part of https://github.com/reactor/reactor-netty/issues/339.

Issue: SPR-16688
2018-04-27 10:40:48 +02:00
sdeleuze b5dfdbaa65 Reuse PartBodyStreamStorageFactory in SynchronossPartGenerator
Issue: SPR-16727
2018-04-26 10:59:11 +02:00
Rossen Stoyanchev 9bc4e70e93 Better assertion message in MockPart
Issue: SPR-16767
2018-04-25 09:59:06 -04:00
Rossen Stoyanchev da98ff72d2 Use StringDecoder to split SSE stream
ServerSentEventHttpMessageReader had logic to split on new lines
and buffer until an empty new line (start of a new event). To account
for random data chunking, it later re-assembled the lines for each
event and split again on new lines. However bufferUntil was still
unreliable a chunk may contain nothing but a newline, which doesn't
necessarily mean an empty newline in the overall SSE stream.

This commit simplifies the above by delegating the splitting of the
stream along newlines to StringDecoder.

Issue: SPR-16744
2018-04-19 11:29:12 -04:00
Rossen Stoyanchev 586be50109 Fix typo 2018-04-16 10:02:47 -04:00
Rossen Stoyanchev 551505bd93 Restore handling of 0 bytes read
Issue: SPR-16728
2018-04-16 09:59:34 -04:00
Juergen Hoeller 0754833b37 Local XMLUnit dependency declarations with consistent version 2.5.1 2018-04-14 21:03:20 +02:00
Brian Clozel 69e3fde295 Avoid duplicate Accept header values in RestTemplate
Prior to this commit, the various `HttpMessageConverter` instances
configured for a given `RestTemplate` instance could all contribute
`MediaType` values to the "Accept:" request header.

This could lead to duplicate media types in that request header,
cluttering for the HTTP request for no reason.

This commit ensures that only distinct values are added to the request.

Issue: SPR-16690
2018-04-12 22:28:31 +02:00
Rossen Stoyanchev 224589ea74 Remove write pausing in Undertow response
Using the simple example shown in the ticket but switching from
Mono<String> to Flux<String> (and 5,000,000 onNext calls) shows that
constant pausing causes significant overhead and is not worth the
trouble vs ignoring the onWritePossible in REQUESTED state.

Issue: SPR-16702
2018-04-11 14:27:27 -04:00
Rossen Stoyanchev 3549745e37 Avoid inifinite recursion in UndertowServerHttpResponse
Undertow does not provide a way to check if we can write so with the
current implementation of isWritePossible, deep recursion can occur
when writing slows down. We now use a flag to keep track of write
ChannelListener callbacks.

This commit also addresses a related issue in
AbstractListenerWriteProcessor that went undected since #3c2d186
where after a large (single) buffer that is not written fully, the
completion signal is processed before the all data is written.

Issue: SPR-16702
2018-04-11 14:27:27 -04:00
sdeleuze 89d069b09d Add default ctor to Reactive UrlBasedCorsConfigurationSource
Issue: SPR-16712
2018-04-11 14:38:42 +02:00
sdeleuze 27e87e5593 Document why "charset=UTF-8" is specified for JSON
Issue: SPR-14715
2018-04-09 12:03:17 +02:00
Brian Clozel 2dde000475 Document socket timeout config limitations for HttpClient
This commit documents the difference between configuring the socket
timeout on the `RequestConfig` and on the `SocketConfig`.

The first one does not affect timeouts when establishing an SSL
connection or sending a CONNECT request to a proxy. For these use cases,
it is required to configure `SocketConfig` on the `HttpClient` instance
directly.

Issue: SPR-16697
2018-04-06 16:35:17 +02:00
Juergen Hoeller 66a3a82fb3 Avoid reference to HandlerMethod class in ServerErrorException
This breaks the package dependency cycle between web.server/web.method and makes ServerErrorException more generally applicable. Includes deprecation of the plain reason constructor variant, in favor of providing a Method or MethodParameter context (which MatrixVariableMethodArgumentResolver does now).
2018-04-01 00:21:15 +02:00
Juergen Hoeller 28ea718d2d Build setup allows for JDK 10 as source/test target compatibility
Includes upgrade to Groovy 2.4.15 and HtmlUnit 2.30.

Issue: SPR-16390
2018-03-31 23:17:31 +02:00
Rossen Stoyanchev d9e17a62ce Refine SyncInvocableHandlerMethod error handling
Ensure the error is wrapped as ServerErrorException
2018-03-31 12:06:24 -04:00
Juergen Hoeller 912c270f2b Polishing 2018-03-31 17:49:21 +02:00
Rossen Stoyanchev 4454ffd2b1 Replace remaining use of block operator 2018-03-31 11:18:38 -04:00
Stephane Maldini b8d32095a9 workaround multipart integration test using blocking receive inside netty thread 2018-03-30 15:43:11 -07:00
Juergen Hoeller 0bc01fcd55 Polishing 2018-03-30 13:42:23 +02:00
Rossen Stoyanchev 240d6f52c9 Replaces rather than prepend contextPath
Issue: SPR-16650
2018-03-29 18:17:29 -04:00
Juergen Hoeller d553ddc5b3 Nullability refinements (based on IntelliJ IDEA 2018.1 introspection)
Issue: SPR-15756
2018-03-29 23:50:17 +02:00
igor-suhorukov 93abe0e94b All branches in a conditional structure should not have exactly the same implementation 2018-03-29 23:33:50 +02:00
Rossen Stoyanchev dd96c873e3 Improve docs on forwarded headers
Issue: SPR-16660
2018-03-29 16:11:01 -04:00
Rossen Stoyanchev a546cf0a3b Reject invalid forwarded headers
Issue: SPR-16660
2018-03-29 15:28:34 -04:00
Juergen Hoeller b165475eb6 Polishing 2018-03-29 16:05:52 +02:00
Rossen Stoyanchev f9e6ea5482 MvcResult returns asyncResult after asyncDispatch
Issue: SPR-16648
2018-03-28 22:15:16 -04:00
Juergen Hoeller d95bbb6b1b Test for hasError keeping body available in case of unknown status code
Issue: SPR-16604
2018-03-28 12:16:03 +02:00
Juergen Hoeller b2d87abcbb Polishing 2018-03-28 12:06:38 +02:00
Rossen Stoyanchev 5861e9685b Always specify charset for form data requests
Issue: SPR-16613
2018-03-27 19:56:09 -04:00
igor-suhorukov 4aae6a6dda Use Map.forEach instead of manual Map.Entry iteration wherever possible SPR-16646 2018-03-28 01:09:03 +02:00
Rossen Stoyanchev f3994467c4 Refine ContentNegotiationStrategy contract
Consistently return "*/*" if no media types were requested rather than
an empty list. Existing code has to check for both in any case to see
if nothing was requested.

Issue: SPR-16624
2018-03-27 16:54:19 -04:00
Juergen Hoeller e3d0ef6015 Use Map.forEach instead of manual Map.Entry iteration wherever possible
Issue: SPR-16646
2018-03-27 00:38:32 +02:00
Juergen Hoeller 10cb2ccaef Avoid triggering lazy resolution in MultipartResolver.cleanupMultipart
Issue: SPR-16640
2018-03-27 00:25:05 +02:00
Rossen Stoyanchev a989ea0867 Polish Synchronoss message reader
Issue: SPR-16639
2018-03-24 08:59:16 -04:00
Rossen Stoyanchev 0af847c01c ServerSentEventHttpMessageReader internal refactoring
Eliminate use of .block() which Reactor now flags as illegal on
schedulers where that's not expected.
2018-03-23 19:01:11 -04:00
Juergen Hoeller ba5ef6456f WebFluxResponseStatusExceptionHandler for @ResponseStatus introspection
The web.server package is quite low-level and should not depend on web.bind in order to avoid a dependency cycle. Extracting the introspection of the ResponseStatus annotation into a WebFlux-level subclass resolves the cycle.

Issue: SPR-16567
2018-03-21 16:12:32 +01:00
Rossen Stoyanchev f9df8c738a Avoid inifinite recursion in UndertowServerHttpRequest
Undertow does not provide a way to check if data is available to read
but instead we have to try to read and see if any data is returned.
This makes it impossible to implement checkOnDataAvailable without
trying to read and that can lead to infinite recursion like this:

...
UndertowServerHttpRequest$RequestBodyPublisher.checkOnDataAvailable(UndertowServerHttpRequest.java:156)
AbstractListenerReadPublisher.changeToDemandState(AbstractListenerReadPublisher.java:177)
AbstractListenerReadPublisher.access$900(AbstractListenerReadPublisher.java:47)
AbstractListenerReadPublisher$State$4.onDataAvailable(AbstractListenerReadPublisher.java:319)
AbstractListenerReadPublisher.onDataAvailable(AbstractListenerReadPublisher.java:85)
UndertowServerHttpRequest$RequestBodyPublisher.checkOnDataAvailable(UndertowServerHttpRequest.java:156)

This commit prevent the call to checkOnDataAvailable() when switching
states from READING->DEMAND which implies we exited the readAndPublish
loop because there was no more data to read.

Issue: SPR-16545
2018-03-20 17:21:33 -04:00
Juergen Hoeller 442ddb0845 Correct documentation of default HttpMessageConverters in RestTemplate
Issue: SPR-7885
2018-03-19 20:38:14 +01:00
Rossen Stoyanchev 26bb3a0893 Improve docs on enabling Servlet 3 multipart 2018-03-19 11:20:08 -04:00
Rossen Stoyanchev 8651b8d4c1 Show use of RequestEntity rather than HttpEntity
Issue: SPR-16608
2018-03-19 08:57:01 -04:00
Rossen Stoyanchev 30583a62cf Fix Class isAssignableFrom checks for Resource conversion
Issue: SPR-16606
2018-03-16 16:18:05 -04:00
Rossen Stoyanchev 842c29103f MultipartBodyBuilder supports PublisherEntity as input
Issue: SPR-16601
2018-03-16 16:18:05 -04:00
Rossen Stoyanchev 313c6cef32 Polish 2018-03-16 16:18:05 -04:00
Juergen Hoeller f8588e364a AcceptHeaderLocaleResolver keeps language match among supported locales
Issue: SPR-16599
2018-03-16 14:17:50 +01:00
Rossen Stoyanchev 7de2650a70 Drop @WebServlet annotation
Issue: SPR-16591
2018-03-16 00:14:54 -04:00
Rossen Stoyanchev 72bbb2619d Commit actions are (properly) deferred
Issue: SPR-16597
2018-03-15 23:17:57 -04:00
Juergen Hoeller 2096676b3f Upgrade to Apache Johnzon 1.1.7 and JRuby 9.1.16 2018-03-15 15:43:45 +01:00
Juergen Hoeller d4a8f76bf9 Consistent volatile access to running flag in Lifecycle implementations
Issue: SPR-16488
2018-03-15 15:17:55 +01:00
Rossen Stoyanchev b8d94f8a20 Improve WebFlux support for response status exceptions
Support @ResponseStatus annotated exceptions.
Supported root cause exceptions with response status information.

Issue: SPR-16567
2018-03-14 20:07:00 -04:00
Juergen Hoeller 58011f71e9 Consistent assertions for template method result vs servlet registration 2018-03-14 18:55:50 +01:00
Juergen Hoeller 41730220f4 InterceptingClientHttpRequest adapts to StreamingHttpOutputMessage
Issue: SPR-16582
2018-03-12 22:31:48 +01:00
sdeleuze 36a222acd5 Take into account the MimeType's charset in Jackson encoder
Notice that per specification, only Unicode is supported
(UTF8, UTF16_BE, UTF16_LE, UTF32_BE, UTF32_LE).

Issue: SPR-16539
2018-03-12 21:54:53 +01:00
Juergen Hoeller cf74b1b8be Consistent result synchronization in WebAsyncManager
Issue: SPR-16571
2018-03-09 09:03:15 +01:00
igor-suhorukov 58a5138f26 simplify lambda expression 2018-03-08 23:44:32 +01:00
igor-suhorukov d89f9af22d parentheses should be removed from a single lambda input parameter when its type is inferred 2018-03-08 21:55:45 +01:00
Juergen Hoeller 139dc1d373 Polishing (collapsed if checks, consistent downcasts, refined javadoc) 2018-03-08 18:11:57 +01:00
igor-suhorukov 0f7485b01d Polish: reorder the modifiers to comply with the Java Language Specification. 2018-03-08 17:57:47 +01:00