-
Notifications
You must be signed in to change notification settings - Fork 38.4k
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
Compatibility with Bean Validation 2.0 and JPA 2.2 [SPR-13482] #18061
Comments
Juergen Hoeller commented Let's reduce this ticket to Bean Validation 2.0, since Java EE 8 will only have a minor JPA 2.1 maintenance revision now. |
Gunnar Morling commented Hi, we'll release Bean Validation 2.0.0.Alpha1 and Hibernate Validator 6.0.0.Alpha1 within the next few days. Happy about any feedback of course. If there is anything you think we should consider in the spec to ease usage withing Spring-based applications, please let us know, e.g. by sending a mail to beanvalidation-dev. |
Juergen Hoeller commented Hey Gunnar Morling, thanks for reaching out! We'll definitely give it a spin once available, possibly in time for our 5.0 M5 still. |
Juergen Hoeller commented Gunnar Morling, Hibernate Validator 6.0 Alpha 1 works fine with Spring as far as I can tell. The only gotcha is the new Just wondering: Could you possibly declare such new methods as default methods (even returning |
Juergen Hoeller commented Gunnar Morling, Hibernate Validator 6.0 Alpha 2 works equally well with Spring at runtime, at least for my initial round of testing.
That said, it would sure be nice to upgrade our build to BV 2.0 proper. So as suggested above, I'm still in favor of having |
Gunnar Morling commented Juergen Hoeller, sorry, I somehow missed your comment from February, the safest is always to use our mailing list. Concerning the clock provider contract we could make it a On making I'm wondering though what issue you actually are seeing. I'd have expected that the new type doesn't cause issues when using your decorator at runtime with the 1.1 API (as long as the new method isn't invoked of course). I just did a test, compiling a decorator against 2.0.0.Alpha2 and using it with the 1.1.0.Final API at runtime. I could invoke methods on the decorator without any problem. |
Juergen Hoeller commented Gunnar Morling, such method signatures with types that don't exist on the classpath caused a lot of subtle trouble for us over the years. It's a brittle arrangement: Any attempt to reflect upon that class (e.g. As for In Servlet 4.0, they have a similar situation with |
Gunnar Morling commented I see your point about Do you have a pointer to the related discussion in Servlet 4.0 by any chance? I feel it's a bit of a miss-use of default methods really. |
Juergen Hoeller commented Iterating the methods usually comes from some kind of container environment, e.g. trying to find certain annotations. For better or for worse, it's the norm in both a Spring container (with annotating processing activated) and a CDI environment these days, applied to any class that appears in a list of candidate component types or even just the declared return type of a factory method. As for the exposure of such a type on an interface (whether as a default method or not), that depends on the version of that interface in the classpath then: In BV 1.1, What we currently do (and historically always did) is to simply compile against the minimum version of any such target API, with the compiler not forcing us to implement any such new methods then. As long as those new methods aren't actually called at runtime (which won't ever be the case here on a Now for Spring Framework 5.0, it's just a nuisance that we can't build against BV 2.0 (and HV 6.0) then; we'll have to keep building against BV 1.1 (and HV 5.4) until we can raise our minimum requirement to BV 2.0. In fact, we'd love to raise that requirement immediately, and BV 2.0 is easy enough to bring into Boot or Tomcat/Jetty stacks: However, we couldn't reliably run on EE 7 stacks anymore then which expose BV 1.1 by default. Even on WildFly, we need to support unpatched versions: It's not really an option to enforce a BV 2.0 upgrade for WildFly 10.x there; the best we can do is to leniently support BV 2.0 when present at runtime. Good question about such discussions on the Servlet 4.0 EG; we'd have to ask them. They've consistently applied that principle since Servlet 4.0 b01 without much discussion, it seems. As for misuse of default methods, well, arguably the default method mechanism has been introduced for exactly such compatibility stories with existing implementations, in particular on |
Gunnar Morling commented Juergen Hoeller, I've been thinking a bit more about the default method route. I first assumed you suggested to add an empty default method (which is why I considered it as a "hack"), but I came to realize that you probably meant it to be an actually functional default method implementation. That would indeed be inline with the semantics of default methods, but I don't think we can do it. The problem is that those methods return the effectively configured implementations for message parameter, clock provider et al. So we cannot do a simple default implementation (e.g. for clock provider, based on the VM's time and timezone) but instead would have to implement the retrieval of configured values via XML and so on. That's not really feasible to do for the API.
Those methods actually also matter from the client perspective. Their use case is to obtain the value configured for the factory and create a Would it be possible that you provide two decorators, one for BV 1.1 and one for 2.0. You'd probably have to have two modules of sort, or some switch in your bootstrapping routine so it plugs in the right decorator version. I see how it'd be a tad more complex on your side, but I think that'd be the cleanest approach to take. |
Juergen Hoeller commented I'll mark this ticket as resolved now, with Hibernate Validator 6.0 beta 2 tested and a few further steps taken for our upcoming 5.0 RC2:
Also, |
Juergen Hoeller opened SPR-13482 and commented
There are loose plans for JPA 2.2 and Bean Validation 2.0 revisions within the Java EE 8 umbrella in 2017. Let's make sure to be fully compatible with those API updates and support their new features where feasible (it looks like there won't be much to do anyway).
http://beanvalidation.org/2.0/spec/2.0.0.beta1/
https://jcp.org/aboutJava/communityprocess/maintenance/jsr338/ChangeLog-JPA-2.2-MR.txt
Issue Links:
1 votes, 5 watchers
The text was updated successfully, but these errors were encountered: