-
Notifications
You must be signed in to change notification settings - Fork 38.6k
Closed
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)type: bugA general bugA general bug
Milestone
Description
Sam Brannen opened SPR-7323 and commented
The inconsistent behavior is due to improper tracking of the lastKey
for maps in Selection.getValueInternal(ExpressionState)
.
The following can be used to reproduce the bug:
class MapTestBean {
private final Map<String, String> colors = new TreeMap<String, String>();
MapTestBean() {
colors.put("red", "rot");
colors.put("brown", "braun");
colors.put("blue", "blau");
colors.put("yellow", "gelb");
colors.put("beige", "beige");
}
public Map<String, String> getColors() {
return colors;
}
}
EvaluationContext context = new StandardEvaluationContext(new MapTestBean());
ExpressionParser parser = new SpelExpressionParser();
Expression exp = parser.parseExpression("colors.$[key.startsWith('b')]");
Map<String, String> colorsMap = (Map<String, String>) exp.getValue(context);
assertEquals(1, colorsMap.size());
assertEquals("brown", colorsMap.keySet().iterator().next());
The above test currently fails with:
org.junit.ComparisonFailure: expected:<[brown]> but was:<[yellow]>
Affects: 3.0.3
Metadata
Metadata
Assignees
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)type: bugA general bugA general bug