Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Random results for JSR-303 method constraint validation on generically typed methods [SPR-10384] #15017

Closed
spring-projects-issues opened this issue Mar 15, 2013 · 3 comments
Assignees
Labels
in: core

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Mar 15, 2013

Jan Goyvaerts opened SPR-10384 and commented

Trying to make method validation work using Hibernate Validator 4.3.0.

Running the very same code over and over again yields different results. Sometimes everything gets validated. Sometimes not. And occasionally I'm getting an unexpected exception.

I've prepared a test case. Simply run maven "install test".

I'm aware I might be barking at the wrong tree here. Maybe it's not Spring's plumbing that is to blame. But rather HV. On the other hand, this are quite straightforward cases...

Running on Linux x64 (Arch) & JDK 1.6.0_43.


Affects: 3.2.2

Attachments:

Issue Links:

0 votes, 6 watchers

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented May 15, 2013

Juergen Hoeller commented

Since you're making heavy use of generics there, I suspect that what you're seeing is a bridge method problem where the runtime invocation may come in as a compiler-generated bridge method instead of the originally declared method. The bridge method won't have any annotations on it, so method validation would obviously fail then.

However, unfortunately, I'm getting mixed results even with an explicit call to our BridgeMethodResolver. Maybe it is picking up the method from the sub-interface as opposed to the base interface and only finding the constraint annotations in one but not the other case. A JVM is quite free to play games with reflection here.

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented May 15, 2013

Juergen Hoeller commented

This turns out to be rather involved, and indeed only occuring for generically typed methods. We'll certainly do something about it (if Hibernate Validator itself doesn't, since it could resolve such an ambiguous Method handle as well), but probably only in the 4.x line.

Juergen

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Mar 23, 2017

Juergen Hoeller commented

I cannot reproduce this against Hibernate Validator 5.x on JDK 8 anymore, going through the Bean Validation 1.1 method validation API. So I assume this has been addressed on Hibernate Validator's side in the meantime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core
Projects
None yet
Development

No branches or pull requests

2 participants