Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-12237

MethodValidationPostProcessor fails for certain generic method signatures when running against Hibernate Validator 5

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Complete
    • Affects Version/s: 4.0.6
    • Fix Version/s: 4.2.1
    • Component/s: Core
    • Labels:
    • Last commented by a User:
      true

      Description

      I am trying to validate service layer method arguments using the MethodValidationPostProcessor. This is failing on, what appears to be, different the method signatures.

      With an interface such as:

      @Validated
      public interface Service<T> {
      
      	public T create(@Valid T item);
      	
      	public T update(String identifier, @Valid T item);
      }
      

      And the following implementation:

      @Named
      public class ItemService implements Service<Item>{
      
      	@Override
      	public Item create(Item item) {
      		return item;
      	}
      
      	@Override
      	public Item update(String identifier, Item item) {
      		return item;
      	}
      }
      

      Validation works fine when calling update(String, Item) but throws the following exception when calling create(Item):

      java.lang.IllegalArgumentException: HV000162: The validated type org.commons.test.validation.ItemService does not specify the constructor/method: public abstract java.lang.Object org.commons.test.validation.Service.create(java.lang.Object)
      

      This is also working fine if Service<T> is an abstract class and I just extend it.

      Attached is a sample application that demonstrates the problem.

        Attachments

          Activity

            People

            Assignee:
            juergen.hoeller Juergen Hoeller
            Reporter:
            amccormick Adam McCormick
            Last updater:
            Spring Issues Spring Issues
            Votes:
            3 Vote for this issue
            Watchers:
            8 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Days since last comment:
              3 years, 24 weeks, 4 days ago