-
Notifications
You must be signed in to change notification settings - Fork 38.6k
Closed
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)type: bugA general bugA general bug
Milestone
Description
Daniel Jones opened SPR-16098 and commented
@JsonView
annotations aren't being honoured when the return type is a >= 2 nested generic type. i.e. Mono<ResponseEntity<UserAccount>>
. For example (in Kotlin, but the same occurs with Java):
@RestController
@RequestMapping("/users")
class UserController(
val userAccountRepository: UserAccountRepository,
val passwordEncoder: BCryptPasswordEncoder
) {
@JsonView(UserView.PublicView::class)
@PostMapping
fun create(@RequestBody userAccount: UserAccount, uriBuilder: UriComponentsBuilder): Mono<ResponseEntity<UserAccount>> {
return userAccountRepository
.save(UserAccount(null,
userAccount.username,
passwordEncoder.encode(userAccount.password))).map {
ResponseEntity.created(uriBuilder.path("/users/${it.id}").build().toUri())
.body(it)
}
}
}
This is because in AbstractMessageWriterResultHandler.writeBody(...)
where bodyType
is resolved, ResolvableType.forMethodParameter(...)
strips the typeProvider
when extracting the nested generics in ResolvableType#getNested()
There was some discussion around this in #19257 which has now been closed, hence I've created a new issue.
Affects: 5.0 GA
Issue Links:
- Consistent type resolution for ? and Object element type [SPR-15941] #20495 Consistent type resolution for ? and Object element type
Referenced from: commits c530745
Metadata
Metadata
Assignees
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)type: bugA general bugA general bug