thymeleaf-spring
thymeleaf-spring copied to clipboard
SpringNonCacheableMessageResolver swallows NoSuchMessageException
org.springframework.context.support.AbstractMessageSource allows you to choose the way missing message resources are handled by setting setUseCodeAsDefaultMessage(boolean) true - message's code is returned instead of message false - NoSuchMessageException is thrown
Usually in production environment you would choose the second option (fail-fast) instead of displaying page incorrectly, which is confirmed by their javadoc: "In general, it is recommended to just use "useCodeAsDefaultMessage" during development and not rely on it in production.."
However, SpringNonCacheableMessageResolver catches NoSuchMessageException and returns null, which is replaced by message code in question marks in MessageResolutionUtils.getAbsentMessageRepresentation() thus messing up the fail-fast option.
As an addition it would be good to have the possibility to set a default-text.