You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by th...@apache.org on 2021/02/14 16:00:43 UTC
[lucene-solr] branch branch_8x updated: SOLR-15145: Restore
base_url if node_name is set
This is an automated email from the ASF dual-hosted git repository.
thelabdude pushed a commit to branch branch_8x
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
The following commit(s) were added to refs/heads/branch_8x by this push:
new a5087d9 SOLR-15145: Restore base_url if node_name is set
a5087d9 is described below
commit a5087d9ab03c6ea9eb3f21c81eb869fd9fd22c84
Author: Timothy Potter <th...@gmail.com>
AuthorDate: Sat Feb 13 19:33:28 2021 -0700
SOLR-15145: Restore base_url if node_name is set
---
.../src/java/org/apache/solr/common/cloud/ZkNodeProps.java | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/ZkNodeProps.java b/solr/solrj/src/java/org/apache/solr/common/cloud/ZkNodeProps.java
index 47ab034..b206c8d 100644
--- a/solr/solrj/src/java/org/apache/solr/common/cloud/ZkNodeProps.java
+++ b/solr/solrj/src/java/org/apache/solr/common/cloud/ZkNodeProps.java
@@ -40,7 +40,7 @@ public class ZkNodeProps implements JSONWriter.Writable {
* Installations that use an older (pre-8.8) SolrJ against a 8.8.0 or newer server will need to set this system
* property to true to avoid NPEs when reading cluster state from Zookeeper, see SOLR-15145.
*/
- static final boolean STORE_BASE_URL = Boolean.parseBoolean(System.getProperty("solr.storeBaseUrl", "true"));
+ public static final boolean STORE_BASE_URL = Boolean.parseBoolean(System.getProperty("solr.storeBaseUrl", "true"));
protected final Map<String,Object> propMap;
@@ -125,10 +125,15 @@ public class ZkNodeProps implements JSONWriter.Writable {
@Override
public void write(JSONWriter jsonWriter) {
// don't write out the base_url if we have a node_name
- if (!STORE_BASE_URL && propMap.containsKey(ZkStateReader.BASE_URL_PROP) && propMap.containsKey(ZkStateReader.NODE_NAME_PROP)) {
- final Map<String,Object> filtered = new HashMap<>(propMap);
+ if (!STORE_BASE_URL && propMap.containsKey(ZkStateReader.BASE_URL_PROP) && propMap.get(ZkStateReader.NODE_NAME_PROP) != null) {
+ final Map<String, Object> filtered = new HashMap<>(propMap);
filtered.remove(ZkStateReader.BASE_URL_PROP);
jsonWriter.write(filtered);
+ } else if (STORE_BASE_URL && propMap.get(ZkStateReader.BASE_URL_PROP) == null && propMap.get(ZkStateReader.NODE_NAME_PROP) != null) {
+ // this is for back-compat with older SolrJ
+ final Map<String, Object> addBaseUrl = new HashMap<>(propMap);
+ addBaseUrl.put(ZkStateReader.BASE_URL_PROP, UrlScheme.INSTANCE.getBaseUrlForNodeName((String)propMap.get(ZkStateReader.NODE_NAME_PROP)));
+ jsonWriter.write(addBaseUrl);
} else {
jsonWriter.write(propMap);
}