https://github.com/spring-projects/spring-framework/blob/main/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ResponseEntityExceptionHandler.java
Method:handleTypeMismatch
Object[] args = {ex.getPropertyName(), ex.getValue()};
String defaultDetail = "Failed to convert '" + args[0] + "' with value: '" + args[1] + "'";
If exception type is MethodArgumentTypeMismatchException, return value of "ex.getPropertyName()" is null. Therefore "defaultDetail" is "Failed to convert 'null' with value: 'val'"; But, return value of "ex.getName()" is correct property name.
Probably "TypeMismatchException#initPropertyName()" is not called.
Comment From: rstoyanchev
Indeed, as we are using the property name now in the detail message, we should make sure it's initialied. Both handleTypeMismatch
and handleConversionNotSupported
.
Comment From: grundtein
Thank you for your confirmation.