You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2013/11/18 19:37:26 UTC
[Bug 55792] Collection literals not recognized within stream lambda
expression, result in syntax error
https://issues.apache.org/bugzilla/show_bug.cgi?id=55792
--- Comment #1 from Nick Williams <ni...@nicholaswilliams.net> ---
Please note the following revision to this bug:
It's only the map-literal that isn't working. The list-literal is working fine.
When I used the list-literal originally, I mapped before sorting, like so:
${users.stream()
.filter(u -> fn:contains(u.username, '1'))
.map(u -> [u.username, u.firstName, u.lastName])
.sorted((u1, u2) -> (x = u1.lastName.compareTo(u2.lastName);
x == 0 ? u1.firstName.compareTo(u2.firstName) : x))
.toList()}
This caused the NumberFormatException, which makes sense. When mapping happens
after sorting:
${users.stream()
.filter(u -> fn:contains(u.username, '1'))
.sorted((u1, u2) -> (x = u1.lastName.compareTo(u2.lastName);
x == 0 ? u1.firstName.compareTo(u2.firstName) : x))
.map(u -> [u.username, u.firstName, u.lastName])
.toList()}
The expression works correctly. So the ONLY expression that isn't working uses
the map-literal for the mapping:
${users.stream()
.filter(u -> fn:contains(u.username, '1'))
.sorted((u1, u2) -> (x = u1.lastName.compareTo(u2.lastName);
x == 0 ? u1.firstName.compareTo(u2.firstName) : x))
.map(u -> {'username':u.username, 'first':u.firstName,
'last':u.lastName})
.toList()}
This is definitely broken, as the } ending the map-literal makes the EL engine
think the expression has ended prematurely.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org