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
This commit is contained in:
Timothy Potter 2014-10-13 15:35:35 +00:00
parent 1fb3769a89
commit 58a145fbba
1 changed files with 12 additions and 2 deletions

View File

@ -1989,8 +1989,18 @@ public final class ZkController {
}
Map<String,Object> stateObj = null;
if (stateData != null && stateData.length > 0)
stateObj = (Map<String, Object>) ZkStateReader.fromJSON(stateData);
if (stateData != null && stateData.length > 0) {
Object parsedJson = ZkStateReader.fromJSON(stateData);
if (parsedJson instanceof Map) {
stateObj = (Map<String,Object>)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;
}