Apache Solr open-source search software
SOLR-16265: Fix NPE for req in Http2SolrClient (#1860)
Houston Putmanc79c8994b5e2
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.javaindex 63fc96f2b77..867b5edc85d 100644--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java@@ -528,34 +528,35 @@ public class Http2SolrClient extends SolrClient {InputStreamResponseListener listener = new InputStreamResponseListener();req = makeRequestAndSend(solrRequest, url, listener, false);Response response = listener.get(idleTimeoutMillis, TimeUnit.MILLISECONDS);+ url = req.getURI().toString();InputStream is = listener.getInputStream();assert ObjectReleaseTracker.track(is);- return processErrorsAndResponse(solrRequest, response, is, req.getURI().toString());+ return processErrorsAndResponse(solrRequest, response, is, url);} catch (InterruptedException e) {Thread.currentThread().interrupt();abortCause = e;throw new RuntimeException(e);} catch (TimeoutException e) {throw new SolrServerException(- "Timeout occurred while waiting response from server at: " + req.getURI(), e);+ "Timeout occurred while waiting response from server at: " + url, e);} catch (ExecutionException e) {Throwable cause = e.getCause();abortCause = cause;if (cause instanceof ConnectException) {- throw new SolrServerException("Server refused connection at: " + req.getURI(), cause);+ throw new SolrServerException("Server refused connection at: " + url, cause);}if (cause instanceof SolrServerException) {throw (SolrServerException) cause;} else if (cause instanceof IOException) {throw new SolrServerException(- "IOException occurred when talking to server at: " + req.getURI(), cause);+ "IOException occurred when talking to server at: " + url, cause);}throw new SolrServerException(cause.getMessage(), cause);} catch (SolrServerException | RuntimeException sse) {abortCause = sse;throw sse;} finally {- if (abortCause != null) {+ if (abortCause != null && req != null) {req.abort(abortCause);}}