From 571c8871278bc14aea683420aea58ef64e38bbae Mon Sep 17 00:00:00 2001 From: Calvin Smith Date: Wed, 24 Jan 2024 10:29:09 -0800 Subject: [PATCH] SOLR-17120: handle null value when merging partials (#2214) * SOLR-17120 handle null value when merging partials - this change avoids a `NullPointerException` that can occur under some circumstances when performing multiple partial updates of the same document --- solr/CHANGES.txt | 3 +++ solr/core/src/java/org/apache/solr/update/UpdateLog.java | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index b2c00b14911..36b7be60896 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -195,6 +195,9 @@ Bug Fixes * SOLR-17074: Fixed not correctly escaped quote in bin/solr script (Dominique BĂ©jean, Vincenzo D'Amore) +* SOLR-17120: Fix NullPointerException in UpdateLog.applyOlderUpdates that can occur if there are multiple partial + updates of the same document in separate requests using commitWithin. (Calvin Smith, Christine Poerschke) + Dependency Upgrades --------------------- * SOLR-17012: Update Apache Hadoop to 3.3.6 and Apache Curator to 5.5.0 (Kevin Risden) diff --git a/solr/core/src/java/org/apache/solr/update/UpdateLog.java b/solr/core/src/java/org/apache/solr/update/UpdateLog.java index c9301356a0c..c13530891fd 100644 --- a/solr/core/src/java/org/apache/solr/update/UpdateLog.java +++ b/solr/core/src/java/org/apache/solr/update/UpdateLog.java @@ -1020,8 +1020,13 @@ private void applyOlderUpdates( // if the newerDoc has this field, then this field from olderDoc can be ignored if (!newerDoc.containsKey(fieldName) && (mergeFields == null || mergeFields.contains(fieldName))) { - for (Object val : olderDoc.getFieldValues(fieldName)) { - newerDoc.addField(fieldName, val); + Collection values = olderDoc.getFieldValues(fieldName); + if (values == null) { + newerDoc.addField(fieldName, null); + } else { + for (Object val : values) { + newerDoc.addField(fieldName, val); + } } } }