ZoneIdEditor
throws wrong exception type for TypeConverterSupport
#33545
Labels
Milestone
ZoneIdEditor
throws wrong exception type for TypeConverterSupport
#33545
Spring Framework Version: Latest (6.1.13) and below
spring-beans/src/main/java/org/springframework/beans/propertyeditors/ZoneIdEditor.java
callsZoneId.of
which throws ajava.time.DateTimeException
.But
org.springframework.beans.TypeConverterSupport.convertIfNecessary(String, Object, Class<T>, TypeDescriptor)
is expecting anIllegalArgumentException
.This manifests in a variety of ways. Best example is in
web-mvc
assuming a controller with:This means a
get
request of/?integer=helloworld
results in aMethodArgumentTypeMismatchException
which can easily be bound to 400 response.However a
get
request of/?zoneId=helloworld
results in aDateTimeException
which binds to 500 response.The integer parameter binding works because it throws
NumberFormatException
which extends fromIllegalArgumentException
.The text was updated successfully, but these errors were encountered: