Fix exception in bean json parser

This commit is contained in:
aboyko
2024-09-11 10:46:31 -04:00
parent dc577efc87
commit 30abaec4d6

View File

@@ -83,7 +83,7 @@ public class LiveBeansJsonParser {
// construct LiveBeans // construct LiveBeans
for (int i = 0; i < beansArray.length(); i++) { for (int i = 0; i < beansArray.length(); i++) {
JSONObject beanJson = beansArray.getJSONObject(i); JSONObject beanJson = beansArray.getJSONObject(i);
if (beanJson != null && beanJson.has(LiveBean.ATTR_BEAN)) { if (beanJson != null && beanJson.has(LiveBean.ATTR_BEAN) && !beanJson.isNull(LiveBean.ATTR_BEAN)) {
LiveBean bean = parseBean(beanJson, context); LiveBean bean = parseBean(beanJson, context);
bean.addAttribute(LiveBeansContext.ATTR_CONTEXT, context.getLabel()); bean.addAttribute(LiveBeansContext.ATTR_CONTEXT, context.getLabel());
context.addElement(bean); context.addElement(bean);
@@ -94,13 +94,13 @@ public class LiveBeansJsonParser {
protected LiveBean parseBean(JSONObject beanJson, LiveBeansContext context) throws JSONException { protected LiveBean parseBean(JSONObject beanJson, LiveBeansContext context) throws JSONException {
LiveBean bean = new LiveBean(typeLookup, beanJson.getString(LiveBean.ATTR_BEAN)); LiveBean bean = new LiveBean(typeLookup, beanJson.getString(LiveBean.ATTR_BEAN));
if (beanJson.has(LiveBean.ATTR_SCOPE)) { if (beanJson.has(LiveBean.ATTR_SCOPE) && !beanJson.isNull(LiveBean.ATTR_SCOPE)) {
bean.addAttribute(LiveBean.ATTR_SCOPE, beanJson.getString(LiveBean.ATTR_SCOPE)); bean.addAttribute(LiveBean.ATTR_SCOPE, beanJson.getString(LiveBean.ATTR_SCOPE));
} }
if (beanJson.has(LiveBean.ATTR_TYPE)) { if (beanJson.has(LiveBean.ATTR_TYPE) && !beanJson.isNull(LiveBean.ATTR_TYPE)) {
bean.addAttribute(LiveBean.ATTR_TYPE, beanJson.getString(LiveBean.ATTR_TYPE)); bean.addAttribute(LiveBean.ATTR_TYPE, beanJson.getString(LiveBean.ATTR_TYPE));
} }
if (beanJson.has(LiveBean.ATTR_RESOURCE)) { if (beanJson.has(LiveBean.ATTR_RESOURCE) && !beanJson.isNull(LiveBean.ATTR_RESOURCE)) {
bean.addAttribute(LiveBean.ATTR_RESOURCE, beanJson.getString(LiveBean.ATTR_RESOURCE)); bean.addAttribute(LiveBean.ATTR_RESOURCE, beanJson.getString(LiveBean.ATTR_RESOURCE));
} }
if (typeLookup != null && typeLookup.getApplicationName() != null) { if (typeLookup != null && typeLookup.getApplicationName() != null) {
@@ -149,7 +149,7 @@ public class LiveBeansJsonParser {
// populate LiveBean dependencies // populate LiveBean dependencies
for (int i = 0; i < beansArray.length(); i++) { for (int i = 0; i < beansArray.length(); i++) {
JSONObject beanJson = beansArray.optJSONObject(i); JSONObject beanJson = beansArray.optJSONObject(i);
if (beanJson != null && beanJson.has(LiveBean.ATTR_BEAN)) { if (beanJson != null && beanJson.has(LiveBean.ATTR_BEAN) && !beanJson.isNull(LiveBean.ATTR_BEAN)) {
LiveBean bean = beansMap.get(beanJson.getString(LiveBean.ATTR_BEAN)); LiveBean bean = beansMap.get(beanJson.getString(LiveBean.ATTR_BEAN));
JSONArray dependencies = beanJson.optJSONArray(LiveBean.ATTR_DEPENDENCIES); JSONArray dependencies = beanJson.optJSONArray(LiveBean.ATTR_DEPENDENCIES);
if (dependencies != null) { if (dependencies != null) {