A warning about Spring converters
Cantor, Scott
cantor.2 at osu.edu
Mon Aug 4 10:36:13 EDT 2014
On 8/4/14, 10:08 AM, "Rod Widdowson" <rdw at steadingsoftware.com> wrote:
>But some time ago we added an explicit Converter<String,Predicate> to
>allow
>us to say "false" and get back the "AlwaysFalse" predicate. This makes a
>lot of sense for easy configuration.
>
>The trouble is that this then meant that when it encountered the stanza
>Spring first of all converted the String into a Predicate and then calle
>the
>*other* constructor for the predicate (which now always returns false).
Oops. That was me, of course.
>So to go back to the top, you should be aware of this pothole, and if
>anyone
>has suggestions of ways to look out for duplicates of bugs like this I'd
>be
>glad to hear them...
I think probably we need to try and avoid the shorthand string->list
conversion where we can, and only use it if there's a clear comment and a
cross-check that it's safe.
Note that usually the named parameter or argument will be a plural name,
so that's a hint that the content should be a collection, not a single
value.
-- Scott
More information about the dev
mailing list