Repository navigation
Conversation
The commit is a follow-up of d6b5c20 which applies the same principle to ServerResponse, WebClient.RequestBodySpec and WebTestClient.RequestBodySpec body methods. It introduces a body(Object) method where the parameter can be: - Concrete value - Publisher of value(s) - Any other producer of value(s) that can be adapted to a Publisher via ReactiveAdapterRegistry Variants with Class and ParameterizedTypeReference parameters are also provided and syncBody(Object) is deprecated. With this change, in Kotlin it is now mandatory to specify explicitly the generic type (for example body<List<Foo>>(body)) in order to invoke the ParameterizedTypeReference shortcut. If it is not specified, the extension is shadowed by the Java body(Object) method which is not able to use Kotlin type inference to resolve the generic type.
rstoyanchev
reviewed
Jul 1, 2019
| */ | ||
| public static <T> BodyInserter<T, ReactiveHttpOutputMessage> fromObject(T body) { | ||
| Assert.notNull(body, "'body' must not be null"); | ||
| ReactiveAdapter adapter = ReactiveAdapterRegistry.getSharedInstance().getAdapter(body.getClass()); |
Contributor
There was a problem hiding this comment.
Using the shared instance means if someone tries to register additional adapters, they don't have a way to influence this.
Contributor
There was a problem hiding this comment.
Can't we use the hints mechanism to resolve the registry?
Contributor
Author
There was a problem hiding this comment.
@rstoyanchev Could you please elaborate? I am not sure to understand.
rstoyanchev
added a commit
that referenced
this pull request
Aug 20, 2019
The recently added body(Object) variant can be confused easily with body(Publisher, Class) forgetting to provide the element type and only running into the IllegalArgumentException at runtime. See gh-23212
bclozel
added a commit
to spring-projects/spring-boot
that referenced
this pull request
Aug 20, 2019
This commit adapts to recent changes in Spring Framework. See spring-projects/spring-framework#23212
pull Bot
pushed a commit
to scope-demo/spring-boot
that referenced
this pull request
Aug 20, 2019
This commit adapts to recent changes in Spring Framework. See spring-projects/spring-framework#23212
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The commit is a follow-up of d6b5c20
which applies the same principle to ServerResponse,
WebClient.RequestBodySpec and WebTestClient.RequestBodySpec body
methods.
It introduces a body(Object) method where the parameter can be:
Publisher via ReactiveAdapterRegistry
Variants with Class and ParameterizedTypeReference parameters are also
provided and syncBody(Object) is deprecated.
With this change, in Kotlin it is now mandatory to specify explicitly
the generic type (for example body<List>(body)) in order to
invoke the ParameterizedTypeReference shortcut. If it is not specified,
the extension is shadowed by the Java body(Object) method which is not
able to use Kotlin type inference to resolve the generic type.