The following line causing 406 Error while using any subtype of ProblemDetail class.
// For ProblemDetail, fall back on RFC 7807 format
if (bestMediaType == null && elementType.toClass().equals(ProblemDetail.class)) {
bestMediaType = selectMediaType(exchange, () -> getMediaTypesFor(elementType), this.problemMediaTypes);
}
The issue does not exists in Servlet as it checks the error body type is assignable of ProblemDetail class.
// For ProblemDetail, fall back on RFC 7807 format
if (compatibleMediaTypes.isEmpty() && ProblemDetail.class.isAssignableFrom(valueType)) {
determineCompatibleMediaTypes(this.problemMediaTypes, producibleTypes, compatibleMediaTypes);
}
The following line causing 406 Error while using any subtype of ProblemDetail class.
(https://github.com/spring-projects/spring-framework/blob/main/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/AbstractMessageWriterResultHandler.java#L178)
The issue does not exists in Servlet as it checks the error body type is assignable of ProblemDetail class.
https://github.com/spring-projects/spring-framework/blob/main/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/AbstractMessageConverterMethodProcessor.java#L247