From 9cd5c11656d7ebeb02832e099b3872669ae23f53 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 4aad5c07f58..36ed6abb019 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -42,6 +42,9 @@ Bug Fixes * SOLR-17098: ZK Credentials and ACLs are no longer sent to all ZK Servers when using Streaming Expressions. They will only be used when sent to the default ZK Host. (Houston Putman, Jan Høydahl, David Smiley, Gus Heck, Qing Xu) +* 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) + Optimizations --------------------- * SOLR-16555: SolrIndexSearcher - FilterCache intersections/andNot should not clone bitsets repeatedly (Kevin Risden, David Smiley) 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 590ce372e8e..e7ae6c4610c 100644 --- a/solr/core/src/java/org/apache/solr/update/UpdateLog.java +++ b/solr/core/src/java/org/apache/solr/update/UpdateLog.java @@ -959,8 +959,13 @@ private void applyOlderUpdates(@SuppressWarnings({"rawtypes"})SolrDocumentBase n for (String fieldName : olderDoc.getFieldNames()) { // 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); + } } } }