Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ServerResponse.BodyBuilder.body(Object) shadows body(Publisher) in Kotlin ServerResponseExtensions [SPR-15467] #20027

spring-projects-issues opened this issue Apr 20, 2017 · 2 comments


Copy link

@spring-projects-issues spring-projects-issues commented Apr 20, 2017

Dariusz Bacinski opened SPR-15467 and commented


After linked change I am unable to pass Mono<List<String>> to body method.

The problem is that can't pass generic type of List<String> to body method.

Doesn't work:

val monoList: Mono<List<String>> = Mono.just(listOf("1", "2"))
ok().contentType(APPLICATION_JSON_UTF8).body(monoList, List<String>


val flux: Flux<String> = Mono.just(listOf("1", "2")).flatMapIterable { it }

Code is written in Kotlin -, but I think it also applies to Java due to how generics works.-
It is very inconvenient that after linked change we have to provide exact type when we pass Publisher, before that it was not required.

Affects: 5.0 RC1

Issue Links:

  • #20021 Add body(Object) method to ServerResponse.BodyBuilder

Referenced from: commits b9dbac7

Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Apr 21, 2017

Arjen Poutsma commented

This is specific to Kotlin, as the body(Object) method (unintentionally) overrides the body(Publisher) extension method in ServerResponseExtensions.kt, see here. It does not occur in Java, because there said method requires an extra Class parameter, see here.

Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Apr 25, 2017

Arjen Poutsma commented

Fixed by renaming body(Object) to syncBody(Object), see b9dbac7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants