Uploaded image for project: 'Hibernate Validator'
  1. HV-887

Validator ParanamerParameterNameProvider with inheritance

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.1.1.Final
    • Fix Version/s: 5.2.0.Beta1
    • Component/s: engine
    • Labels:
      None
    • 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)
    • Bug Testcase Reminder (view):

      Bug reports should generally be accompanied by a test case!

    • Last commented by a user?:
      true
    • Sprint:

      Description

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

      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());
          }
      }
      
      <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:

      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
      

        Attachments

          Activity

            People

            • Votes:
              1 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: