From ad7e704c8ee232bb96894c536f6a12d2a7979caf Mon Sep 17 00:00:00 2001 From: David Smiley Date: Fri, 31 Jul 2026 13:00:48 -0400 Subject: [PATCH 1/2] SolrRequest.setPath fix; allow null and the constructor should use the same validation. --- .../src/java/org/apache/solr/client/solrj/SolrRequest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/SolrRequest.java b/solr/solrj/src/java/org/apache/solr/client/solrj/SolrRequest.java index 7574bd38967..11665a52828 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/SolrRequest.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/SolrRequest.java @@ -157,7 +157,7 @@ public String getBasicAuthPassword() { public SolrRequest(METHOD m, String path, SolrRequestType requestType) { this.method = m; - this.path = path; + setPath(path); this.requestType = requestType; } @@ -182,7 +182,7 @@ public String getPath() { } public void setPath(String path) { - if (path == null || !path.startsWith("/")) { + if (path != null && !path.startsWith("/")) { throw new IllegalArgumentException("Must start with a '/': " + path); } From 733c539513d5b4b19c035ad69a9b588b6b7660b6 Mon Sep 17 00:00:00 2001 From: David Smiley Date: Fri, 31 Jul 2026 15:29:04 -0400 Subject: [PATCH 2/2] extract validate so isn't overridden --- .../java/org/apache/solr/client/solrj/SolrRequest.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/SolrRequest.java b/solr/solrj/src/java/org/apache/solr/client/solrj/SolrRequest.java index 11665a52828..fb975b9bab2 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/SolrRequest.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/SolrRequest.java @@ -157,7 +157,7 @@ public String getBasicAuthPassword() { public SolrRequest(METHOD m, String path, SolrRequestType requestType) { this.method = m; - setPath(path); + this.path = validatePath(path); this.requestType = requestType; } @@ -182,11 +182,14 @@ public String getPath() { } public void setPath(String path) { + this.path = validatePath(path); + } + + private static String validatePath(String path) { if (path != null && !path.startsWith("/")) { throw new IllegalArgumentException("Must start with a '/': " + path); } - - this.path = path; + return path; } /**