Skip to content

Commit

Permalink
SOLR-17120: handle null value when merging partials (backport of solr…
Browse files Browse the repository at this point in the history
…#2214) (#2683)

* 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

Co-authored-by: Calvin Smith <eukaryote@users.noreply.github.com>
  • Loading branch information
cpoerschke and eukaryote committed Jan 26, 2024
1 parent f13b673 commit 78e6184
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
3 changes: 3 additions & 0 deletions solr/CHANGES.txt
Expand Up @@ -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)
Expand Down
9 changes: 7 additions & 2 deletions solr/core/src/java/org/apache/solr/update/UpdateLog.java
Expand Up @@ -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<Object> values = olderDoc.getFieldValues(fieldName);
if (values == null) {
newerDoc.addField(fieldName, null);
} else {
for (Object val : values) {
newerDoc.addField(fieldName, val);
}
}
}
}
Expand Down

0 comments on commit 78e6184

Please sign in to comment.