Skip to content

MethodValidationPostProcessor fails for certain generic method signatures when running against Hibernate Validator 5 [SPR-12237] #22186

@spring-projects-issues

Description

@spring-projects-issues

Adam McCormick opened SPR-12237 and commented

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.


Affects: 4.0.6

Attachments:

Referenced from: commits 7118fcf

3 votes, 8 watchers

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions