Skip to content

Apache Lucene open-source search software

SOLR-9339: NPE in CloudSolrClient when the response is null

Noble Paul9a24dc5d2ca8
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index e392df34d59..4da2d0eef94 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -163,6 +163,8 @@ Bug Fixes
* SOLR-9334: CloudSolrClient.collectionStateCache is unbounded (noble)
+* SOLR-9339: NPE in CloudSolrClient when the response is null (noble)
+
Optimizations
----------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java
index b4c9b4f9560..1f1c675c827 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java
@@ -1060,7 +1060,7 @@ public class CloudSolrClient extends SolrClient {
try {
resp = sendRequest(request, collection);
//to avoid an O(n) operation we always add STATE_VERSION to the last and try to read it from there
- Object o = resp.get(STATE_VERSION, resp.size()-1);
+ Object o = resp == null || resp.size() == 0 ? null : resp.get(STATE_VERSION, resp.size() - 1);
if(o != null && o instanceof Map) {
//remove this because no one else needs this and tests would fail if they are comparing responses
resp.remove(resp.size()-1);