From 58a145fbba238b26551586afe074ae644916d78a Mon Sep 17 00:00:00 2001 From: Timothy Potter Date: Mon, 13 Oct 2014 15:35:35 +0000 Subject: [PATCH] SOLR-6511: fix back compat issue when reading existing data from ZK git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1631439 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/solr/cloud/ZkController.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/solr/core/src/java/org/apache/solr/cloud/ZkController.java b/solr/core/src/java/org/apache/solr/cloud/ZkController.java index abe054650f3..fe1e36906fd 100644 --- a/solr/core/src/java/org/apache/solr/cloud/ZkController.java +++ b/solr/core/src/java/org/apache/solr/cloud/ZkController.java @@ -1989,8 +1989,18 @@ public final class ZkController { } Map stateObj = null; - if (stateData != null && stateData.length > 0) - stateObj = (Map) ZkStateReader.fromJSON(stateData); + if (stateData != null && stateData.length > 0) { + Object parsedJson = ZkStateReader.fromJSON(stateData); + if (parsedJson instanceof Map) { + stateObj = (Map)parsedJson; + } else if (parsedJson instanceof String) { + // old format still in ZK + stateObj = new LinkedHashMap<>(); + stateObj.put("state", (String)parsedJson); + } else { + throw new SolrException(ErrorCode.SERVER_ERROR, "Leader-initiated recovery state data is invalid! "+parsedJson); + } + } return stateObj; }