diff --git a/src/main/java/com/hubspot/jinjava/el/ext/CollectionMembershipOperator.java b/src/main/java/com/hubspot/jinjava/el/ext/CollectionMembershipOperator.java index 28c93dd0a..58c1d71a7 100644 --- a/src/main/java/com/hubspot/jinjava/el/ext/CollectionMembershipOperator.java +++ b/src/main/java/com/hubspot/jinjava/el/ext/CollectionMembershipOperator.java @@ -48,8 +48,12 @@ public Object apply(TypeConverter converter, Object o1, Object o2) { if (Map.class.isAssignableFrom(o2.getClass())) { Map map = (Map) o2; if (!map.isEmpty()) { + Object key = map.keySet().iterator().next(); + if (key == null) { + return Boolean.FALSE; + } try { - Class keyClass = map.keySet().iterator().next().getClass(); + Class keyClass = key.getClass(); return map.containsKey(converter.convert(o1, keyClass)); } catch (ELException | NoSuchElementException e) { return Boolean.FALSE;