SOLR-15145: Additional fix for SolrJ back-compat (#2366)

This commit is contained in:
Timothy Potter 2021-02-14 10:19:20 -07:00 committed by GitHub
parent 99f011a06e
commit 97763ad3ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 2 deletions

View File

@ -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);
}