[ 
https://issues.apache.org/jira/browse/BVAL-184?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17246348#comment-17246348
 ] 

Romain Manni-Bucau commented on BVAL-184:
-----------------------------------------

I see, so you would validate a proxy where field validation is not expected 
until you use getters - which go through the proxy, I now get what you meant. 
For me it is expected to not work and it can not work generally speaking - your 
sample just being one particular case, here are the issues I see out of my head:
 # the unwrapping you implemented is not guaranteed to work, it just works in 
some particular cases
 # such bean validations are expected to be done in the bean (in postconstruct 
or so, validating them on methods or elsewhere - anywhere not aligned on the 
scope - is an antipattern)
 # a resolver is not enough until you have a global chain resolver since you 
must resolve owb proxies, potentially cglib ones, bytebuddy ones, javassist 
ones java.util.proxy ones and finally just return the instance you got as input 
otherwise the same exact bug applies
 # In terms of performance it is a huge regression for most apps (none will use 
that feature since it is not in the spec)

I suspect it can make sense for BValInterceptor more than manual validator case 
where caller can unwrap it when needed already so a SPI wouldn't help and 
BValInterceptor can be replaced by another impl thanks to CDI extension (and 
just be extended to return the right instance in InvocationContext if needed 
but CDI already does it).

So at the end I'm not sure there is really more gain to implement it than 
drawbacks and there is no cases where user can't solve it properly without any 
SPI AFAIK.

> Support for proxied instances
> -----------------------------
>
>                 Key: BVAL-184
>                 URL: https://issues.apache.org/jira/browse/BVAL-184
>             Project: BVal
>          Issue Type: New Feature
>            Reporter: Gerhard Petracek
>            Assignee: Gerhard Petracek
>            Priority: Major
>
> currently org.apache.bval.jsr.util.Proxies just detects the real class, but 
> that means only getters can get annotated.
> with a spi like
> {code}
> public interface InstanceResolver extends Comparable<InstanceResolver> {
>     <T> T resolveInstance(T instance);
>     //...
> }
> {code}
> it would be possible to create resolvers for external libs (like owb, weld, 
> ...)



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to