Skip to content

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

Closed
@spring-projects-issues

Description

@spring-projects-issues

Dariusz Bacinski opened SPR-15467 and commented

#20021

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>::class.java 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>::class.java)

Works:

val flux: Flux<String> = Mono.just(listOf("1", "2")).flatMapIterable { it }
ok().contentType(APPLICATION_JSON_UTF8).body(flux,  String::class.java)

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:

Referenced from: commits b9dbac7

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions