Commit Graph

958 Commits

Author SHA1 Message Date
Sebastien Deleuze 5adc3d6666 Fix RSocketRequester API for requests without payload
This commit makes it possible to send requests without
requiring to call data(Mono.empty()). It introduces a
dedicated MetadataSpec interface and merge ResponseSpec
into RequestSpec for more flexibility.

Closes gh-23649
2019-09-18 16:00:16 +02:00
Brian Clozel 848804a227 Allow registration of RSocket metadata extractors
Prior to this commit, customizing the extraction of RSocket metadata
from frames would require developers to override the default
`MetadataExtractor` while configuring `RSocketStrategies`.
This touches on many infrastructure parts, whereas the goal is just to
configure an extra metadata entry extractor using already configured
codecs.

This commit adds a way to register metadata entry extractors on the
`RSocketStrategies` builder with a `Consumer`-based API.

Closes gh-23645
2019-09-16 19:01:14 +02:00
Phillip Webb deba2ed1b3 Add blank line between java and javax imports
See gh-23539
2019-09-04 22:05:46 -07:00
Sebastien Deleuze d587a660fc Fix a warning in Kotlin tests 2019-09-03 23:48:39 +02:00
Sebastien Deleuze 9b33b0ad58 Rename CoroutinesUtils#invokeHandlerMethod to invokeSuspendingFunction 2019-09-03 23:41:53 +02:00
Sebastien Deleuze c13941821a Treat Kotlin warnings as errors
Closes gh-23566
2019-09-02 16:49:31 +02:00
Sebastien Deleuze ca02cc1194 Migrate to AssertJ in Kotlin tests
Closes gh-23475
2019-09-02 15:59:26 +02:00
Rossen Stoyanchev 58e9266e99 Add Consumer methods to RSocketRequester
Closes gh-23513
2019-09-02 13:31:28 +01:00
Rossen Stoyanchev b144c72937 Support ByteBuf as a metadata value
This allows encoding of metadata values externally via some
existing API for encoding RSocket metadata, rather than relying on
registered Encoders.

Also remove explicit checks for DataBuffer since those are supported
through the DataBufferEncoder (registered by default).

See gh-23513
2019-09-02 13:31:28 +01:00
Rossen Stoyanchev 71f3498a26 Switch to using RoutingMetadata API
Closes gh-23137
2019-09-02 13:31:28 +01:00
Rossen Stoyanchev 29a58ab045 Remove RSocket metadata MimeType constants
For public use, these constants aren't ideally exposed through an SPI
like MetadataExtractor, and there isn't any other obvious place either.
In practice the only public API where these can be passed in is
RSocketRequester and RSocketMessageHandler both of which already
default to composite metadata anyway, leaving only the routing MimeType
to be used potentially but much less likely.
Due to existence of similar constants in the RSocket itself, i.e.
WellKnownMimeType, we can get by internally too without declaring
MimeType constants from a central place.
2019-08-27 13:04:58 +03:00
Rossen Stoyanchev 45d0405624 Upgrade to RSocket 1.0 RC3 snapshots and...
take advantage of the symmetrical SocketAcceptor methods now available
on RSocketFactory for both client and server side.
2019-08-27 13:04:58 +03:00
Sam Brannen ad6231ad29 Add missing @Override annotations 2019-08-23 13:50:58 +02:00
Sebastien Deleuze 4d10249b70 Update to Coroutine 1.3.0-RC2
This updates brings full interoperability between Reactor and
Coroutines contexts.

Closes gh-22986
2019-08-19 10:03:01 +02:00
Sam Brannen bbe33832cf Clean up warnings in Javadoc 2019-08-17 13:21:28 +02:00
Sam Brannen 979508a7f3 Remove JUnit 4 dependency from all modules except spring-test
This commit removes the JUnit 4 dependency from all modules except
spring-test which provides explicit JUnit 4 support.

This commit also includes the following.

- migration from JUnit 4 assertions to JUnit Jupiter assertions in all
  Kotlin tests
- migration from JUnit 4 assumptions in Spring's TestGroup support to
  JUnit Jupiter assumptions, based on org.opentest4j.TestAbortedException
- introduction of a new TestGroups utility class than can be used from
  existing JUnit 4 tests in the spring-test module in order to perform
  assumptions using JUnit 4's Assume class

See gh-23451
2019-08-17 11:37:21 +02:00
Sam Brannen 3f3e41923f Migrate rest of test suite from JUnit 4 to JUnit Jupiter
This commit migrates the rest of Spring's test suite to JUnit Jupiter,
except spring-test which will be migrated in a separate commit.

See gh-23451
2019-08-17 11:36:58 +02:00
Phillip Webb 62a3e41473 Deprecate mutable methods of MethodParameter
Deprecate all mutation methods in `MethodParameter` in favor of factory
methods that return a new instance. Existing code that previously relied
on mutation has been updated to use the replacement methods.

Closes gh-23385
2019-08-01 08:05:14 +01:00
Juergen Hoeller dea9ad6cb2 Merge branch '5.1.x' 2019-07-31 23:53:32 +02:00
Juergen Hoeller ea4f7d365f Deprecate logger field in HandlerMethodArgumentResolverComposite 2019-07-31 23:48:21 +02:00
Juergen Hoeller e6f86c5c75 Nullability refinements and related polishing 2019-07-31 13:45:48 +02:00
Juergen Hoeller 8ef557df2f Merge branch '5.1.x' 2019-07-30 17:34:29 +02:00
Rossen Stoyanchev 5e15bbfbf1 Change order of argument for createPayload
Expecting data first and metadata second aligns better with the single
arg variant that accepts data. This is also consistent with the
RSocket API in the create methods of ByteBufPayload and DefaultPayload.
2019-07-30 16:16:30 +01:00
Rossen Stoyanchev a1a8781279 PayloadUtils improvements and tests 2019-07-30 16:16:30 +01:00
Juergen Hoeller c4622dbebc Polishing 2019-07-30 16:59:01 +02:00
Rossen Stoyanchev d972911d51 Merge branch '5.1.x' 2019-07-30 11:02:33 +01:00
Rossen Stoyanchev 1d92755cc7 Remove custom handling of byte[] in DefaultStompSession
Closes gh-23358
2019-07-30 10:52:51 +01:00
Rossen Stoyanchev 2c878e9331 Support for setupPayload in RSocketRequester
Closes gh-23368
2019-07-29 22:09:06 +01:00
Rossen Stoyanchev 55946bf319 Factor out MetadataEncoder from RSocketRequester
To be re-used also for creating metadata for the setup payload.

See: gh-23368
2019-07-29 22:09:06 +01:00
Rossen Stoyanchev c76370d7d8 Polish 2019-07-29 22:09:02 +01:00
Rossen Stoyanchev dc0c730ee8 DefaultMetadataExtractor refactoring 2019-07-29 22:08:26 +01:00
Rossen Stoyanchev 2aa3363ba2 ClientRSocketFactoryConfigurer refactoring 2019-07-29 22:08:07 +01:00
Rossen Stoyanchev 8574f977a2 Mutate RSocketStrategies in RSocketMessageHandler
Use rsocketStrategies field with mutate() to ensure consistency
with internal state.

Remove transparent initialization of decoders in MetadataExtractor
and expect them to be set to avoid unintended side effects.
2019-07-26 16:12:02 +01:00
Rossen Stoyanchev fab0a5d504 MetadataExtractor refactoring
Remove RSocketStrategies argument from the contract to avoid having to
pass them every time especially by application components, like an
implementation of a Spring Security matcher.

Decouple DefaultMetadataExtractor from RSocketStrategies in favor of
a decoders property and an internal DataBufferFactory, which does not
need to be the shared one as we're only wrapping ByteBufs.
2019-07-26 16:12:02 +01:00
Rossen Stoyanchev be4facef1b Relax check on default data MimeType
If there is more than one non-basic codec (e.g. CBOR and JSON)
RSocketRequester.Builder takes the mime type of the first one rather
than giving up. It is a valid scenario (JSON for server responding to
browser, and CBOR for client talking to server) and it is the default
situation in Boot, and after all the point here is to pick some default
as best as we can with the worst possible outcome being a server
refusing the connection if it doesn't support the mime type. Beyond
that applications can set the dataMimeType on the builder explicitly.

To match that change this commit also ensures RSocketMessageHandler
rejects proactively data mime types it does not support at the point
of accepting a connection.
2019-07-24 18:44:04 +01:00
Rossen Stoyanchev 88016d47d0 Fix issues in RSocketMessageHandler initialization
This commit ensures getRSocketStrategies() now reflects the state of
corresponding RSocketMessageHandler properties even if those change
after a call to setRSocketStrategies.

RSocketMessageHandler has default Encoder/Decoder initializations
consistent with the recent changes to RSocketStrategies.
2019-07-24 17:39:31 +01:00
Rossen Stoyanchev e19e36ae4c Simplify RSocket client responder config
Now that responder RSocketStrategies also exposes responder strategies,
AnnotationClientResponderConfigurer is reduced and no longer needs to
be public. This commit folds it into RSocketMessageHandler as a nested
class and exposes it as a ClientRSocketFactoryConfigurer through a
static method that accepts the handlers to use.

Effectively a shortcut for creating RSocketMessageHandler, giving it
RSocketStrategies, calling afterPropertiesSet, and then the instance
createResponder.

See gh-23314
2019-07-24 11:17:56 +01:00
Rossen Stoyanchev c456950bc3 Add create shortcut to RSocketStrategies
Now that RSocketStrategies has default settings it makes sense to have
a create() shortcut vs builder().build().

This commit also updates tests to take advantage of improvements in this
and the previous two commits.

See gh-23314
2019-07-24 11:16:27 +01:00
Rossen Stoyanchev 91b040d0bf Add responder strategies to RSocketStrategies
RouteMatcher and MetadataExtractor can now be configured on and
accessed through RSocketStrategies. This simplifies configuration for
client and server responders.

See gh-23314
2019-07-24 11:16:27 +01:00
Rossen Stoyanchev a780cad12e Updates to RSocket[Strategies|Requester] defaults
1. RSocketStrategies hooks in the basic codecs from spring-core by
default. Now that we have support for composite metadata, it makes
sense to have multiple codecs available.

2. RSocketStrategies is pre-configured with NettyDataBufferFactory.

3. DefaultRSocketRequesterBuilder configures RSocket with a frame
decoder that matches the DataBufferFactory choice, i.e. ensuring
consistency of zero copy vs default (copy) choice.

4. DefaultRSocketRequesterBuilder now tries to find a single non-basic
decoder to select a default data MimeType (e.g. CBOR), or otherwise
fall back on the first default decoder (e.g. String).

See gh-23314
2019-07-24 11:16:27 +01:00
Rossen Stoyanchev 56c2987273 RSocketRequester support for route vars
Closes gh-23310
2019-07-22 14:02:22 +01:00
Rossen Stoyanchev d2a7d9fa88 Introduce RSocketClientFactoryConfigurer
The new interface supersedes ClientResponderFactory and is more general,
for any RSocketFactory customization.

DefaultClientResponderFactory implements the new interface and is
renamed to AnnotationClientResponderConfigurer.

See gh-23170
2019-07-18 10:21:51 +01:00
Rossen Stoyanchev 1e9ccdd8b8 Pass RSocketStrategies to MetadataExtractor
Simplify the creation of MetadataExtractor by not requiring
RSocketStrategies up front. The strategies are already configured in higher
level places like RSocketMessageHandler that invoke the MetadataExtractor.
The strategies are now passed in as an argument to the extract method.
2019-07-18 10:21:51 +01:00
Rossen Stoyanchev d33e4878a0 Move MetadataExtractor to the rsocket package
The move up the hierarchy reflects the fact that MetadataExtractor
is more generally useful and not tied to annotations.
2019-07-18 10:18:28 +01:00
Juergen Hoeller 94e3210ae7 Fix nullability warnings and javadoc-triggered package cycles 2019-07-17 22:34:07 +02:00
Brian Clozel e7ecb83449 Add client responder configuration
Prior to this commit, the `RSocketRequester.Builder` would allow to
configure directly annotated handlers for processing server requests.
This lead to a package tangle where the `o.s.messaging.rsocket` would
use classes from `o.s.messaging.rsocket.annotation.support` package.

This commit introduces the `ClientResponderFactory` interface for
configuring a responder on the client RSocket factory. Its goal is
to be compatible with future changes with a functional variant for
RSocket handlers.

Closes gh-23170
2019-07-17 12:09:09 +02:00
Sam Brannen 60a7092977 Fix dataMimeType and metadataMimeType mixup in precondition check
Closes gh-23292
2019-07-16 11:13:21 +02:00
Rossen Stoyanchev 68c99dafcf Rename {client|server}Acceptor to Responder
See gh-23170
2019-07-13 10:23:46 +01:00
Сергей Цыпанов 1728bf17fc Avoid unnecessary boxing where primitives can be used
Closes gh-23267
2019-07-10 16:51:18 +02:00
Sam Brannen 43447a8ee9 Polishing 2019-07-09 12:33:55 +02:00
Sebastien Deleuze ca75c2843a Upgrade to Coroutines 1.3.0-M2 2019-07-09 11:36:26 +02:00
Rossen Stoyanchev 47d60b34f8 Fix checkstyle violation 2019-07-08 21:35:00 +01:00
Rossen Stoyanchev 7b1a6eb50a Add getters to RSocketMessageHandler 2019-07-08 19:39:54 +01:00
Rossen Stoyanchev 2f77541f9c Update @MessageMapping Javadoc 2019-07-08 18:02:45 +01:00
Rossen Stoyanchev c199cb9054 @ConnectMapping for RSocket handling
The new annotation helps to differentiate the handling of connection
level frames (SETUP and METADATA_PUSH) from the 4 stream requests.

Closes gh-23177
2019-07-08 17:04:23 +01:00
Brian Clozel 507d128e1d Fix RSocket API warning 2019-07-08 14:47:41 +02:00
Sebastien Deleuze 08a5196c3a Use elementClass and elementTypeRef consistently 2019-07-08 12:08:40 +02:00
Sebastien Deleuze 88d7fede36 Avoid shadowed RSocketRequester extensions
This commit renames RSocketRequester.RequestSpec data extension to
dataWithType to avoid shadowing issues and adds Publisher<T> and Flow<T>
variants to provide automatic reified type parameter resolution for
those types. It also makes RSocketRequester consistent with the
changes introduced via 2b4d6ce354 in WebFlux.
2019-07-08 12:08:26 +02:00
slawluc 4bced4682a Make RSocketRequester extensions reified
Extension functions need to use reified types to create
ParameterizedTypeReference.

Closes gh-23185
2019-07-08 10:49:44 +02:00
Sam Brannen 0fbc9bf461 Fix broken Javadoc links 2019-07-07 19:50:34 +02:00
Juergen Hoeller a5cb8799fa Merge branch '5.1.x' 2019-07-05 18:22:02 +02:00
Juergen Hoeller 16deb3c50f Defensively register ReactiveReturnValueHandler for messaging methods
Closes gh-23207
2019-07-05 17:08:08 +02:00
Rossen Stoyanchev 3d913b8134 Merge branch '5.1.x' 2019-07-03 17:25:12 +01:00
Rossen Stoyanchev 4e6e47b726 Earlier detection of token authentication
Use a callback to detect token authentication (via inteceptor) thus
avoiding a potential race between that detection after the message is
sent on the inbound channel (via Executor) and the processing of the
CONNECTED frame returned from the broker on the outbound channel.

Closes gh-23160
2019-07-03 15:24:27 +01:00
Rossen Stoyanchev 511a430906 Polish 2019-06-28 23:13:31 +01:00
Rossen Stoyanchev 5bf070a857 More flexible RSocket metadata support
The responding side now relies on a new MetadataExtractor which decodes
metadata entries of interest, and adds them to an output map whose
values are then added as Message headers, and are hence accessible to
controller methods.

Decoded metadata entry values can be added to the output map one for
one, or translated to any number of values (e.g. JSON properties),
as long as one of the resulting pairs has a key called "route".

On the requesting side, now any metadata can be sent, and a String
route for example is not required to be provided explicitly. Instead
an application could create any metadata (e.g. JSON properties) as long
as the server can work out the route from it.

The commit contains further refinements on the requesting side so that
any mime type can be used, not only composite or routing metadata, e.g.
a route in an "text/plain" entry.

Closes gh-23157
2019-06-28 22:00:44 +01:00
Brian Clozel dd15ff79d7 Register annotated handlers in RSocketRequester
Prior to this commit, there would be no easy way to register client
RSocket handlers against an `RSocketRequester` instance. The only
solution was to gather all handlers and wrap them in a
`RSocketMessageHandler` and configure it as an acceptor on the client
RSocket.

This commit adds a convenience method on the `RSocketRequester` builder
to tkae care of this part of the infrastructure.

Closes gh-23170
2019-06-24 15:11:18 +02:00
Sebastien Deleuze eaecf0c006 Improve RSocketRequester.ResponseSpec Kotlin extensions
This commit adds retrieveMono and retrieveFlux reified variants, and
turns dataFlow(flow: Flow) extension into a general purpose reified
data(producer: Any) one.

Closes gh-23164
2019-06-21 15:26:12 +02:00
Rossen Stoyanchev 003247dc40 Equalize copy of ChannelSendOperator
See gh-23175
2019-06-21 14:16:44 +01:00
Rossen Stoyanchev 7f1d5d790e Polish 2019-06-21 06:51:59 +01:00
Rossen Stoyanchev c6a2c89408 Package refactoring in rsocket support
Create annotation.support sub-package and move handler code there. This
prepares for a future, functional handler (responder) variant and is
consistent with the package structure under simp.
2019-06-21 06:49:59 +01:00
Rossen Stoyanchev 772087fe18 Refactor RSocket handler selection
1. Consolidate config options for handler detection in the base class
AbstractMethodMessageHandler with sub-classes like RSocketMessageHandler
now only setting the handler predicate by default (e.g. @Controller).

2. Remove autoDetection flag in favor of just having the mutually
exclusive handler Predicate<Object> vs manually registered List<Object>.
Or if both are desired for some reason, then manually register first,
and set the predicate second.
2019-06-20 12:16:08 +01:00
Rossen Stoyanchev 7d68a65dc0 Replace deprecated methods in RSocket tests 2019-06-20 12:16:08 +01:00
Rossen Stoyanchev d6b5c20058 Generalize RSocketRequester data methods
Replace the Publisher argument in RequestSpec's
data(Publisher, Class<T>) and
data(Publisher, ParameterizedTypeReference<T>) methods with Object thus
allowing any reactive type known to the ReactiveAdapterRegistry to be
passed in directly rather than adapted to Publisher first.
2019-06-20 12:16:08 +01:00
Rossen Stoyanchev 22fd521e0a Remove MessageHandlerAcceptor sub-class
This commit removes the MessageHandlerAcceptor sub-class of
RSocketMessageHandler, and rather than implementing directly the
contracts for RSocket client and server acceptors, RSocketMessageHandler
now exposes clientAcceptor() and serverAcceptor() methods that return
the required adapter instances.

This provides better separation between the RSocketMessageHandler and
the RSocket adapter code, and also avoids implementing generic
interfaces like the BiFunction required for the client acceptor.
2019-06-19 22:19:19 +01:00
Rossen Stoyanchev 73c2eb1b77 Fix minor Assert-related issues 2019-06-18 21:31:44 +01:00
Rossen Stoyanchev 14e2c6803e Support for RSocket composite metadata
Closes gh-22798
2019-06-12 17:11:30 -04:00
Juergen Hoeller 0a77477d32 Merge branch '5.1.x' 2019-06-12 18:16:30 +02:00
Juergen Hoeller fc46abf0b7 Polishing 2019-06-12 18:04:06 +02:00
Juergen Hoeller 707c720441 Polishing 2019-06-12 00:05:37 +02:00
Sebastien Deleuze 098ac0bbb8 Annotate Object#equals parameter with @Nullable
Closes gh-23093
2019-06-06 14:18:30 +02:00
Rossen Stoyanchev eacc531cf7 Add dataMimeType to RSocketRequestBuilder
Closes gh-23012
2019-05-29 17:08:46 -04:00
Rossen Stoyanchev 64f3dbbee8 Polish in rsocket package 2019-05-29 17:08:46 -04:00
Сергей Цыпанов 7ef8cc9faf Tiny improvements regarding ArrayList creation
Closes gh-23047
2019-05-28 16:08:58 +02:00
Sam Brannen 141ef9082f Clean up Mockito usage
This commit migrates to the MockitoJUnitRunner where sensible, which
will later allow for an easier migration to Mockito's extension for
JUnit Jupiter.

In addition, this commit deletes unnecessary stubbing for various mocks
and polishes test fixture setup in various test classes.
2019-05-28 13:59:43 +02:00
Christoph Dreis 4e4145ac27 Avoid unnecessary call to get message type
Closes gh-23040
2019-05-28 07:21:08 +02:00
Phillip Webb 9d74da006c Migrate JUnit 4 assertions to AssertJ
Migrate all existing JUnit 4 `assert...` based assertions to AssertJ
and add a checkstyle rule to ensure they don't return.

See gh-23022
2019-05-23 15:52:49 -07:00
Phillip Webb 95a9d46a87 Migrate Hamcrest assertions to AssertJ
Migrate all existing `assertThat(..., Matcher)` assertions to AssertJ
and add checkstyle rules to ensure they don't return.

See gh-23022
2019-05-23 15:49:59 -07:00
Rossen Stoyanchev 2294625cf0 Exposes STOMP frame stats
Closes gh-23015
2019-05-23 18:32:11 -04:00
Rossen Stoyanchev e09c5fd9e5 Use TaskExecutor instead of ThreadPoolTaskExecutor
Closes gh-22943
2019-05-23 14:26:51 -04:00
Rossen Stoyanchev 0b2fcbfe8a Use TaskScheduler instead of ThreadPoolTaskScheduler
Closes gh-22943
2019-05-23 14:01:05 -04:00
Rossen Stoyanchev 438d3710d3 Detect MimeType via ConnectionSetupPayload
Closes gh-23012
2019-05-21 14:07:59 -04:00
Phillip Webb 02850f357f Migrate exception checking tests to use AssertJ
Migrate tests that use `@Test(expectedException=...)` or
`try...fail...catch` to use AssertJ's `assertThatException`
instead.
2019-05-20 10:47:53 -07:00
Johnny Lim 21e163e5da Fix typo 2019-05-20 16:41:05 +02:00
Rossen Stoyanchev 97c2de915a Add RouteMatcher
Closes gh-22642
2019-05-14 21:44:39 -04:00
stsypanov 9ca8681f79 Iteration over a map using EntrySet 2019-05-13 15:38:13 +02:00
Sam Brannen 0cff7eb32c Fix Javadoc links 2019-05-10 17:40:03 +02:00
Stephane Nicoll f188aab5f2 Merge branch '5.1.x' 2019-05-10 10:49:59 +02:00
chenqimiao e3137f11df Fix typo in package-info.java
Closes gh-22941
2019-05-10 10:49:13 +02:00
Phillip Webb 798b51f4a3 Migrate to BDD Mockito
Migrate all tests to consistently use BDD Mockito. Also add
checksyle rule to enforce going forwards.
2019-05-08 13:46:13 -07:00