qingwen220 commented on a change in pull request #1001: [EAGLE-1096]
getJSONArray may cause exception, optJSONArray can be used
URL: https://github.com/apache/eagle/pull/1001#discussion_r281904704
##########
File path:
eagle-topology-check/eagle-topology-app/src/main/java/org/apache/eagle/topology/utils/JMXQueryHelper.java
##########
@@ -56,7 +56,7 @@
final Map<String, JMXBean> resultMap = new HashMap<String, JMXBean>();
final JSONTokener tokener = new JSONTokener(is);
final JSONObject jsonBeansObject = new JSONObject(tokener);
- final JSONArray jsonArray = jsonBeansObject.getJSONArray("beans");
+ final JSONArray jsonArray = jsonBeansObject.optJSONArray("beans");
int size = jsonArray.length();
Review comment:
Agree with @jhsenjaliya, this change will incur the NPE issue.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services