Commit Graph

538 Commits

Author SHA1 Message Date
igor-suhorukov 4c888d0f32 Polish
Closes gh-1669
2018-02-09 10:10:05 +01:00
Rossen Stoyanchev 1653a32a04 Stabilize Flux.interval emissions in integration tests
After this commit the use of interval in tests is combined with
take(n).onBackpressureBuffer(n) to ensure emissions don't fail if the
fixed rate is exceeded (e.g. on slow CI server).

Tests that verify N number of items followed by verifyOnComplete()
should set the number of emissions to N.

Tests that verify N number of items followed by thenCancel() should
set the number of buffered to an arbitrary number greater than N.
2018-02-06 11:01:19 -05:00
Arjen Poutsma 609f173ebc StringDecoder shouldn't chop off strings randomly
Issue: SPR-16337
2018-02-02 15:59:21 +01:00
Juergen Hoeller c5a33d62dd TypeVariablesVariableResolver compares variables by full equality again
Issue: SPR-16456
2018-02-02 12:41:43 +01:00
Juergen Hoeller 7f96827ade Polishing 2018-02-02 11:34:03 +01:00
sdeleuze b6c78452b2 Update and improve script templating documentation
Issue: SPR-16447
2018-01-31 17:57:41 +01:00
sdeleuze b2681e1f4a Add ViewResolverRegistry#scriptTemplate in WebFlux
Issue: SPR-16431
2018-01-31 10:38:08 +01:00
sdeleuze d02e4fb545 Add Vary:Access-Control-Request-Method/Headers CORS headers
This commit adds these 2 Vary headers in addition to the existing
Origin one to avoid caching of Access-Control-Request-Method and
Access-Control-Request-Headers headers which can be an issue
when allowed methods or headers are unbounded and only the
requested method or headers are returned in the response.

Issue: SPR-16413
2018-01-30 17:00:32 +01:00
sdeleuze 32f6ccece8 Add WebFlux support for Smile streaming
The commit brings following changes:
 - Move getDecodableMimeTypes() to AbstractJackson2Decoder
 - Move getEncodableMimeTypes() to AbstractJackson2Encoder
 - Add support for application/stream+x-jackson-smile
 - Avoid streaming line separator when Smile encoder is used
 - Use double null token in Jackson2Tokenizer to identify documents

Issue: SPR-16151
2018-01-29 18:56:25 +01:00
Rossen Stoyanchev 00b95b10a8 Docs: result handling and view resolution
Issue: SPR-16393
2018-01-26 22:14:14 -05:00
Rossen Stoyanchev fbde97f302 Default order 0 for ServerResponseResultHandler
Issue: SPR-16420
2018-01-26 17:06:01 -05:00
Juergen Hoeller 91e6274b7d Upgrade to Apache HttpClient 4.5.5 and Tomcat 8.5.27 2018-01-22 22:11:00 +01:00
Juergen Hoeller 61579ffe7b Polishing 2018-01-22 21:34:44 +01:00
Juergen Hoeller 9d0e62ef68 Javadoc format and related polishing 2018-01-22 11:43:21 +01:00
Arjen Poutsma 0befc60c8f Renamed DataBufferUtils/DataBufferFactory.compose to join
Issue: SPR-16365
2018-01-22 10:51:07 +01:00
Arjen Poutsma c53c8bfc5a Set 304 status on ServerResponse when ETag/LastModified match
This commit checks the Etag/LastModified headers on the incoming
request, and sets a 304 Not Modified status with no body when they
match, by delegating to ServerWebExchange.checkNotModified.

Issue: SPR-16348
2018-01-18 11:34:38 +01:00
Arjen Poutsma c211e3998b Polishing 2018-01-18 11:34:38 +01:00
Arjen Poutsma 61d330f805 Javadoc 2018-01-18 11:34:38 +01:00
Juergen Hoeller ea5f8f5a7c Consistently handle NoClassDefFoundError in BeanUtils and related places
Issue: SPR-16369
2018-01-17 20:24:57 +01:00
Juergen Hoeller 9623cdec48 Functional response builders allow for non-standard HTTP status codes
Issue: SPR-16366
2018-01-14 17:45:58 +01:00
Juergen Hoeller 4c9ed0d87e Polishing 2018-01-12 18:24:00 +01:00
Arjen Poutsma 67e7c784e8 Use DataBufferUtils.compose and remove writeAggregator
Use DataBufferUtils.compose instead of writeAggregator to combine
multiple data buffers into one, as the write aggregator would not work
when the initial data buffer did not have enough capacity to contain
all subsequent buffers.

Removed writeAggregator, as it is no longer needed.

Issue: SPR-16365
2018-01-12 10:36:09 +01:00
Rossen Stoyanchev 84b8ceca0f Update Javadoc for AbstractHandlerMapping properties
Clarify what PathPatternParser is used for which is CORS checks in the
very least. Some sub-classes will also use it for request mapping but
not all (e.g. RouterFunctionMapping). Hence the need to be more
explicit.
2018-01-11 12:41:04 -05:00
Rossen Stoyanchev 72e3c43375 Refine @EnableWebFlux docs for functional endpoints
@EnableWebFlux bootstraps both annotated controllers and functional
endpoints, so we need to be more explicit about which parts of the
configuration apply to which.

Issue: SPR-16360
2018-01-11 12:25:42 -05:00
Arjen Poutsma f7bf6460aa Reverted signature change on fromMultipartData
Reverted back from `MultiValueMap<String, Object>` to
`MultiValueMap<String, ?>`
2018-01-10 17:54:51 +01:00
Rossen Stoyanchev b36af8a11f Uncomment test after Reactor Netty fix
Issue: SPR-16246
2018-01-10 10:47:36 -05:00
Arjen Poutsma 8a129ef3da Use write aggregator from DataBufferUtils
This commit uses the newly introduced write aggregator from
DataBufferUtils throughout WebFlux.

Issue: SPR-16351
2018-01-10 11:15:47 +01:00
Rossen Stoyanchev 30c0616384 Improve error message
Issue: SPR-16214
2018-01-08 21:30:41 -05:00
Rossen Stoyanchev 446e7ed25c Links from @RequestMapping to reference docs
Issue: SPR-16266
2018-01-08 09:29:52 -05:00
Rossen Stoyanchev 93a522f336 Fix regression in BodyInserters with multipart data
The issue was introduced very recently with commit #7035ee but never
released.

Issue: SPR-16350
2018-01-05 13:59:14 -05:00
sdeleuze deac8e556e Improve Kotlin extensions doc about type erasure
Since type erasure can be fixed only when using
ParameterizedTypeReference based Java methods, RestOperations and
WebFlux API documentation should be updated to specify which extensions
are subject to type erasure, and which are not.

Issue: SPR-16273
2017-12-27 17:49:18 +01:00
Rossen Stoyanchev f389f66270 Upgrade to Reactor Bismuth snapshots
This allows us to confirm 0.7.3 fixes and run tests against the latest
ahead of an upgrade to Reactor Netty 0.8 snapshots.

The fix for #231 and #240 are confirmed but unfortunately test case for
2017-12-22 12:50:18 -05:00
Arjen Poutsma 7035ee7ebb Support Publishers for multipart data in BodyInserters
This commit uses the changes in the previous commit to support
Publishers as parts for multipart data.

Issue: SPR-16307
2017-12-21 17:41:01 +01:00
Juergen Hoeller 9d27e86951 Upgrade to Hibernate Validator 6.0.7 2017-12-21 17:00:06 +01:00
sdeleuze 99cbfd32c3 Set default view content-type with WebFlux fn
With this commit, the default content-type defined by the
view (usually "text/html;charset=UTF-8" defined in AbstractView)
is used if any, when none is defined in the response headers.

Issue: SPR-16247
2017-12-19 11:11:40 +01:00
Juergen Hoeller 3a51b5a9d2 Upgrade to Hibernate Validator 6.0.6 2017-12-15 15:58:12 +01:00
Rossen Stoyanchev f05175586e Refine behavior on error after response committed
If the response is set and we can't change the status through
ServerHttpResponse any more, allow the error signal to propagate and
let the individual server adapters handle it. Ultimately that should
result in closing the connection.

On Servlet containers, we check one last time if the response is
committed (we may not have filled the buffer). If not then save
the exception as a request attribute, dispatch, and re-throw it on the
container thread.

On Undertow access the connection and close it.

On Netty just let the error through to Reactor Netty.

Issue: SPR-16051
2017-12-12 14:51:24 -05:00
Rossen Stoyanchev fda08852ba Take content-type from ResponseEntity unconditionally
From #9a894a we began using the content-type from the ResponseEntity
but cross-checking it still against the requested content type.

Arguably there isn't any purpose in cross-checking. The only possible
outcomes are: a) it's compatible or b) it's not, which would result in
406 (NOT_ACCEPTABLE). As we've been given explicitly the media type to
use, it makes little sense to send 406, ignoring the wish to use that
content type.

Issue: SPR-16251
2017-12-02 00:43:43 -05:00
Rossen Stoyanchev 91d3e4402f Add test case for SPR-16246 2017-12-01 15:40:35 -05:00
Rossen Stoyanchev 44c95a4736 Adjust logging to catch sporadic PERF build failure 2017-12-01 10:11:51 -05:00
Rossen Stoyanchev 3650ecc3bb Polish 2017-11-28 22:16:07 -05:00
Juergen Hoeller a8323f6a27 Latest dependency updates (OkHttp 3.9.1, JRuby 9.1.14, Rome 1.9) 2017-11-26 16:03:48 +01:00
Rossen Stoyanchev 01a82b5291 Improve semantics writing currentData
Before this commit, the return value from write was interpreted as the
data being fully written and ready to be released via releaseData().

This is not true for WebSocketSession implementations where a true
return value simply means the message was sent with the full payload
but releas is not appropriate until a send confirmation.

Technically not an issue since WebSocketSession's extending this do
not use pooled buffers. Nevertheless this commit refines the semantics
of write, removes the releaseData() method, and makes sub-classes
responsible for releasing the buffer when fully written (and they
know best when that is). As a bonus currentData is now private.

Issue: SPR-16207
2017-11-23 10:55:03 -05:00
Rossen Stoyanchev c1b191edb0 Polish and improve logging 2017-11-22 23:25:36 -05:00
Rossen Stoyanchev f44366877c Switch to suspended mode before demand
After this commit, Tomcat and Undertow WebSocketSession imlpementations
start out in suspended mode and wait for demand.

The JettyWebSocketSession is capable of suspending but it doesn't seem
to work if invoked before any messages are received. That may become an
issue if there is a case where no demand appears long enough for more
messages to accumulate than we can hold.

UnderowServerHttpRequest would ideally also start in suspended mode but
that also doesn't work. It is not an issue in this case since we can
ignore the read notifications.

Servlet API requires a proactive check before it calls you back so
there is no need to suspend.

Issue: SPR-16207
2017-11-22 17:55:20 -05:00
Rossen Stoyanchev afdca285e5 Avoid resume-suspend race condition
This commit turns suspendReading() into a readingPaused() notification
that is invoked after a succession of reads stops because there is no
more demand. Sub-classes can use this notification to suspend, if that
applies to them.

Most importantly the notification is guaranteed not to overlap with
checkOnDataAvailable() which means that suspend does not need to be
atomic and guarded against resume. The two can and do compete all the
time when reading ends with no demand, and a request for demand arrives
concurrently.

Issue: SPR-16207
2017-11-22 17:48:03 -05:00
sdeleuze 652e5c5584 Disable CORS credentials by default
Access-Control-Allow-Credentials CORS header, used to
allow cookies with CORS requests, is not set to true
anymore by default when enabling CORS with
@CrossOrigin or global CORS configuration in order to
provide a more secured default CORS configuration.

The related allowCredentials property now requires to
be set to true explicitly in order to support cookies
with CORS requests.

Issue: SPR-16130
2017-11-22 22:46:44 +01:00
Rossen Stoyanchev b7c924cac1 Polish 2017-11-21 23:20:13 -05:00
Violeta Georgieva d8099adc9a AbstractListenerWebSocketSession: suspend the channel when there is no demand
Issues: SPR-16207
2017-11-21 22:59:33 -05:00
Rossen Stoyanchev b89a48a703 Improve FlushingIntegrationTests 2017-11-21 22:12:33 -05:00
sdeleuze 9f1d8517ba Polish Kotlin source code style 2017-11-21 15:59:23 +01:00
Rossen Stoyanchev bc8e525e60 Add shared instance of ReactiveAdapterRegistry
Issue: SPR-16218
2017-11-20 17:02:22 -05:00
Juergen Hoeller 14a7da8183 Upgrade to Hibernate Validator 6.0.5 2017-11-19 21:16:10 +01:00
Rossen Stoyanchev ce895d7a84 Add mention of shortcut methods in BodyInserters 2017-11-17 10:43:53 -05:00
sdeleuze c530745015 Fix JsonView + HttpEntity Reactive handling
This commit adds
AbstractMessageReaderArgumentResolver#readBody and
AbstractMessageWriterResultHandler#writeBody variants
which allow to pass the actual MethodParameter in order
to perform proper annotation-based hint resolution with
nested generics, for example with HttpEntity.

Issue: SPR-16098
2017-11-16 15:12:58 +01:00
Rossen Stoyanchev 8e21023f28 Update docs on ClientResponse
Issue: SPR-16200
2017-11-15 17:08:57 -08:00
Rossen Stoyanchev 6e05a5881e Update WebClient Javadoc
Issue: SPR-16197
2017-11-15 15:09:01 -08:00
sdeleuze 9dd29f76ae Polish CORS documentation 2017-11-15 16:16:13 +01:00
Rossen Stoyanchev fb7b7d089b Revert erroneously committed change 2017-11-14 08:42:04 -05:00
Rossen Stoyanchev 536e72c8df Add WebSocket chapter to WebFlux section
Issue: SPR-15700
2017-11-13 23:20:01 -05:00
Rossen Stoyanchev 5e86049438 Expose WebSocket options for Tomcat/Jetty 2017-11-13 23:20:01 -05:00
Rossen Stoyanchev e818b904ad Polish WebSocket-related 2017-11-13 23:20:01 -05:00
Rossen Stoyanchev 9a894ab61e Use ResponseEntity Content-Type as producible media type
Issue: SPR-16172
2017-11-10 15:05:03 -05:00
Rossen Stoyanchev f565f635e3 Polish 2017-11-10 11:29:58 -05:00
Rossen Stoyanchev ff97eafa4f Fix NPE in ErrorsArgumentResolver
Issue: SPR-16187
2017-11-10 10:57:26 -05:00
Rossen Stoyanchev a5103307c6 Polish ErrorArgumentResolver 2017-11-10 10:15:46 -05:00
Rossen Stoyanchev 8cfa3c632b Allow Undertow client in websocket integration tests
It seems to work.
2017-11-09 17:49:11 -05:00
Rossen Stoyanchev cb34b0b963 Polish 2017-11-09 17:16:31 -05:00
anton_bondarenko b487db294b Fix NullPointer when setting cookies in RequestUriSpec 2017-11-09 16:59:44 -05:00
Rossen Stoyanchev 807297f173 Remove RxNetty (from test sources)
Practically no changes to RxNetty for a year and efforts underway to
rebuild 0.6.x based on a current Reactor Netty base.

Aside from the extra time to run integration tests having two
Netty-based servers can also cause false alarms such as ByteBuf leaks
related to RxNetty.
2017-11-09 15:56:56 -05:00
Arjen Poutsma db00669197 Allow to set cookies in ServerResponse
Issue: SPR-16121
2017-11-09 11:04:02 +01:00
Rossen Stoyanchev 9786750b5a Improve @RequestAttribute WebFlux resolver
The resolver now takes into account the possibility the attribute
itself may be a reactive type.

Issue: SPR-16158
2017-11-06 21:44:45 -05:00
Rossen Stoyanchev 14f02d7192 Update reference with examples of multipart requests
Issue: SPR-16118
2017-11-06 16:33:58 -05:00
Arjen Poutsma af2e296ff3 Javadoc 2017-11-06 16:00:18 +01:00
Rossen Stoyanchev 8c33ed02b3 ServletHttpHandlerAdapter supports Serlvet path mapping
Issue: SPR-16155
2017-11-02 20:53:26 -04:00
Rossen Stoyanchev aa653b23bc Add AbstractReactiveWebInitializer
This commit introduces a new AbstractReactiveWebInitializer in
spring-web that relies on WebHttpHandlerBuilder to detect request
processing infrastructure beans from an ApplicationContext.

This eliminates the need to create a DispatcherHandler, since it is
expected to be a Spring bean, and as a result the initializers in
spring-webflux have been deprecated.

Issue: SPR-16144
2017-11-02 14:57:06 -04:00
Arjen Poutsma a58002a5de Chained API for form and multipart data in BodyInserters
Issue: SPR-16133
2017-11-01 13:17:52 +01:00
Rossen Stoyanchev 48c2cc18b9 Update form + multipart data Javadoc on BodyInserters
Issue: SPR-16118
2017-10-31 09:21:09 -04:00
Rossen Stoyanchev 8083eaae54 syncBody better differentiates plain vs multipart forms
FromHttpMessageWriter and MultipartHttpMessageWriter both support
MultiValueMap except the former supports String values only. This
presents an issue since either full generic type information must be
provided, which is cumbersome on the client side, or if left out there
is no good way to order the writers to make a proper decision.

This commit:

- refines the canWrite behavior of   to not a
accept MultiValueMap without proper generic information unless the
MediaType is explicitly set providing a strong hint.

- modifies MultipartHttpMessageWriter to be configured with a
FormHttpMessageWriter so it can write both plan and multipart data with
the ability to properly differentiate based on actual map values.

Issue: SPR-16131
2017-10-31 09:12:05 -04:00
Juergen Hoeller e5c8dc0d65 MessageSource.getMessage returns null default message as-is (again)
Issue: SPR-16127
2017-10-31 11:06:42 +01:00
Juergen Hoeller 9bab7a2708 Upgrade to Java Activation Framework 1.2 for test runtime
Includes upgrade to Hibernate Validator 6.0.4 (where applicable)

