Uploaded image for project: 'JBoss Enterprise Application Platform'
  1. JBoss Enterprise Application Platform
  2. JBEAP-16100

HV-1684 StackOverflowError with Hibernate-validator 6.0.13Final

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Blocker Blocker
    • 7.3.0.CD15
    • 7.2.0.GA.CR4
    • Hibernate
    • None
    • Regression
    • Hide
      public class Main {
      
      	public static class Foo {
      
      		@Size(min=1)
      		Map<String, String> map1 = new HashMap<>();
      
      		@Size(min=1)
      		Map<String, String> map2 = new HashMap<>();
      
      		@Size(min=1)
      		Map<String, String> map3 = new HashMap<>();
      
      		@Size(min=1)
      		Map<String, String> map4 = new HashMap<>();
      	}
      
      	public static void main(String[] args) {
      
      		Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
      
      		Foo foo1 = new Foo();
      		Set<ConstraintViolation<Foo>> violations = validator.validate(foo1);
      		System.out.println( violations );
      	}
      }
      
      Show
      public class Main { public static class Foo { @Size(min=1) Map< String , String > map1 = new HashMap<>(); @Size(min=1) Map< String , String > map2 = new HashMap<>(); @Size(min=1) Map< String , String > map3 = new HashMap<>(); @Size(min=1) Map< String , String > map4 = new HashMap<>(); } public static void main( String [] args) { Validator validator = Validation.buildDefaultValidatorFactory().getValidator(); Foo foo1 = new Foo(); Set<ConstraintViolation<Foo>> violations = validator.validate(foo1); System .out.println( violations ); } }

      https://hibernate.atlassian.net/browse/HV-1684

      The value obtained from possibleValueExtractorsByRuntimeType is always re-added later on, wrapped into an immutable set. So after some time this will produce the stack overflow. Instead, the write to the cache should only happen once upon initial retrieval of the value.

      java.lang.StackOverflowError
              at java.util.Collections$UnmodifiableCollection.isEmpty(Collections.java:1031)
              at java.util.Collections$UnmodifiableCollection.isEmpty(Collections.java:1031)
      	......
      	at java.util.Collections$UnmodifiableCollection.isEmpty(Collections.java:1031)
              at java.util.Collections$UnmodifiableCollection.isEmpty(Collections.java:1031)
              at java.util.Collections$UnmodifiableCollection.isEmpty(Collections.java:1031)
              at java.util.Collections$UnmodifiableCollection.isEmpty(Collections.java:1031)
              at java.util.Collections$UnmodifiableCollection.isEmpty(Collections.java:1031)
              at java.util.Collections$UnmodifiableCollection.isEmpty(Collections.java:1031)
              at org.hibernate.validator.internal.engine.valueextraction.ValueExtractorResolver.getRuntimeCompliantValueExtractors(ValueExtractorResolver.java:316)
              at org.hibernate.validator.internal.engine.valueextraction.ValueExtractorResolver.getValueExtractorCandidatesForContainerDetectionOfGlobalCascadedValidation(ValueExtractorResolver.java:177)
              at org.hibernate.validator.internal.metadata.aggregated.CascadingMetaDataBuilder.build(CascadingMetaDataBuilder.java:227)
              at org.hibernate.validator.internal.metadata.aggregated.FieldCascadable$Builder.build(FieldCascadable.java:83)
              at org.hibernate.validator.internal.metadata.aggregated.FieldCascadable$Builder.build(FieldCascadable.java:64)
              at org.hibernate.validator.internal.metadata.aggregated.PropertyMetaData$Builder.lambda$build$1(PropertyMetaData.java:347)
              at org.hibernate.validator.internal.metadata.aggregated.PropertyMetaData$Builder$$Lambda$62/1651906449.apply(Unknown Source)
              at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
              at java.util.HashMap$ValueSpliterator.forEachRemaining(HashMap.java:1625)
              at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
              at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
              at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
              at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
              at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
              at org.hibernate.validator.internal.metadata.aggregated.PropertyMetaData$Builder.build(PropertyMetaData.java:348)
              at org.hibernate.validator.internal.metadata.aggregated.PropertyMetaData$Builder.build(PropertyMetaData.java:151)
              at org.hibernate.validator.internal.metadata.aggregated.BeanMetaDataImpl$BuilderDelegate.build(BeanMetaDataImpl.java:784)
              at org.hibernate.validator.internal.metadata.aggregated.BeanMetaDataImpl$BeanMetaDataBuilder.build(BeanMetaDataImpl.java:648)
              at org.hibernate.validator.internal.metadata.BeanMetaDataManager.createBeanMetaData(BeanMetaDataManager.java:192)
              at org.hibernate.validator.internal.metadata.BeanMetaDataManager.lambda$getBeanMetaData$0(BeanMetaDataManager.java:160)
              at org.hibernate.validator.internal.metadata.BeanMetaDataManager$$Lambda$53/253243426.apply(Unknown Source)
              at java.util.concurrent.ConcurrentMap.computeIfAbsent(ConcurrentMap.java:324)
              at org.hibernate.validator.internal.metadata.BeanMetaDataManager.getBeanMetaData(BeanMetaDataManager.java:159)
              at org.hibernate.validator.internal.engine.ValidationContext$ValidationContextBuilder.forValidate(ValidationContext.java:566)
              at org.hibernate.validator.internal.engine.ValidatorImpl.validate(ValidatorImpl.java:155)
      		at com.test.ValidateParameters.validateObject(ValidateParameters.java:31)
      

      The only way to fix it is to restart the app

              gsmet@redhat.com Guillaume Smet
              msimka@redhat.com Martin Simka
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: