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

Validator ParanamerParameterNameProvider with inheritance

Description

using the provided code, sometimes I'm getting "arg0" instead of the right name in the output after a few runs.

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 import org.hibernate.validator.parameternameprovider.ParanamerParameterNameProvider; import javax.validation.ConstraintViolation; import javax.validation.Validation; import javax.validation.Validator; import javax.validation.ValidatorFactory; import javax.validation.constraints.NotNull; import java.lang.reflect.Method; import java.util.Set; interface Service { void sayHello(@NotNull String world); } class ServiceImpl implements Service { @Override public void sayHello(String world) {} } public class Test { public static void main(String[] args) throws NoSuchMethodException { ValidatorFactory factory = Validation.byDefaultProvider() .configure() .parameterNameProvider(new ParanamerParameterNameProvider()) .buildValidatorFactory(); Validator validator = factory.getValidator(); Service service = new ServiceImpl(); Method sayHello = Service.class.getMethod("sayHello", String.class); Set<ConstraintViolation<Service>> violations = validator.forExecutables().validateParameters(service, sayHello, new Object[]{null}); System.out.println("violations = " + violations.iterator().next().getPropertyPath()); } }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 <dependencies> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-validator</artifactId> <version>5.1.0.Final</version> </dependency> <dependency> <groupId>org.glassfish.web</groupId> <artifactId>javax.el</artifactId> <version>2.2.6</version> </dependency> <dependency> <groupId>com.thoughtworks.paranamer</groupId> <artifactId>paranamer</artifactId> <version>2.5.5</version> </dependency> </dependencies>

I'm attaching another example but with custom paranamer.

Running with maven I'm not getting the same result:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 PASS ==== Running org.test.TestTest May 06, 2014 5:11:27 PM org.hibernate.validator.internal.util.Version <clinit> INFO: HV000001: Hibernate Validator 5.1.0.Final Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.281 sec FAIL ==== Running org.test.TestTest May 06, 2014 5:11:44 PM org.hibernate.validator.internal.util.Version <clinit> INFO: HV000001: Hibernate Validator 5.1.0.Final Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.292 sec <<< FAILURE! test(org.test.TestTest) Time elapsed: 0.254 sec <<< FAILURE! .... Results : Failed tests: test(org.test.TestTest): expected:<sayHello.[foo]> but was:<sayHello.[xxx0]> Tests run: 1, Failures: 1, Errors: 0, Skipped: 0

Environment

$ java -version
java version "1.7.0_55"
Java(TM) SE Runtime Environment (build 1.7.0_55-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.55-b03, mixed mode)

Status

Assignee

Emmanuel Bernard

Reporter

Filipe Sousa

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

Components

Fix versions

Affects versions

5.1.1.Final

Priority

Major