From 9e6e11bdf54a2674fe707cbf94e7f1250dd60176 Mon Sep 17 00:00:00 2001 From: Libo Song Date: Thu, 9 May 2024 09:52:49 -0400 Subject: [PATCH] Fix NPE in dictsort. --- .../java/com/hubspot/jinjava/lib/filter/DictSortFilter.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/com/hubspot/jinjava/lib/filter/DictSortFilter.java b/src/main/java/com/hubspot/jinjava/lib/filter/DictSortFilter.java index 4a7135dfd..3f3f3736f 100644 --- a/src/main/java/com/hubspot/jinjava/lib/filter/DictSortFilter.java +++ b/src/main/java/com/hubspot/jinjava/lib/filter/DictSortFilter.java @@ -88,6 +88,9 @@ private static class MapEntryComparator public int compare(Entry o1, Entry o2) { Object sVal1 = sortByKey ? o1.getKey() : o1.getValue(); Object sVal2 = sortByKey ? o2.getKey() : o2.getValue(); + if (sVal1 == null || sVal2 == null) { + return 0; + } int result = 0;