From eb9792cdbcd8a8123c27d4be85cd505b951a9dc4 Mon Sep 17 00:00:00 2001 From: Renato Haeberli Date: Mon, 20 Jan 2025 09:46:41 +0100 Subject: [PATCH] SOLR-17623: fix case for contains(null) --- .../org/apache/solr/common/util/SimpleOrderedMap.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/solr/solrj/src/java/org/apache/solr/common/util/SimpleOrderedMap.java b/solr/solrj/src/java/org/apache/solr/common/util/SimpleOrderedMap.java index ad64fb4c9d6..1aab8a93baa 100644 --- a/solr/solrj/src/java/org/apache/solr/common/util/SimpleOrderedMap.java +++ b/solr/solrj/src/java/org/apache/solr/common/util/SimpleOrderedMap.java @@ -21,6 +21,7 @@ import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Set; import org.apache.commons.lang3.tuple.ImmutablePair; @@ -107,7 +108,8 @@ public boolean containsKey(final Object key) { public boolean containsValue(final Object value) { int sz = size(); for (int i = 0; i < sz; i++) { - if (value.equals(getVal(i))) { + T val = getVal(i); + if (Objects.equals(value, val)) { return true; } } @@ -159,8 +161,8 @@ public Collection values() { @SuppressWarnings({"unchecked"}) public Set> entrySet() { var values = new HashSet>(); - for (int i = 0; i < nvPairs.size() - 1; i +=2) { - values.add(ImmutablePair.of((String) nvPairs.get(i), (T) nvPairs.get(i + 1))); + for (int i = 0; i < nvPairs.size() - 1; i += 2) { + values.add(ImmutablePair.of((String) nvPairs.get(i), (T) nvPairs.get(i + 1))); } return values; }