Avoid NPE in autoconfig report parsing

This commit is contained in:
Kris De Volder
2018-02-19 14:59:53 -08:00
parent 00b38a8ecf
commit 00cdf0aa50

View File

@@ -44,12 +44,12 @@ public class LiveConditionalParser {
public Optional<List<LiveConditional>> parse() {
try {
List<LiveConditional> allConditionals = new ArrayList<>();
JSONObject autoConfigReport = new JSONObject(autoConfigRecord);
if (autoConfigReport.has("contexts")) {
//more recently the report is nested inside the 'application' context.
autoConfigReport = autoConfigReport.getJSONObject("contexts").getJSONObject("application");
}
if (StringUtil.hasText(autoConfigRecord)) {
JSONObject autoConfigReport = new JSONObject(autoConfigRecord);
if (autoConfigReport.has("contexts")) {
//more recently the report is nested inside the 'application' context.
autoConfigReport = autoConfigReport.getJSONObject("contexts").getJSONObject("application");
}
for (LiveConditional c : getConditionalsFromPositiveMatches(autoConfigReport)) {
allConditionals.add(c);
}