Skip to content

ex.getPropertyName() is not initialized in ResponseEntityExceptionHandler#handleTypeMismatch #29959

Closed
@grundtein

Description

@grundtein

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.

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