Issue: SPR-16115
2017-10-25 19:18:10 +02:00
Arjen Poutsma 6457a1556e Javadoc 2017-10-24 10:59:47 +02:00
Arjen Poutsma 40a6fba443 Allow to change URL/method in ClientRequest.Builder
This commit exposes the ClientRequest's URL and HttpMethod fields via a
setter, so that they can be changed more easily in a request that was
created via ClientRequest.from(ClientRequest).

Issue: SPR-16093
2017-10-23 16:39:33 +02:00
Rossen Stoyanchev 1cc5afe24b Fix lines over 120 characters
https://github.com/spring-projects/spring-framework/wiki/Spring-Framework-Code-Style#line-wrapping
2017-10-20 16:42:26 -04:00
Juergen Hoeller e17ad551f3 Latest dependency updates (RxJava 1.3.3, Hibernate ORM 5.2.12, Hibernate Validator 5.4.2 & 6.0.3) 2017-10-20 16:16:06 +02:00
Juergen Hoeller d1fac36e3e SchedulingConfigurer and JmsListenerConfigurer respect @Order
Issue: SPR-16090
2017-10-20 16:10:12 +02:00
Rossen Stoyanchev 48eb416ecc Fix failing tests 2017-10-19 21:42:31 -04:00
Rossen Stoyanchev ab92754a2e @MatrixVariable resolvers for WebFlux
The information was already parsed and available in a request attribute
but until now there were no argument resolvers to expose it.

Issue: SPR-16005
2017-10-19 21:01:38 -04:00
Rossen Stoyanchev d8a7b96b46 WebFlux support for "request handled" in controller
Issue: SPR-16087
2017-10-18 21:07:27 -04:00
Rossen Stoyanchev 950edf888a Support for Map method argument in WebFlux
Issue: SPR-16086
2017-10-18 11:41:46 -04:00
Rossen Stoyanchev 32d78e60b6 Update information on WebApplicationContext hierarchy
Issue: SPR-16041
2017-10-17 21:49:57 -04:00
Rossen Stoyanchev 94c4a7f941 Shortcut factory method in MockServerWebExchange
MockServerWebExchange now has a second factory method that accepts a
MockServerHttpRequest.BaseBuilder.

Issue: SPR-16079
2017-10-17 12:23:12 -04:00
Juergen Hoeller 3890d4c9eb AbstractServerHttpResponse stores HTTP status code as integer value
Issue: SPR-16073
2017-10-16 15:34:09 +02:00
Arjen Poutsma faa74988c4 WebClient.mutate() should not impact future .mutate() invocations
Before this commit, when adding filters to a builder obtained via
`WebClient.mutate()`, the filters were added both to the original client
as well as the mutated builder. This commit fixes that.

Issue: SPR-16059
2017-10-13 11:23:10 +02:00
Brian Clozel 3febec3df6 ResourceWebHandler signals error for missing resources
Prior to this commit, the `ResourceWebHandler` would itself handle the
response with an HTTP 404 in many cases, including a missing static
resource.

This does not give a chance to `WebExceptionHandler` instances to handle
that error and, for example, display an error page.

See spring-projects/spring-boot#8625

Issue: SPR-16023
2017-10-10 23:28:03 +02:00
Rossen Stoyanchev 48c41049b1 Correct package for MockServerWebExchange
Discovered late, but not too late. MockServerWebExchange is now in the
proper package matching to the location of ServerWebExchange.
2017-09-29 17:03:23 -04:00
Rossen Stoyanchev 223e27d53d Package private request and response implementations
Concrete server and client, reactive request and response
implementations should not have to be accessed outside their package.
They could be seen as private to their HttpHandler adapters and
ClientHttpConnector's respectively.

The one exception, WebSocket upgrades in spring-webflux, is an internal
framework use case, accommodated via downcast + accessors in the
abstract base classes.
2017-09-29 13:04:03 -04:00
Arjen Poutsma 69945f4185 WebClient throws ClassCastException for bodyToMono(ParameterizedTypeReference)
Prior to this commit, the `WebClient` always throws a `ClassCastException`
when an error occurs in `bodyToMono(ParameterizedTypeReference)``, and
not the expected exception, as set up by `onStatus`

Issue: SPR-16025
2017-09-29 10:15:40 +02:00
Rossen Stoyanchev d332e06f6c Update reference after removal of ClientResponse.close() 2017-09-28 16:11:48 -04:00
Rossen Stoyanchev 869b818e96 WebFlux support for LocaleContext related arguments
Issue: SPR-15998
2017-09-27 22:03:42 -04:00