Commit Graph

363 Commits

Author SHA1 Message Date
Brian Clozel 81125de697 Fix error responses handling in WebClient
This commit fixes a typo in the `DefaultWebClient` implementation.
Instead of forwarding resolved `WebClientException` instances as error
signals, the `bodyToMono(ParameterizedTypeReference)` variant would just
forward those exceptions as `onNext` signals.

Issue: SPR-15946
2017-09-14 14:15:05 +02:00
Brian Clozel 98b6491f0c Send error signal also for empty server responses
Prior to that commit, the `ResponseSpec` `WebClient` would process error
responses (4xx, 5xx HTTP status) and transform those into error signals
with a `WebClientResponseException`. But this would only work if the
HTTP response would have a non-empty response body.

An empty error response would not send an error signal and only
translate in an `onComplete` signal.

This commit fixes this behavior and makes sure that this error signal is
sent in all cases.

Issue: SPR-15946
2017-09-13 10:56:57 +02:00
Brian Clozel aa19912e00 Polish 2017-09-13 10:51:13 +02:00
Rossen Stoyanchev e214d69350 Remove jetbrains annotations inserted by IDE 2017-09-11 09:31:43 -04:00
Rossen Stoyanchev f76ac5bb32 WebFlux support for @SessionAttributes
Issue: SPR-15887
2017-09-09 17:40:59 -04:00
Rossen Stoyanchev bc470fca30 Polish 2017-09-09 17:40:59 -04:00
Juergen Hoeller fd0132c7e6 Polishing 2017-09-08 16:56:22 +02:00
Juergen Hoeller 496223a927 WebFlux supports field default/marker parameters for data classes as well
Issue: SPR-15871
2017-09-08 16:55:12 +02:00
Sam Brannen 15ab0ad6e2 Clean up warnings in Gradle build output 2017-09-07 12:25:10 +02:00
Brian Clozel 16f3f8d28f Add close() method on HTTP client response
Before this commit, there was no way to signal the HTTP client that we
were done consuming the response. Without that, the underlying client
library cannot know when it is safe to release the associated resources
(e.g. the HTTP connection).

This commit adds new `close()` methods on both `ClientHttpResponse`
and `ClientResponse`. This methods is non-blocking and its behavior
depends on the library, its configuration, HTTP version, etc.

At the `WebClient` level, `close()` is called automatically if we
consume the response body through the `ResponseSpec` or the
`ClientResponse` itself.

Note that it is *required* to call `close()` manually otherwise; not
doing so might create resource leaks or connection issues.

Issue: SPR-15920
2017-09-06 17:29:18 +02:00
Arjen Poutsma 02a2c400c7 Move URL transform methods from ServerHttpResponse to ServerWebExchange
This commit moves `encodeUrl` and `registerUrlEncoder` from
ServerHttpResponse to ServerWebExchange.

It also renames `encodeUrl` to `transformUrl` and `registerUrlEncoder`
to `addUrlTransformer` to make it clearer that these methods do not
perform actual URL encodings (i.e. they do not replaceinvalid
characters).
The `add` prefix (instead of `register`) makes it clearer that each
function is added in addition to the previous one.

Issue: SPR-15924
2017-09-06 14:39:09 +02:00
Rossen Stoyanchev 03eb6f76db Improve check for actual return value type
Issue: SPR-15910
2017-09-05 16:11:35 -04:00
Rossen Stoyanchev fc0841c60f Adapt to method name change in Mono 2017-09-05 13:57:20 -04:00
Arjen Poutsma 14af5d941a Javadoc
Issue: SPR-15912
2017-08-31 13:55:19 +02:00
Juergen Hoeller b122bc6dcc Upgrade to Hibernate Validator 6.0.2
Includes latest dependency updates (Netty 4.1.15, Undertow 1.4.19)

Issue: SPR-15808
2017-08-29 15:04:17 +02:00
Sebastien Deleuze d2c1b284f3 Polish Kotlin API contracts and documentation
Issue: SPR-15659
2017-08-29 00:56:39 +02:00
Brian Clozel 397fd24849 Revert "Leverage Kotlin plugin dependency management"
This reverts commit 3e2f6c848a.
2017-08-22 21:29:39 +02:00
Sebastien Deleuze 3e2f6c848a Leverage Kotlin plugin dependency management 2017-08-22 17:35:57 +02:00
Stephane Nicoll 5a51351fa4 Relax test assertion when Jacoco is enabled
This commit changes the resolveMethod to take a method name as
instrumentation may add additional methods to the test object.

Issue: SPR-15888
2017-08-22 10:26:19 +02:00
Sebastien Deleuze 9abe77670c Sync with reactor-core when() -> zip() change 2017-08-21 19:54:08 +02:00
Brian Clozel cc3d7d2d48 Apply dependency management to selected modules
This commit applies the Dependency Management Plugin to modules that
require it; right now Spring Framework is importing BOMs for Netty and
Reactor dependencies only.

Instead of applying those BOMs to all modules, they're applied only
where they're needed.

Issue: SPR-15885
2017-08-21 14:42:03 +02:00
Brian Clozel 2eeb428e95 Move modules to independent build files
The main `build.gradle` file contains now only the common build
infrastructure; all module-specific build configurations have
been moved to their own build file.

Issue: SPR-15885
2017-08-21 14:41:55 +02:00
Stephane Nicoll f6e7fef236 Polish 2017-08-19 10:50:41 +02:00
Juergen Hoeller 47a7475898 Resolve remaining nullability warnings
Issue: SPR-15869
2017-08-18 00:15:46 +02:00
Sebastien Deleuze 73cf07e9a4 Fix overridden methods nullability
Issue: SPR-15869
2017-08-17 15:02:59 +02:00
Rossen Stoyanchev 645e3492db Use URLDecoder for query params in WebFlux
Issue: SPR-15860
2017-08-16 13:34:31 +02:00
Sebastien Deleuze f57e5584af Add a reference to KT-18833 in JDK 9 ignored tests 2017-08-14 11:47:08 +02:00
Juergen Hoeller adeb521ce4 Polishing 2017-08-08 17:27:28 +02:00
Rossen Stoyanchev 08dfce2cb5 Dedicated specificity comparator in PathPattern
The PathPattern compareTo method is now consistent with equals when
two patterns are of the same specificity but otherwise different.

Separately PathPattern now exposes a Comparator by specificity that
offers the current functionality of compareTo. This can be used for
actual sorting where we only care about specificity.
2017-08-02 18:11:36 +02:00
Rossen Stoyanchev 62fa20fd6f PathPattern#matchAndExtract minor refactoring
Consistent behavior with matches(PathContainer), the two had slightly
different logic for handling of empty paths.

Make matchAndExtract independantly usable without the need to call
matches(PathContainer) first. Essentially no longer raising ISE if the
pattern doesn't match but simply returning null.
2017-08-02 16:31:06 +02:00
Rossen Stoyanchev dccedd5ad5 Minor refactoring in PathPattern
Rename getPathRemaining to matchStartOfPath since the method does
match and to be more clear about what the method and the return value
intuitively follows.

Remove matchStart which matches the start of the pattern (rather than
the start of the path). It is a use case that does not come up in
request mapping.
2017-08-02 15:05:28 +02:00
Rossen Stoyanchev c060f4f615 Polish PathPattern and parser
Updates to Javadoc
Consistent and separator type neutral naming for trailing slash
PathPattern extracts options from the parser instance
2017-08-02 14:21:16 +02:00
Arjen Poutsma 5394cc0c63 WebClientException should allow access to status code of the response
This commit changes the WebClient so that it now throws a
`WebClientResponseException` for `ResponseSpec.bodyTo`. This newly
introduces exception contains the status code, headers, and body of the
response message.

As a consequence of the above, we had to change `onStatus` so that the
`exceptionFunction` now returns a `Mono<Throwable>` rather than a
`Throwable`, which it was before. The Mono allows for asynchronous
operations, such as reading the contents of the body.

Issue: SPR-15824
2017-08-02 10:20:58 +02:00
Rossen Stoyanchev b1440b6816 Remove ParsingPathMatcher
Now that we also have RequestPath and PathContainer with the latter as
the required input, the ParsingPathMatcher adapter can be removed.
2017-08-01 13:35:21 +02:00
Rossen Stoyanchev 4fc0ce1206 Properly detect null value params in params conditions
Issue: SPR-15831
2017-08-01 13:01:09 +02:00
Rossen Stoyanchev f813a63fd8 PathContainer parses URL paths only
Collapse non-URL vs URL based path parsing into one essentially
supporting URL paths only.
2017-07-31 22:10:08 +02:00
Arjen Poutsma 0b3ea405ab Remove BodyInserters.fromServerSentEvent variants
Removed superfluous `fromServerSentEvent` variants from `BodyInserters`,
as their functionality can also be obtained by passing a stream of
strings or POJOs (to be encoded as JSON) to
`fromPublisher(Publisher, Class)}`, and specifying a `text/event-stream`
Content-Type.

Issue: SPR-15826
2017-07-28 12:37:19 +02:00
Rossen Stoyanchev 6855a85c41 Move RequestPath to parent server package 2017-07-28 12:26:34 +02:00
Sebastien Deleuze 6583f9f754 Use ParameterizedTypeReference instead of Class in Kotlin extensions
This commit also removes WebFlux non-extension functions in favor of
regular Kotlin extensions leveraging ParameterizedTypeReference parameter.

Issue: SPR-15818
2017-07-28 00:22:00 +02:00
Arjen Poutsma 1d86c9c3d1 Use Credentials object instead of 2 attributes for Basic Authentication
This commit changes the usage of two separate attributes (username and
password) into one: a single `Credentials` object.
Additionally, the attributes key under which the credentials are stored
is changed to be specific to Basic Authentication, in order to allow for
other sorts of authentication later.

Issue: SPR-15764
2017-07-27 16:09:09 +02:00
Sebastien Deleuze 3cef5a1294 Add RouterFunctions#toWebHandler(RouterFunction<?>) 2017-07-27 15:25:35 +02:00
Arjen Poutsma eb435f5947 Add ParameterizedTypeReference method variants to ServerRequest/ServerResponse
This commit changes adds overloaded `ParameterizedTypeReference `
variants to body-related methods in `ServerRequest` and
`ServerResponse`.
It also adds a single PTR variant to ClientRequest, which was missing
before.

Issue: SPR-15817
2017-07-27 13:38:35 +02:00
Arjen Poutsma f3975776d4 Use list of HttpMessage[Reader|Writer]s instead of CodecConfigurer
This commit changes all consumers of CodecConfigurer to consume a `List`
of HttpMessageReaders or HttpMessageWriters instead of consuming the
Server- or ClientCodecConfigurer directly.

Issue: SPR-15816
2017-07-26 17:48:36 +02:00
Sebastien Deleuze ed6fe2b723 Upgrade to Kotlin 1.1.4-eap-33
Issue: SPR-15814
2017-07-24 17:29:02 +02:00
Sebastien Deleuze d8a80fc0db Rename RouterFunction Kotlin DSL files 2017-07-20 16:05:00 +02:00
Sebastien Deleuze 0720f9e978 Fix an eventual IndexOutOfBoundsException in RequestPredicates 2017-07-20 16:05:00 +02:00
Rossen Stoyanchev 378c72e9b6 Polish + minor refactoring of ResourceUrlProvider 2017-07-19 23:04:39 +02:00
Juergen Hoeller ac1d3b22c9 Polishing 2017-07-19 22:22:27 +02:00
Juergen Hoeller 46eba3dbfa Nullability fine-tuning around declaration inconsistencies
Issue: SPR-15720
Issue: SPR-15792
2017-07-19 22:22:20 +02:00
Rossen Stoyanchev 147368eccc Proactively reject URLs without target address
Issue: SPR-15782
2017-07-19 12:37:32 +02:00