Commit Graph

75 Commits

Author SHA1 Message Date
Rossen Stoyanchev
9eb07b7780 Update package for reactor Signal 2015-12-29 23:13:21 -05:00
Stephane Maldini
da4e4aab39 test operator log 2015-12-18 16:56:17 +00:00
Rossen Stoyanchev
69973d984d Fix test failure 2015-12-16 12:30:15 -05:00
Rossen Stoyanchev
1b3289d0d5 Add InternalServerErrorExceptionHandler 2015-12-15 17:04:53 -05:00
Rossen Stoyanchev
f2cd92a243 Fix imports 2015-12-15 12:09:23 -05:00
Rossen Stoyanchev
c13a8c9bb4 DispatcherHandler maps errors to ResponseStatusException
The DispatcherHandler now has an errorMapper property that is a
function for transforming errors. By default this property is set to an
instance of DispatcherHandlerExceptionMapper which wraps "standard"
framework exceptions and @ResponseStatus-annotated exceptions as
ResponseStatusException.

This makes it easy to handle the exceptions downstream uniformly.
2015-12-15 12:08:13 -05:00
Rossen Stoyanchev
1f15b7e074 Add ResponseStatusException
This change adds a ResponseStatusException to associate an exception
with a status code at runtime. Along with that is an
ResponseStatusExceptionHandler that handles ResponseStatusException
by setting the response status.
2015-12-15 12:06:53 -05:00
Rossen Stoyanchev
5231e7da7b Fix failing test 2015-12-10 16:50:28 -05:00
Rossen Stoyanchev
a0018d13e1 Add DispatcherHandlerErrorTests
The tests demonstrate failures at various phases of request processing
and the resulting error signals.
2015-12-10 16:35:40 -05:00
Rossen Stoyanchev
4ba3d0736f Add HttpExceptionHandler 2015-12-10 16:35:40 -05:00
Rossen Stoyanchev
448aac813a Add MockServerHttpRequest/Response 2015-12-10 16:35:40 -05:00
Rossen Stoyanchev
ef3560a55a Add HttpHandlerDecorator and fix test package 2015-12-08 22:50:25 -05:00
Rossen Stoyanchev
ad4be9462b Drop use of WebApplicationContext in tests
It brings along Servlet imports.
2015-12-08 14:33:23 -05:00
Rossen Stoyanchev
45706422dd InvocableHandlerMethod and arg resolution updates
General improvements e.g. make use of Java 8 Stream. The main reason
for the refactoring however to tighten error handling. To that extent:

InvocableHandlerMethod turns all exceptions into Reactive Streams
error signals, in effect never allowing any Exceptions to bubble up.

HandlerMethodArgumentResolver may throw an Exception for sync resolution
or produce an error signal via the returned Publisher. Either way the
exception is consistently wrapped with helpful method argument details.
For the latter case using a custom mapError operator.

HandlerMethodArgumentResolver no longer needs to return Optional for
nullable argument values. Instead (for now) the defaultIfEmpty operator
of reactor.rx.Stream operator is used to ensure a default constant value
(called "NO_VALUE") is produced. That way an argument resolver may
produce 0..1 values where 0 means it did not resolve to any value and
that results in null passed as the argument value.

If a HandlerMethodArgumentResolver produces more than one value, all
additional values beyond the first one will be ignored with the help
of a custom "first" operator.

As HandlerMethod is invoked within the map operator, checked exceptions
are not allowed but instead of wrapping it in a runtime exception what
we really need is to unwrap the target exception for exception
resolution purposes. To this end concatMap is used to produce a nested
Publisher or an error Publisher with the unwrapped target exception.

Related to that InvocableHandlerMethod now returns
Publisher<HandlerResult> instead of Publisher<Object> so that no longer
needs to be externally mapped from Object to HandlerResult.

InvocableHandlerMethodTests provides tests for the above scenarios and
verifies the details of resulting error signals.
2015-12-07 17:36:58 -05:00
Rossen Stoyanchev
da98becf72 Move http.server to http.server.reactive 2015-12-02 17:46:07 -05:00
Rossen Stoyanchev
71d1d11fac Non-blocking HandlerMapping chain 2015-12-01 07:34:35 -05:00
Sebastien Deleuze
91c2b7afad Support handler methods returning void, Observable<Void>, etc. 2015-11-30 15:35:58 +01:00
Rossen Stoyanchev
57dc8199fb Add ReactiveHttpFilter 2015-11-25 13:11:01 -05:00
Sebastien Deleuze
0f8a4bf706 Polish imports 2015-11-25 10:42:23 +01:00
Rossen Stoyanchev
d319edba28 HandlerMapping is now asynchronous 2015-11-24 17:36:44 -05:00
Sebastien Deleuze
dc57e2621c Move HttpServer related classes back to src/main/java
This is needed in order to be able to use Spring Reactive in standalone
applications. These are temporary classes that will return in
src/test/java when Spring Boot support for Reactive applications will
be implemented.
2015-11-24 18:11:44 +01:00
Rossen Stoyanchev
4a3c0bc3b6 Remove top-level org.springfamework.reactive package
reactive.codec -> core.codec
reactive.io    -> util

These may very well not be the final locations. For now they simply
express that there are classes that belong somewhere in core, i.e.
they are lower level dependencies than web.
2015-11-22 15:02:18 -05:00
Rossen Stoyanchev
8d30722f21 Remove @MVC test with multiple matches
RequestMappingHandlerMapping currently picks the first match and does
have logic to deal with selecting the best match. This caused a
random test failure depending on which controller method was matched
first. This change removes the test.
2015-11-20 13:17:10 -05:00
Rossen Stoyanchev
e9e4bcdc59 Move ~.web.reactive.server to ~.http.server 2015-11-20 13:10:44 -05:00
Rossen Stoyanchev
81867fa423 Refactor package structure for web
The web related code is now under org.springframework.web.reactive.
This is parallel to org.springframework.web (the top-level package of
spring-webmvc).
2015-11-13 17:49:31 -05:00
Sebastien Deleuze
c6713c23e3 Add a ResolvableType field to HandlerResult
This change allows to be able to check generic type on the return value
at HandlerAdapter and ResultHandler level. For example, it allows to do
a Publisher<Void> check in SimpleHandlerResultHandler.
2015-11-13 17:09:02 -05:00
Sebastien Deleuze
bdc5b38cb1 Refactor codecs
This commit introduces the following changes:
 - MessageToByteEncoder/Decoder renamed to Encoder/Decoder
 - JsonObjectEncoder/Decoder are now used directly in
   JacksonJsonEncoder/Decoder
 - Codec uses MimeType instead of MediaType since they
   are not specific to HTTP
 - Default MimeType are now managed thanks to
   Encoder/Decoder#getSupportedMimeTypes()
 - AbstractEncoder/Decoder takes care of generic MimeType related behavior
2015-11-13 15:01:02 -05:00
Marek Hawrylczak
4c84117155 undertow support using non-blocking API’s 2015-11-07 15:52:47 +01:00
Rossen Stoyanchev
a48c9b6305 Replace DefaultConversionService in spring-reactive 2015-10-30 17:58:59 -04:00
Rossen Stoyanchev
c0dff3d2bb Comply with Spring Framework code style
https://github.com/spring-projects/spring-framework/wiki/Spring-Framework-Code-Style
2015-10-30 17:22:19 -04:00
Rossen Stoyanchev
0989c8b3c2 HandlerMethodArgumentResolver is now asynchronous 2015-10-30 16:04:49 -04:00
Rossen Stoyanchev
6b73993a38 HandlerAdapter is asynchronous again 2015-10-30 15:02:54 -04:00
Arjen Poutsma
bd472af37e Updated Copyright notices 2015-10-30 09:26:34 +01:00
Arjen Poutsma
45a88974bc Changed addBody() to setBody() 2015-10-29 16:28:22 +01:00
Arjen Poutsma
bab3b6fd1c Introduce HttpMessage hierarchy
This commit introduces "reactive" sub-interfaces of the HttpMessage
interface found in the Spring Framework.
2015-10-29 15:45:28 +01:00
Stephane Maldini
3864fc24ff Fix JSON encoding issue 2015-10-29 11:10:38 +01:00
Stephane Maldini
fd52ae999b Update to latest reactor-net
Latest reactor-net doesn't depend on reactor-stream anymore (neither reactor-codec and reactor-bus, it only depends on reactor-core).
2015-10-29 11:10:19 +01:00
Sebastien Deleuze
adc50bbfb9 Add handler method parameter and result converters
This commit introduces the following changes:
 - Publisher -> Observable/Stream/etc. conversion is now managed
    in a dedicated ConversionService instead of directly in
    RequestBodyArgumentResolver and ResponseBodyResultHandler
 - More isolated logic that decides if the stream should be
    serialized as a JSON array or not
 - Publisher<ByteBuffer> are now handled by regular
   ByteBufferEncoder and ByteBufferDecoder
 - Handle Publisher<Void> return value properly
 - Ensure that the headers are properly written even for response
   without body
 - Improve JsonObjectEncoder to autodetect JSON arrays
2015-10-29 10:50:06 +01:00
Sebastien Deleuze
cf2c1514af Use latest Reactor core capabilities
No need for rxjava-reactive-streams dependency and
 CompletableFutureUtils anymore.
2015-10-19 11:15:03 +02:00
Sebastien Deleuze
07374f48d6 Move server related classes from src/test to src/main 2015-10-07 14:06:26 +02:00
Sebastien Deleuze
0dabdb8207 Add request method based mapping
Closes #22
2015-10-07 12:15:39 +02:00
Sebastien Deleuze
9516c9992f Return HandlerResult in HandlerAdapter#handle()
This commit updates HandlerAdapter#handle() to return HandlerResult
instead of Publisher<HandlerResult>. A new SimpleHandlerResultHandler
class has been introduced for handlers returning Publisher<Void>.
2015-10-02 20:09:27 +02:00
Stephane Maldini
d20fbffcd0 Update to Reactor 2.1.0.BUILD-SNAPSHOT 2015-09-29 23:31:02 +01:00
Stephane Maldini
4ffec61310 Update to 2.0.6 snapshot for Header sent too soon fix, which allows DispatcherHandler to assign content-type correctly. 2015-09-29 23:16:06 +01:00
Stephane Maldini
20c4011094 initialize reactor support, not passing requestmapping tests yet 2015-09-29 14:07:36 +01:00
Sebastien Deleuze
f816cc6a51 Add CompletableFuture/Single/Promise support 2015-09-24 23:02:49 +02:00
João Pedro Evangelista
d3e5d9dd03 Polishing 2015-09-22 09:14:29 +02:00
Sebastien Deleuze
110d9d7cd9 Use ByteBuffer instead of byte[] 2015-09-22 08:02:57 +02:00
Sebastien Deleuze
77c5b3fd65 Fix RxNetty tests by finding a new port for each test 2015-09-17 14:25:57 -04:00
Stephane Maldini
5e39858780 ignore for now 2015-09-11 16:09:49 -04:00