-
Couldn't load subscription status.
- Fork 38.8k
Closed
Labels
status: declinedA suggestion or change that we don't feel we should currently applyA suggestion or change that we don't feel we should currently applytype: enhancementA general enhancementA general enhancement
Milestone
Description
GanMing opened SPR-16909 and commented
I was looking forward to extracting a tool class from methods such as readToMono, readToFlux, and findReader in BodyExtractors. This would improve the problem of generic warnings.
Or is there a better way?In short, it would be great to get rid of that annoying warning and make it more reliable to use.
BodyExtractor<Mono<Map<String, Object>>, ReactiveHttpInputMessage> bodyExtractor = (msg, context) -> {
ResolvableType elementType = ResolvableType.forClassWithGenerics(Map.class, String.class, Object.class);
HttpMessageReader<Map<String, Object>> reader = context.messageReaders()
.stream().filter(messageReader -> messageReader.canRead(elementType, MediaType.APPLICATION_JSON))
.findFirst()
//What actually intimidates me is the following unchecked generic cast-cause warning, because it interferes with the developer's focus.
.map(r -> (HttpMessageReader<Map<String, Object>>) r)
.orElseThrow(() -> new IllegalStateException(
"No HttpMessageReader for \"" + MediaType.APPLICATION_JSON_VALUE + "\" and \"" + elementType + "\""));
return reader.readMono(elementType, msg, context.hints());
};Reference URL: #21396
Metadata
Metadata
Assignees
Labels
status: declinedA suggestion or change that we don't feel we should currently applyA suggestion or change that we don't feel we should currently applytype: enhancementA general enhancementA general enhancement