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

[GSS](7.3.z) @Valid annotation on parameter doesn't get picked up by subclass

XMLWordPrintable

    • +
    • Hide
      1. Download and unzip reproducer-7.3.2.zip.
      2. Install a clean JBoss EAP 7.3
      3. Patch to 7.3.2
      4. Run - test will fail
           $ mvn -Peap7 -DJBOSS_HOME=/path/to/jboss-eap-7.3 clean package verify
        
      1. Roll patch back to 7.3.1
      2. Run again
      3.    $ mvn -Peap7 -DJBOSS_HOME=/path/to/jboss-eap-7.2 clean package verify
        
      1. Tests will pass.

       

      Show
      Download and unzip reproducer-7.3.2.zip. Install a clean JBoss EAP 7.3 Patch to 7.3.2 Run - test will fail $ mvn -Peap7 -DJBOSS_HOME=/path/to/jboss-eap-7.3 clean package verify Roll patch back to 7.3.1 Run again $ mvn -Peap7 -DJBOSS_HOME=/path/to/jboss-eap-7.2 clean package verify Tests will pass.  

      When having an interface with method:

         @POST
          Response createDummy(@Valid DummyClass payload);
      

      And a subclass that implements it with:

         @Override
          public Response createDummy(DummyClass payload)
      

      The code will only validate the parameter if @Valid is added on the subclass. He interprets that as a bug. Looking at the spec, I believe he is correct, going by section 7.5

      From the JAX-RS spec

      > *Annotation Inheritance*
      > The rules for inheritance of constraint annotation are defined in [16]. It is worth noting that these rules
      > are incompatible with those defined in Section 3.6. Generally speaking, constraint annotations in [16] are
      > cumulative (can be strengthen) across a given type hierarchy while JAX-RS annotations are inherited or,
      > overridden and ignored.
      > The goal of this specification is to enable validation of JAX-RS resources by leveraging existing Bean
      > Validation implementations. Therefore, JAX-RS implementations MUST follow the constraint annotation
      > rules defined in [16].

      It appears to work with @Valid in JBoss EAP 6, though I know that implementation was tech preview.

      While adding @Valid will in every subclass will work, this would be a large undertaking for the customer, so they would like to know if there is an easier workaround.

              rhn-engineering-lgao Lin Gao
              rhn-engineering-lgao Lin Gao
              Votes:
              0 Vote for this issue
              Watchers:
              11 Start watching this issue

                Created:
                Updated:
                Resolved: