We're updating the issue view to help you get more done. 

Escaping validator messages doesn't work

Description

as described in http://stackoverflow.com/questions/16665649/how-to-escape-curly-braces-in-hibernate-validator-messages-test-case-provided.

HV should allow to escape validation messages from user provided bundles.

a test case:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 import org.hibernate.validator.HibernateValidator; import org.hibernate.validator.HibernateValidatorConfiguration; import org.hibernate.validator.internal.engine.constraintvalidation.ConstraintValidatorFactoryImpl; import org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator; import org.hibernate.validator.spi.resourceloading.ResourceBundleLocator; import org.junit.Test; import javax.validation.*; import javax.validation.constraints.Max; import java.util.Enumeration; import java.util.Locale; import java.util.ResourceBundle; import java.util.Set; public class HibValTest { @Test public void shouldNotSubstituteEscaped() throws Exception { MessageInterpolator interpolator = new ResourceBundleMessageInterpolator( new ResourceBundleLocator() { @Override public ResourceBundle getResourceBundle(Locale locale) { return new ResourceBundle() { @Override protected Object handleGetObject(String key) { return "\\{escapedKey\\}"; } @Override public Enumeration<String> getKeys() { throw new UnsupportedOperationException(); } }; } }, false); HibernateValidatorConfiguration config = Validation.byProvider( HibernateValidator.class ).configure(); config = config.messageInterpolator(interpolator).constraintValidatorFactory(new ConstraintValidatorFactoryImpl()); ValidatorFactory factory = config.buildValidatorFactory(); Validator validator = factory.getValidator(); Set<ConstraintViolation<A>> validate = validator.validate(new A()); } private class A { @Max(value=1, message = "{key}") private int a=2; } }

that results in stack overflow as it tries to constantly substitute escaped variable

Environment

None

Status

Assignee

Hardy Ferentschik

Reporter

Tomasz Bartczak

Labels

None

Worked in

None

Feedback Requested

None

Feedback Requested By

None

backPortable

None

Community Help Wanted

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

backportReEvaluate

None

Fix versions

Affects versions

4.3.1.Final
5.0.1.Final

Priority

Major