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

When using a sub-resource locator method that returns a CDI managed sub-resource class, bean validation occurs twice on the constrained methods contained in that sub-resource class.

XMLWordPrintable

    • Hide

      Create a root resouce class:

      public class RootResource {

      @Inject
      private SubResource subResource;

      @Path("/sub")
      public SubResource getSubResouce()

      { return subResource; }

      }

      public class SubResource {

      @Path("/:id")
      @GET
      public void get(@PathParam(ID_PARAM) Long id,
      @Valid @BeanParam StdQueryBeanParam queryParams)

      { // queryParams will be validated twice... }

      }

      public class StdQueryBeanParam {

      @Size(max = 5)
      @QueryParam("limit")
      private String limit;

      String getLimit()

      { return limit; }

      }

      Show
      Create a root resouce class: public class RootResource { @Inject private SubResource subResource; @Path("/sub") public SubResource getSubResouce() { return subResource; } } public class SubResource { @Path("/:id") @GET public void get(@PathParam(ID_PARAM) Long id, @Valid @BeanParam StdQueryBeanParam queryParams) { // queryParams will be validated twice... } } public class StdQueryBeanParam { @Size(max = 5) @QueryParam("limit") private String limit; String getLimit() { return limit; } }
    • Medium

      When using a sub-resource locator method that returns a CDI managed sub-resource class, bean validation occurs twice on the constrained methods contained in that sub-resource class. During the request, first Resteasy's GeneralValidatorImpl class calls its #validateAllParameters method which in turn calls the ValdiatorImpl #validateParameters method. Second, the Hibernate ValidationInterceptor class has its #validateMethodInvocation method called, which again calls the ValidatorImpl #validateParameters method, and thereby causing validation to occur twice and duplicate constraint violation messages to be created.

            rsigal@redhat.com Ronald Sigal
            etayjboss99 Eric Taylor (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: