Skip to content

Commit

Permalink
for compatible nacos server lower version, we should check the respon…
Browse files Browse the repository at this point in the history
…se from nacos server is null. (#8229)
  • Loading branch information
horizonzy committed Jul 11, 2021
1 parent 11e15f2 commit 34a4922
Showing 1 changed file with 9 additions and 1 deletion.
Expand Up @@ -260,7 +260,9 @@ public SortedSet<String> getConfigKeys(String group) {

HttpRestResult<String> result = httpAgent.httpGet(GET_CONFIG_KEYS_PATH, emptyMap(), paramsValues, encoding, 5 * 1000);
Stream<String> keysStream = toKeysStream(result.getData());
keysStream.forEach(keys::add);
if (keysStream != null) {
keysStream.forEach(keys::add);
}
} catch (Exception e) {
if (logger.isErrorEnabled()) {
logger.error(e.getMessage(), e);
Expand All @@ -284,7 +286,13 @@ public boolean removeConfig(String key, String group) {

private Stream<String> toKeysStream(String content) {
JSONObject jsonObject = JSON.parseObject(content);
if (jsonObject == null) {
return null;
}
JSONArray pageItems = jsonObject.getJSONArray("pageItems");
if (pageItems == null) {
return null;
}
return pageItems.stream()
.map(object -> (JSONObject) object)
.map(json -> json.getString("dataId"));
Expand Down

0 comments on commit 34a4922

Please sign in to comment.