Clarify inconsistency between Spec Section 1.6 (`value-b` is `null`) and `MapELResolver` Javadoc regarding `null` keys
Maintainers usually reply within 7 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
Research direction
Start by comparing specification Section 1.6 with the MapELResolver Javadoc for getValue, setValue, and isReadOnly, then check the existing TCK tests for EL map access. The issue asks whether null keys in expressions should short-circuit and whether a test should cover ${map[null]} when the map contains a null key. Done means the intended behavior is resolved and the specification or TCK coverage is updated accordingly.
Written by the indexing model from the issue text.
Description
There is an inconsistency between Section 1.6 ("Operators [] and .") of the Jakarta Expression Language 6.1 specification document and the Javadoc of jakarta.el.MapELResolver:
- Specification Document — Section 1.6 ("Operators
[]and."):To evaluate
expr-a[expr-b]orexpr-a[expr-b](params):- Evaluate
expr-aintovalue-a. - [...]
- Evaluate
expr-bintovalue-b. - If
value-bisnull:- If
expr-a[expr-b]is the last property being resolved:- If the expression is a value expression and
ValueExpression.getValue(context)was called to initiate this expression evaluation, returnnull. - Otherwise, throw
PropertyNotFoundException. [trying to de-reference null for an lvalue]
- If the expression is a value expression and
- Otherwise, return
null.
- If
- Evaluate
jakarta.el.MapELResolverJavadoc (getValue,setValue,isReadOnly):@throws NullPointerException if context is null, or if the key is null and this map does not permit null keys (the latter is optionally thrown by the underlying Map).
Because Section 1.6 mandates returning null (for getValue) or throwing PropertyNotFoundException (for setValue/getType/isReadOnly) whenever value-b is null before invoking elResolver, MapELResolver is never invoked with property == null during EL expression evaluation (e.g. ${map[null]}), even when the underlying Map (such as HashMap) contains a mapping for the null key.
Steps to Reproduce
import jakarta.el.ELProcessor;
import org.junit.jupiter.api.Test;
import java.util.HashMap;
import java.util.Map;
import static org.junit.jupiter.api.Assertions.assertNull;
public class MapNullKeyTest {
@Test
void testMapWithNullKey() {
Map<String, String> map = new HashMap<>();
map.put(null, "null-key-value");
ELProcessor processor = new ELProcessor();
processor.defineBean("map", map);
// Following Section 1.6, expr-b evaluates to null and short-circuits to null
// without calling MapELResolver.getValue(context, map, null)
Object result = processor.eval("map[null]");
assertNull(result);
}
}
Question / TCK Request
- Is the
nullkey handling inMapELResolverintended strictly for direct programmatic calls toELResolver#getValue(context, base, null), while EL expressions${map[null]}must always short-circuit tonullper Section 1.6? - Could a TCK test be added for
${map[null]}(whenmapcontains anullkey) to explicitly validate Section 1.6 compliance?
- Dominant language
- Java
- Stars
- 86
- Forks
- 54
- Avg merge
- 6d 9h
- Merged PRs (30d)
- 11
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from jakartaee/expression-language
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
jakartaee/expression-language#501 ·
Maintainers usually reply within 7 days
-
ELProcessor.defineFunction() fails for valid method signaturesPossibly taken @RaphaelFakhri claimed this 8 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
jakartaee/expression-language#492 ·
Maintainers usually reply within 7 days
-
Difficulty 4/5 3-5 days Newbie friendliness 46/100
jakartaee/expression-language#503 ·
Maintainers usually reply within 7 days
-
Difficulty 4/5 3-5 days Newbie friendliness 57/100
jakartaee/expression-language#502 ·
Maintainers usually reply within 7 days
-
certification
Difficulty 1/5 Under an hour Newbie friendliness 20/100
jakartaee/expression-language#494 · 2 reactions ·
Maintainers usually reply within 7 days
All issues in jakartaee/expression-language
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
wultra/powerauth-tests#980 ·
-
account bug communication lecture
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
line/centraldogma#1397 ·
Maintainers usually reply within 2 days
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
cryptomator/hub#515 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
vert-x3/vertx-mail-client#268 ·