<div dir="ltr">Hey Matt,<div><br></div><div>I think you&#39;re giving too much bonus to the original authors of that test method and their well-meaning intentions ;) IMO the test is simply incorrect, for sure the intention was not that a single Order should implicitly be handled as a single-element Set&lt;Order&gt;.</div><div><br></div><div>The reason it doesn&#39;t fail with the RI is simply the fact that the RI is actually doing what the test seeks to ensure: @Valid isn&#39;t applied by validateValue(), i.e. the algorithm never gets to the point where it&#39;d make use of the given value to recursively validate the constraints of the &quot;orders&quot; property. Were validateValue() be invoked for another property with a local constraint, a ClassCastException would occur when trying to feed the non-matching value to the ConstraintValidator.</div><div><br></div><div>Can you open a BVTCK issue for fixing this test? A Set&lt;Order&gt; containing the Order object should be passed to validateValue().</div><div><br></div><div>Regarding the expected behaviour, indeed the spec doesn&#39;t mandate something specifically. I don&#39;t think it&#39;s a big problem, though, because the non-matching value will cause an exception in one or another way anyways. Theoretically we could mandate a specific IllegalArgumentException in that case, but that&#39;d require an instanceof check up front, and I don&#39;t think I wanted to impose this to implementations. I&#39;d rather leave it as is; of course an implementation is free to do such check, as Apache Bval was doing it.</div><div><br></div><div>As far as ExecutableValidator is concerned, there it says to raise an exception if &quot;parameters don&#39;t match with each other&quot;. This leaves some leeway on the exact checks to implement and also here I&#39;d prefer to keep it that way, instead of enforcing potentially costly checks at the spec level.</div><div><br></div><div>--Gunnar</div><div class="gmail_extra"><br><div class="gmail_quote">2018-03-30 17:33 GMT+02:00 Matt Benson <span dir="ltr">&lt;<a href="mailto:mbenson@apache.org" target="_blank">mbenson@apache.org</a>&gt;</span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I would add that other recent discussions have borne out my<br>
interpretation of the ExecutableValidator javadoc in saying that<br>
incompatible parameter/return values should raise<br>
IllegalArgumentExceptions. I would see this as a precedent in the case<br>
of #validateValue().<br>
<span class="HOEnZb"><font color="#888888"><br>
Matt<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
On Fri, Mar 30, 2018 at 10:17 AM, Matt Benson &lt;<a href="mailto:mbenson@apache.org">mbenson@apache.org</a>&gt; wrote:<br>
&gt; Hi, this comes from TCK<br>
&gt; ValidateValueTest#<wbr>testValidIsNotHonoredValidateV<wbr>alue() . The test<br>
&gt; asserts that no constraint violations (and no exceptions) will be<br>
&gt; generated when specifying an Order as a proposed value for a property<br>
&gt; that includes a Set of Orders. The name of the test suggests to me,<br>
&gt; however, that the Validator is expected to transparently treat the<br>
&gt; Order as a single-element Set and simply show that validation of that<br>
&gt; set is not cascaded. Is this the case, or is the test actually showing<br>
&gt; that any incompatible value will be treated as raising no violations<br>
&gt; (and is therefore imperfectly named)? In either case, where does the<br>
&gt; specification dictate this behavior? Apache BVal has always raised an<br>
&gt; IllegalArgumentException if the specified value is not compatible, but<br>
&gt; its justification for having done so appears to be an artifact of an<br>
&gt; incorrect interpretation of the Javadoc of #validateValue(): &quot;not a<br>
&gt; valid object property&quot; was mistakenly applied to the &quot;value&quot; parameter<br>
&gt; instead of to the &quot;propertyName&quot; parameter as a careful reading<br>
&gt; reveals (IMO) is proper. But this exposes what seems to be an omission<br>
&gt; in the spec: what *is* the proper behavior when validation of an<br>
&gt; incompatible value is requested? And let&#39;s not forget the unclear<br>
&gt; nature of the test in question: is &quot;order&quot; a compatible value by<br>
&gt; virtue of being checked against a Set of its type (and, if so, why?),<br>
&gt; or is &quot;order&quot; an incompatible value that the Validator quietly<br>
&gt; abstains from checking at all?<br>
&gt;<br>
&gt; Thanks,<br>
&gt; Matt<br>
______________________________<wbr>_________________<br>
beanvalidation-dev mailing list<br>
<a href="mailto:beanvalidation-dev@lists.jboss.org">beanvalidation-dev@lists.<wbr>jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/beanvalidation-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/<wbr>mailman/listinfo/<wbr>beanvalidation-dev</a><br>
</div></div></blockquote></div><br></div></div>