[jira] [Work logged] (EAGLE-1096) getJSONArray may cause exception, optJSONArray should be used

2019-05-07 Thread ASF GitHub Bot (JIRA)


 [ 
https://issues.apache.org/jira/browse/EAGLE-1096?focusedWorklogId=238970=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-238970
 ]

ASF GitHub Bot logged work on EAGLE-1096:
-

Author: ASF GitHub Bot
Created on: 08/May/19 03:50
Start Date: 08/May/19 03:50
Worklog Time Spent: 10m 
  Work Description: qingwen220 commented on 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 resultMap = new HashMap();
 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:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 238970)
Time Spent: 0.5h  (was: 20m)

> 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: 0.5h
>  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)


[jira] [Work logged] (EAGLE-1096) getJSONArray may cause exception, optJSONArray should be used

2019-04-13 Thread ASF GitHub Bot (JIRA)


 [ 
https://issues.apache.org/jira/browse/EAGLE-1096?focusedWorklogId=227263=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-227263
 ]

ASF GitHub Bot logged work on EAGLE-1096:
-

Author: ASF GitHub Bot
Created on: 14/Apr/19 01:03
Start Date: 14/Apr/19 01:03
Worklog Time Spent: 10m 
  Work Description: bd2019us commented on pull request #1001: [EAGLE-1096] 
getJSONArray may cause exception, optJSONArray can be used
URL: https://github.com/apache/eagle/pull/1001
 
 
   
   
   Be sure to do all of the following to help us incorporate your contribution
   quickly and easily:
   
- [ ] Make sure the PR title is formatted like:
  `[EAGLE-] Description of pull request`
- [ ] Make sure tests pass via `mvn clean verify`. (Even better, enable
  Travis-CI on your fork and ensure the whole test matrix passes).
- [ ] Replace `` in the title with the actual Jira issue
  number, if there is one.
- [ ] If this contribution is large, please file an Apache
  [Individual Contributor License 
Agreement](https://www.apache.org/licenses/icla.txt).
   
   ---
 

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: 227263)
Time Spent: 10m
Remaining Estimate: 0h

> 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
>  Time Spent: 10m
>  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)