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

JaCoCo code coverage fails since ConstraintDescriptorImpl#buildAnnotationParameterMap() does not filter out synthetic methods

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.2.4.Final
    • Fix Version/s: 6.0.3.Final
    • Component/s: engine
    • Labels:
      None
    • Environment:
      Java 8 112
      Eclipse 4.6.1
      Windows 7

      Description

      ConstraintDescriptorImpl.buildAnnotationParameterMap does not filter out sythetic methods.

      Resulting the following exception:

      javax.validation.ValidationException: HV000083: The specified annotation defines no parameter '$jacocoInit'.
      	at org.hibernate.validator.internal.util.privilegedactions.GetAnnotationParameter.run(GetAnnotationParameter.java:53)
      	at org.hibernate.validator.internal.metadata.descriptor.ConstraintDescriptorImpl.run(ConstraintDescriptorImpl.java:741)
      	at org.hibernate.validator.internal.metadata.descriptor.ConstraintDescriptorImpl.buildAnnotationParameterMap(ConstraintDescriptorImpl.java:562)
      	at org.hibernate.validator.internal.metadata.descriptor.ConstraintDescriptorImpl.<init>(ConstraintDescriptorImpl.java:167)
      	at org.hibernate.validator.internal.metadata.descriptor.ConstraintDescriptorImpl.<init>(ConstraintDescriptorImpl.java:211)
      	at org.hibernate.validator.internal.metadata.provider.AnnotationMetaDataProvider.buildConstraintDescriptor(AnnotationMetaDataProvider.java:661)
      	at org.hibernate.validator.internal.metadata.provider.AnnotationMetaDataProvider.findConstraintAnnotations(AnnotationMetaDataProvider.java:587)
      	at org.hibernate.validator.internal.metadata.provider.AnnotationMetaDataProvider.findConstraints(AnnotationMetaDataProvider.java:532)
      	at org.hibernate.validator.internal.metadata.provider.AnnotationMetaDataProvider.findExecutableMetaData(AnnotationMetaDataProvider.java:349)
      	at org.hibernate.validator.internal.metadata.provider.AnnotationMetaDataProvider.getMetaData(AnnotationMetaDataProvider.java:329)
      	at org.hibernate.validator.internal.metadata.provider.AnnotationMetaDataProvider.getMethodMetaData(AnnotationMetaDataProvider.java:315)
      	at org.hibernate.validator.internal.metadata.provider.AnnotationMetaDataProvider.retrieveBeanConfiguration(AnnotationMetaDataProvider.java:138)
      	at org.hibernate.validator.internal.metadata.provider.AnnotationMetaDataProvider.getBeanConfiguration(AnnotationMetaDataProvider.java:125)
      	at org.hibernate.validator.internal.metadata.provider.AnnotationMetaDataProvider.getBeanConfigurationForHierarchy(AnnotationMetaDataProvider.java:108)
      	at org.hibernate.validator.internal.metadata.BeanMetaDataManager.createBeanMetaData(BeanMetaDataManager.java:166)
      	at org.hibernate.validator.internal.metadata.BeanMetaDataManager.getOrCreateBeanMetaData(BeanMetaDataManager.java:194)
      	at org.hibernate.validator.internal.metadata.BeanMetaDataManager.getBeanMetaData(BeanMetaDataManager.java:142)
      	at org.hibernate.validator.internal.engine.ValidatorImpl.validateCascadedConstraint(ValidatorImpl.java:783)
      	at org.hibernate.validator.internal.engine.ValidatorImpl.validateCascadedConstraints(ValidatorImpl.java:681)
      	at org.hibernate.validator.internal.engine.ValidatorImpl.validateInContext(ValidatorImpl.java:416)
      	at org.hibernate.validator.internal.engine.ValidatorImpl.validateCascadedConstraint(ValidatorImpl.java:795)
      	at org.hibernate.validator.internal.engine.ValidatorImpl.validateCascadedConstraints(ValidatorImpl.java:681)
      	at org.hibernate.validator.internal.engine.ValidatorImpl.validateInContext(ValidatorImpl.java:416)
      	at org.hibernate.validator.internal.engine.ValidatorImpl.validateCascadedConstraint(ValidatorImpl.java:795)
      	at org.hibernate.validator.internal.engine.ValidatorImpl.validateCascadedConstraints(ValidatorImpl.java:681)
      	at org.hibernate.validator.internal.engine.ValidatorImpl.validateInContext(ValidatorImpl.java:416)
      	at org.hibernate.validator.internal.engine.ValidatorImpl.validate(ValidatorImpl.java:205)
      

      Fix:

      	private Map<String, Object> buildAnnotationParameterMap(Annotation annotation) {
      		final Method[] declaredMethods = run( GetDeclaredMethods.action( annotation.annotationType() ) );
      		Map<String, Object> parameters = newHashMap( declaredMethods.length );
      		for ( Method m : declaredMethods ) {	
      		    //Add check for synthetic
      		    if(!m.isSynthetic()) {
      		        Object value = run( GetAnnotationParameter.action( annotation, m.getName(), Object.class ) );
      			    parameters.put( m.getName(), value );
      			}
      		}
      		return Collections.unmodifiableMap( parameters );
      	}
      

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: