Uploaded image for project: 'RESTEasy'
  1. RESTEasy
  2. RESTEASY-2503

After first invocation on an EJB, class/field/property constraints don't get checked

XMLWordPrintable

    • Hide
      1. Download and unzip reproducer with long name.
      2. Edit src/test/arquillian.xml and uncomment the jbossHome variable.
      3. Install a clean JBoss EAP 7.2.x
      4. Run - test will fail
           $ mvn -Peap7 -DJBOSS_HOME=/path/to/jboss-eap-7.2 clean package verify
        
      5. Edit ./src/main/java/com/arquillian/DummyEjb.java and add @Valid to the parameters of both methods
      6. Run again
           $ mvn -Peap7 -DJBOSS_HOME=/path/to/jboss-eap-7.2 clean package verify
        
      7. Tests will pass.

      Running with JBoss EAP 6:

         $ mvn -Peap6 -DJBOSS_HOME=/path/to/jboss-eap-6.4 clean package verify
      

      The tests will pass without a change. Changes must be made to the reproducer to test it JBoss EAP 7.1.6, but it has the same issue - @Valid must be defined on the subclass.

      Show
      Download and unzip reproducer with long name. Edit src/test/arquillian.xml and uncomment the jbossHome variable. Install a clean JBoss EAP 7.2.x Run - test will fail $ mvn -Peap7 -DJBOSS_HOME=/path/to/jboss-eap-7.2 clean package verify Edit ./src/main/java/com/arquillian/DummyEjb.java and add @Valid to the parameters of both methods Run again $ mvn -Peap7 -DJBOSS_HOME=/path/to/jboss-eap-7.2 clean package verify Tests will pass. Running with JBoss EAP 6: $ mvn -Peap6 -DJBOSS_HOME=/path/to/jboss-eap-6.4 clean package verify The tests will pass without a change. Changes must be made to the reproducer to test it JBoss EAP 7.1.6, but it has the same issue - @Valid must be defined on the subclass.

      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.

              rsigal@redhat.com Ronald Sigal
              rhn-support-dguthrie David Guthrie
              Votes:
              2 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: