spring-projects / spring-boot

Spring Boot
https://spring.io/projects/spring-boot
Apache License 2.0
74.55k stars 40.54k forks source link

Confusing warnings with fallback MessageInterpolatorFactory #8599

Closed snicoll closed 6 years ago

snicoll commented 7 years ago

When upgrading to the latest hibernate validator we've configured a special MessageInterpolatorFactory that would provide a fallback MessageInterpolator if the default one can't be created.

This works as expected but in case EL is on the classpath, you get those warnings in the logs anyway:

2017-03-14 08:43:21.074  WARN 16537 --- [  restartedMain] o.h.v.m.ParameterMessageInterpolator     : HV000184: ParameterMessageInterpolator has been chosen, EL interpolation will not be supported
2017-03-14 08:43:21.152  WARN 16537 --- [  restartedMain] o.h.v.m.ParameterMessageInterpolator     : HV000184: ParameterMessageInterpolator has been chosen, EL interpolation will not be supported

We get the warning twice because we have that trick in the general ValidationAutoConfiguration and the special validator we use to bind @ConfigurationProperties bean.

It would be nice if we could find a way to get rid of that warning. Not creating the interpolator at all if EL isn't on the classpath might be an idea.

bclozel commented 7 years ago

For more background on this issue, see #7500 and #7598.

The ParameterMessageInterpolator is the fallback implementation chosen by our MessageInterpolatorFactory when no EL implementation is available. The ParameterMessageInterpolator is logging that statement in its constructor and it's been the case since its inception in 5.2.0 (and even before, when it was named NonElMessageInterpolator).

It's a bit strange to 1) warn users when it was a conscious choice, and 2) not say anything when validation requiring EL is used, leading to cases like https://github.com/spring-projects/spring-boot/issues/8400#issuecomment-298511491.

This log is part of the interpolator constructor and there's no way to remove it on our side. I've raised HV-1323 to discuss this with the Hibernate team.

bclozel commented 6 years ago

This has been fixed in Hibernate Validator 6.0.4.Final, with Spring Boot 2.0.0.M6. Duplicates gh-10788.