Can't use newer java.util.Map implementation with JavalinVue::stateFunction
See original GitHub issueI get this weird error as if I’m trying to set a null key:
JavalinVue.stateFunction = ctx -> Map.of(
"currentMsisdn", ctx.sessionAttribute("currentMsisdn"),
"verifiedMsisdn", ctx.sessionAttribute("verifiedMsisdn")
);
java.lang.NullPointerException
at java.base/java.util.Objects.requireNonNull(Objects.java:222)
at java.base/java.util.ImmutableCollections$MapN.<init>(ImmutableCollections.java:964)
at java.base/java.util.Map.of(Map.java:1328)
...
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Cannot implement java.util.Map - kotlin - Stack Overflow
I can't fully explain it, but it seems Kotlin really doesn't like referencing Java collections directly. For example, this is considered a ...
Read more >Map (Java Platform SE 8 ) - Oracle Help Center
An object that maps keys to values. A map cannot contain duplicate keys; each key can map to at most one value. This...
Read more >How to use a Map in Java - Code by Amir | Amir Boroumand
Let's create a HashMap with Integer keys and String values: Map<Integer, String> map = new HashMap<> ...
Read more >Immutable Map Implementations in Java | Baeldung
util.Map using ImmutableMap. It throws an UnsupportedOperationException whenever we try to modify it. Since it contains its own private data, ...
Read more >How to use keySet method in java.util.Map - CodeGym
The feature of this Set collection, that keeps the keys, is that there cannot be duplicate elements in it. The set is backed...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ah! I see, and
Context::sessionAttribute
returns a nullable. Hopefully the Kotlin team will add a@JvmOptional
annotation to their list of interop tools 😄. I’m closing the issue as the error is easily avoided by using the old Map, but maybe you can document the behavior so others can avoid this problem.Thanks again for your quick reply.
I’ll add the info label then 😃