Since Spring 4.3, validation annotation attributes are captured as ResolvableAttribute in SpringValidatorAdapter if they are strings. This behaviour appears to have been introduced due to #17986.
When MessageSourceSupport#alwaysUseMessageFormat is set to true (in the case of Spring Boot, it is possible to set this using the spring.messages.always-use-message-format property) it appears that attributes that may not need formatting will be passed through MessageFormat.
The regex is a valid expression that matches on Unicode letter characters.
Spring will try and pass the regexp attribute string through MessageFormat which causes issues as it then tries to resolve an argument for parameter L. Specifically, it will throw IllegalArgumentException in MessageFormat#makeFormat.
I don't think ResolvableAttribute should be applied to the regexp attribute (or any other attribute) indiscriminately. Is there something that can/should be done about this?
#17986 Support MessageSourceResolvable to string argument value at SpringValidatorAdapter
The text was updated successfully, but these errors were encountered:
We explicitly never format a code-as-default-message now, even with alwaysUseMessageFormat=true. This is in sync with the useCodeAsDefaultMessage feature, just also checked against a MessageSourceResolvable's exposes default message now.
With the above in place, our explicit wrapping of constraint attributes just leads to optional message lookups now but doesn't impact the default attribute value anymore.