Commit Graph

699 Commits

Author SHA1 Message Date
Sam Brannen 8126ffbc8c Fix broken links in JavaDoc
Issue: SPR-17174
2018-08-13 12:22:52 +02:00
Sam Brannen cfb1ed1009 Clean up warnings and delete dead code 2018-08-12 15:55:11 +02:00
Rossen Stoyanchev aef39e8954 Remove test class added by mistake 2018-08-10 16:57:46 +03:00
Rossen Stoyanchev 61c52d64c5 Polish ConcurrentWebSocketSessionDecoratorTests 2018-08-10 16:15:21 +03: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 58e9706991 Polishing 2018-08-09 02:26:36 +02:00
Juergen Hoeller 247ec572b2 Consistent hasAnnotation check for findMergedAnnotation lookup
Issue: SPR-16933
2018-08-08 23:54:56 +02:00
Rossen Stoyanchev a0dfdfcac3 Hierarchy under WebClientResponseException
Issue: SPR-17145
2018-08-08 15:34:08 +03:00
Sebastien Deleuze 7e9b7102b7 Support custom CorsConfigurationSource in AbstractHandlerMapping
This commit allows to specify a custom CorsConfigurationSource
in AbstractHandlerMapping (both Servlet and Reactive variants).

AbstractHandlerMapping#getCorsConfigurations method is now
deprecated.

Issue: SPR-17067
2018-08-08 10:08:55 +02:00
Juergen Hoeller 34ddb88851 ConcurrentModel.addAttribute(String, Object) ignores null value
Issue: SPR-17141
2018-08-07 20:35:34 +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
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 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
Rossen Stoyanchev aec98268fe maxResponseBody client filter
Issue: SPR-16989
2018-08-02 21:19:22 +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 589b7048ec Avoid synthesizable annotation creation for @Bean/@Scope processing
Includes consistent (non-)use of AnnotationUtils/AnnotatedElementUtils.

Issue: SPR-16933
2018-08-01 11:43:28 +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
Rossen Stoyanchev 91d17cf628 Add notes on future deprecation of the RestTemplate
Issue: SPR-16993
2018-07-27 08:41:20 -04:00
Rossen Stoyanchev f5ff1dc3f9 Comment on difference in matrix variable test
Based on discussion under
https://github.com/spring-projects/spring-framework/pull/1901
2018-07-27 08:40:36 -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 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
Rossen Stoyanchev 32faf09a80 Add check for mixing @EnableWebMvc and @EnableWebFlux
Issue: SPR-16609
2018-07-24 20:47:26 -04:00
Rossen Stoyanchev 0be8c20fca Consistent logging of selected media types 2018-07-24 20:47:26 -04: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
Brian Clozel 195f3f07e7 ResponseEntityResultHandler overwrites headers
Prior to this commit, controller handlers (regular and exception
handlers as well) would not overwrite existing HTTP response headers on
the exchange. This would lead to situations where Content-Type values
set during the initial handling phase would not be overwritten when
handling an error later on.

This commit aligns the implementation of that result handler on the
Spring MVC one in that regard.

Issue: SPR-17082
2018-07-24 22:21:30 +02:00
Juergen Hoeller 11881ff211 Polishing 2018-07-24 18:45:52 +02:00
Juergen Hoeller dd4468a74a Polishing 2018-07-24 16:16:52 +02:00
Juergen Hoeller 3c65c17053 Correctly determine and propagate validation hints to DataBinder
Issue: SPR-17073
2018-07-21 12:19:37 +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
Brian Clozel a410d90439 Drain client response body consistenly
Prior to this commit, the `DefaultClientResponse` implementation would
handle HTTP client cases where the server response body would need to be
consumed (pooled resources need to be released) and the body publisher
cancelled right away. This is done to avoid reading the whole response
body and returning the connection to the pool, now that this connection
cannot be reused.

This was done already when the `WebClient` is asked for a `Void` type
for the response body.

SPR-17054 brought a new case for that: whenever no message reader is
able to decode the response body, an `UnsupportedMediaTypeException`
error signal is sent. Prior to this commit, the response body would not
be consumed and cancelled for that case.

This commit refactors all those cases from the `DefaultClientResponse`
directly into the `BodyExtractors`, since most of the logic and
knowledge for that belongs there. We only need to only apply this
behavior when the HTTP client is involved, as the server does not want
this to happen.

Issue: SPR-17054
2018-07-20 14:01:34 +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
Rossen Stoyanchev 66d73017d5 PathVariable consistently reflects value up to 1st ";"
Given "/{foo}" and "/a=42;c=b", previously that would be treated as a
sequence of matrix vars with an empty path variable. After the change
the path variable "foo" is "a=42".

This should be ok for backawards compatibility since it's unlikely for
anything to rely on an empty path variable.

Issue: SPR-11897
2018-07-18 22:14:02 -04: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
Brian Clozel a7f97a1669 Avoid null signals when resolving handler arguments
Prior to this commit, resolving an argument for a WebFlux controller
that's missing from the request and not required by the handler would
throw a NullPointerException in some cases.

This involves the conversion of the parameter (a `String` parameter type
might not trigger this behavior) and sending a `null` within a reactive
stream, which is illegal per the RS spec.

We now rely on a `Mono.justOrEmpty()` to handle those specific cases.

Issue: SPR-17050
2018-07-18 14:41:43 +02:00
Brian Clozel 75fa9c4266 Fix checkstyle issues 2018-07-12 21:54:32 +02:00
Brian Clozel 038af9a303 Improve unknown status codes handling by WebClient
Prior to this commit, `WebClient` would throw `IllegalArgumentException`
when receiving an HTTP response with an unknown HTTP status code.

This commit is a follow up of SPR-16748 (supporting non-standard HTTP
status codes on the reactive `ClientHttpResponse`), and is mirroring
SPR-15978 (supporting non-standard HTTP status codes in `RestTemplate`).

With this change, `WebClient` now tolerates unknown status codes in some
cases, while not offering that choice as a first class citizen:
`HttpStatus` is still the preferred way to deal with HTTP status codes.

Here's how `WebClient` will behave when fetching the full response:

```
// Given a remote endpoint returning a "123" HTTP status code
Mono<ClientResponse> result = this.webClient.get()
				.uri("/status/123")
				.exchange();

// will still throw an IllegalArgumentException
HttpStatus status = result.block().statusCode();

// is safe and will return 123
int statusCode = result.block().rawStatusCode();
```

Resolving directly the response body with `retrieve()` is different.

```
// will send an error signal with a UnknownHttpStatusCodeException
Mono<String> result = this.webClient.get()
				.uri("/status/123")
				.retrieve()
				.bodyToMono(String.class);
```

In general, `WebClient` will provide high-level support
for well-known HTTP status codes, like error handling with
`WebClient.ResponseSpec#onStatus`.

For such support with unknown status codes, it is better to rely
on lower level constructs such as `ExchangeFilterFunction`.

Issue: SPR-16819
2018-07-12 19:08:08 +02:00
Rossen Stoyanchev 1b1bc7f5b5 Switch defaults and model for logging sensitive data
Issue: SPR-17029
2018-07-11 11:10:03 -04:00
xiexed d5df097e0e Small typo fixes in WebSocketHandler doc 2018-07-09 14:27:23 -04: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 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 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