Commit Graph

1213 Commits

Author SHA1 Message Date
Rossen Stoyanchev
e4c84ec757 Consistent default encoding in DefaultUriBuilderFactory
Issue: SPR-17465
2018-11-09 14:13:51 -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
Rossen Stoyanchev
48654c6483 Polish 2018-11-01 14:21:00 -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
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
feeec344e5 ForwardedHeaderFilter works with Servlet FORWARD
Issue: SPR-16983
2018-10-23 11:53:46 -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
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
423aa28ed5 HttpRange validates requested ranges
Issue: SPR-17318
2018-10-14 22:49:25 -04:00
Juergen Hoeller
bfc5ad890e MockHttpServletRequest resets InputStream/Reader on setContent
Issue: SPR-17373
2018-10-12 16:00:31 +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
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
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
51f7a3e40f Polishing 2018-09-17 14:26:56 +02:00
Arjen Poutsma
09af706af6 Use concatWith instead of mergeWith 2018-09-11 13:36:44 +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
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
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
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
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
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
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
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
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
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