Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 6.0.8.Final
    • Fix Version/s: 6.0.9.Final
    • Component/s: engine
    • Labels:
      None
    • Environment:
      Spring Boot 2.0.0
      JDK 8
      Jersey 2.26
      HV 6.0.8
      Jackson 2.9.4

      Description

      When a DTO with the following field is passed to a JAX-RS API, and HV is invoked to perform validation on the DTO.

          @Valid
          private ObjectNode additionalProperties = null;
      

      The follow NPE is thrown:

      Caused by: java.lang.NullPointerException
      	at org.hibernate.validator.internal.metadata.aggregated.CascadingMetaDataBuilder.addCascadingMetaData(CascadingMetaDataBuilder.java:395) ~[hibernate-validator-6.0.8.Final.jar:6.0.8.Final]
      	at org.hibernate.validator.internal.metadata.aggregated.CascadingMetaDataBuilder.addCascadingMetaDataBasedOnContainerDetection(CascadingMetaDataBuilder.java:379) ~[hibernate-validator-6.0.8.Final.jar:6.0.8.Final]
      	at org.hibernate.validator.internal.metadata.aggregated.CascadingMetaDataBuilder.build(CascadingMetaDataBuilder.java:242) ~[hibernate-validator-6.0.8.Final.jar:6.0.8.Final]
      	at org.hibernate.validator.internal.metadata.aggregated.FieldCascadable$Builder.build(FieldCascadable.java:84) ~[hibernate-validator-6.0.8.Final.jar:6.0.8.Final]
      	at org.hibernate.validator.internal.metadata.aggregated.FieldCascadable$Builder.build(FieldCascadable.java:65) ~[hibernate-validator-6.0.8.Final.jar:6.0.8.Final]
      	at org.hibernate.validator.internal.metadata.aggregated.PropertyMetaData$Builder.lambda$build$1(PropertyMetaData.java:339) ~[hibernate-validator-6.0.8.Final.jar:6.0.8.Final]
      	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) ~[?:1.8.0_112]
      	at java.util.HashMap$ValueSpliterator.forEachRemaining(HashMap.java:1620) ~[?:1.8.0_112]
      	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481) ~[?:1.8.0_112]
      	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471) ~[?:1.8.0_112]
      	at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708) ~[?:1.8.0_112]
      	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:1.8.0_112]
      	at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499) ~[?:1.8.0_112]
      	at org.hibernate.validator.internal.metadata.aggregated.PropertyMetaData$Builder.build(PropertyMetaData.java:340) ~[hibernate-validator-6.0.8.Final.jar:6.0.8.Final]
      	at org.hibernate.validator.internal.metadata.aggregated.PropertyMetaData$Builder.build(PropertyMetaData.java:150) ~[hibernate-validator-6.0.8.Final.jar:6.0.8.Final]
      	at org.hibernate.validator.internal.metadata.aggregated.BeanMetaDataImpl$BuilderDelegate.build(BeanMetaDataImpl.java:779) ~[hibernate-validator-6.0.8.Final.jar:6.0.8.Final]
      	at org.hibernate.validator.internal.metadata.aggregated.BeanMetaDataImpl$BeanMetaDataBuilder.build(BeanMetaDataImpl.java:643) ~[hibernate-validator-6.0.8.Final.jar:6.0.8.Final]
      	at org.hibernate.validator.internal.metadata.BeanMetaDataManager.createBeanMetaData(BeanMetaDataManager.java:192) ~[hibernate-validator-6.0.8.Final.jar:6.0.8.Final]
      	at org.hibernate.validator.internal.metadata.BeanMetaDataManager.lambda$getBeanMetaData$0(BeanMetaDataManager.java:160) ~[hibernate-validator-6.0.8.Final.jar:6.0.8.Final]
      	at java.util.concurrent.ConcurrentMap.computeIfAbsent(ConcurrentMap.java:324) ~[?:1.8.0_112]
      	at org.hibernate.validator.internal.metadata.BeanMetaDataManager.getBeanMetaData(BeanMetaDataManager.java:159) ~[hibernate-validator-6.0.8.Final.jar:6.0.8.Final]
      	at org.hibernate.validator.internal.engine.ValidatorImpl.buildNewLocalExecutionContext(ValidatorImpl.java:752) ~[hibernate-validator-6.0.8.Final.jar:6.0.8.Final]
      	at org.hibernate.validator.internal.engine.ValidatorImpl.validateCascadedAnnotatedObjectForCurrentGroup(ValidatorImpl.java:606) ~[hibernate-validator-6.0.8.Final.jar:6.0.8.Final]
      	at org.hibernate.validator.internal.engine.ValidatorImpl.validateCascadedConstraints(ValidatorImpl.java:571) ~[hibernate-validator-6.0.8.Final.jar:6.0.8.Final]
      	at org.hibernate.validator.internal.engine.ValidatorImpl.validateInContext(ValidatorImpl.java:392) ~[hibernate-validator-6.0.8.Final.jar:6.0.8.Final]
      	at org.hibernate.validator.internal.engine.ValidatorImpl.validateCascadedAnnotatedObjectForCurrentGroup(ValidatorImpl.java:608) ~[hibernate-validator-6.0.8.Final.jar:6.0.8.Final]
      	at org.hibernate.validator.internal.engine.ValidatorImpl.validateCascadedConstraints(ValidatorImpl.java:571) ~[hibernate-validator-6.0.8.Final.jar:6.0.8.Final]
      	at org.hibernate.validator.internal.engine.ValidatorImpl.validateParametersInContext(ValidatorImpl.java:866) ~[hibernate-validator-6.0.8.Final.jar:6.0.8.Final]
      	at org.hibernate.validator.internal.engine.ValidatorImpl.validateParameters(ValidatorImpl.java:270) ~[hibernate-validator-6.0.8.Final.jar:6.0.8.Final]
      	at org.hibernate.validator.internal.engine.ValidatorImpl.validateParameters(ValidatorImpl.java:227) ~[hibernate-validator-6.0.8.Final.jar:6.0.8.Final]
      	at org.glassfish.jersey.server.validation.internal.DefaultConfiguredValidator.onValidate(DefaultConfiguredValidator.java:178) ~[jersey-bean-validation-2.26.jar:?]
      	at org.glassfish.jersey.server.validation.internal.ValidationInterceptorExecutor.proceed(ValidationInterceptorExecutor.java:114) ~[jersey-bean-validation-2.26.jar:?]
      	at org.glassfish.jersey.server.validation.internal.DefaultConfiguredValidator.validateResourceAndInputParams(DefaultConfiguredValidator.java:146) ~[jersey-bean-validation-2.26.jar:?]
      	at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:138) ~[jersey-server-2.26.jar:?]
      	at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$TypeOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:243) ~[jersey-server-2.26.jar:?]
      	at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:103) ~[jersey-server-2.26.jar:?]
      	at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:493) ~[jersey-server-2.26.jar:?]
      	at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:415) ~[jersey-server-2.26.jar:?]
      	at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:104) ~[jersey-server-2.26.jar:?]
      	at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:277) ~[jersey-server-2.26.jar:?]
      	at org.glassfish.jersey.internal.Errors$1.call(Errors.java:272) ~[jersey-common-2.26.jar:?]
      	at org.glassfish.jersey.internal.Errors$1.call(Errors.java:268) ~[jersey-common-2.26.jar:?]
      	at org.glassfish.jersey.internal.Errors.process(Errors.java:316) ~[jersey-common-2.26.jar:?]
      	at org.glassfish.jersey.internal.Errors.process(Errors.java:298) ~[jersey-common-2.26.jar:?]
      	at org.glassfish.jersey.internal.Errors.process(Errors.java:268) ~[jersey-common-2.26.jar:?]
      	at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:289) ~[jersey-common-2.26.jar:?]
      	at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:256) ~[jersey-server-2.26.jar:?]
      	at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:703) ~[jersey-server-2.26.jar:?]
      	at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:416) ~[jersey-container-servlet-core-2.26.jar:?]
      	... 88 more
      

      In CascadingMetaDataBuilder.addCascadingMetaData() the enclosingType is ObjectNode and the referenceType is java.lang.Iterable

      It seems TypeVariableBindings.getTypeVariableBindings( enclosingType ) is returning a Map that does not contain a binding for Iterable and thus we get the NPE because the code at CascadingMetaDataBuilder.java:395 assumes that the referenceType will always produce a result from the typeVariableBindings map.

      At the moment I do not have a workaround - I cannot remove the `@Valid` annotation from this field in the DTO as it is auto generated from a swagger template. And swagger doesn't support the fine grained control I would need to exclude this particular field from being annotated with @Valid.

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved: