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

Check why we try to create metadata for Object[] in case of parameter validation and for <return type> in case of return value validation

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects versions: None
    • Fix versions: 6.1-backlog
    • Components: engine
    • Labels:
      None
    • Bug Testcase Reminder (view):

      Bug reports should generally be accompanied by a test case!

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

      Description

      If you throw an error directly from PredefinedScopeBeanMetaDataManager such as:

      	@SuppressWarnings("unchecked")
      	@Override
      	public <T> BeanMetaData<T> getBeanMetaData(Class<T> beanClass) {
      		BeanMetaData<T> beanMetaData = (BeanMetaData<T>) beanMetaDataMap.get( beanClass.getName() );
      
      		if ( beanMetaData == null ) {
      			throw LOG.uninitializedBeanMetaData( beanClass );
      		}
      
      		return beanMetaData;
      	}
      

      you end up with the following error:

      javax.validation.ValidationException: HV000249: Uninitialized bean metadata for class: java.lang.String. Please register your bean class as a class to initialize when initializing your ValidatorFactory.
      	at org.hibernate.validator.internal.metadata.PredefinedScopeBeanMetaDataManager.getBeanMetaData(PredefinedScopeBeanMetaDataManager.java:99)
      	at org.hibernate.validator.internal.engine.ValueContext.getLocalExecutionContext(ValueContext.java:79)
      	at org.hibernate.validator.internal.engine.ValidatorImpl.validateReturnValueInContext(ValidatorImpl.java:1023)
      	at org.hibernate.validator.internal.engine.ValidatorImpl.validateReturnValue(ValidatorImpl.java:283)
      	at org.hibernate.validator.internal.engine.ValidatorImpl.validateReturnValue(ValidatorImpl.java:245)
      	at org.hibernate.validator.test.predefinedscope.PredefinedScopeValidatorFactoryTest.testValidation(PredefinedScopeValidatorFactoryTest.java:53)
      

      This does not sound like something we should do. I mean what would be the bean metadata for Object[]? And if the return value is not marked with @Valid, we can consider it's not a bean.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              gsmet Guillaume Smet
              Participants:
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: