don't trust the response from nacos server. (#8230)
This commit is contained in:
parent
7af0d771de
commit
01874fc4e5
|
|
@ -284,7 +284,9 @@ public class NacosDynamicConfiguration implements DynamicConfiguration {
|
|||
|
||||
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);
|
||||
|
|
@ -309,7 +311,13 @@ public class NacosDynamicConfiguration implements DynamicConfiguration {
|
|||
|
||||
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"));
|
||||
|
|
|
|||
Loading…
Reference in New Issue