[ https://issues.apache.org/jira/browse/EAGLE-1096?focusedWorklogId=227273&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-227273 ]
ASF GitHub Bot logged work on EAGLE-1096: ----------------------------------------- Author: ASF GitHub Bot Created on: 14/Apr/19 03:20 Start Date: 14/Apr/19 03:20 Worklog Time Spent: 10m Work Description: jhsenjaliya commented on pull request #1001: [EAGLE-1096] getJSONArray may cause exception, optJSONArray can be used URL: https://github.com/apache/eagle/pull/1001#discussion_r275139161 ########## 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: if jsonArray is going to be null, can u add that handling as well ? Thanks ---------------------------------------------------------------- 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: us...@infra.apache.org Issue Time Tracking ------------------- Worklog Id: (was: 227273) Time Spent: 20m (was: 10m) > getJSONArray may cause exception, optJSONArray should be used > ------------------------------------------------------------- > > Key: EAGLE-1096 > URL: https://issues.apache.org/jira/browse/EAGLE-1096 > Project: Eagle > Issue Type: Bug > Reporter: bd2019us > Priority: Major > Attachments: 1.patch > > Time Spent: 20m > Remaining Estimate: 0h > > Hello, > The method call jsonBeansObject.getJSONArray("beans") may throw > JSONException when the key does not exist, which will crash the program. To > ensure safety, optJSONArray is recommended to use, which will avoid the > exception in case no such key. -- This message was sent by Atlassian JIRA (v7.6.3#76005)