Skip to content

Commit 5bb7eec

Browse files
committed
解决刚刚改动 result.remove("@RAW@LIST") 逻辑后新增的 NPE bug
1 parent 5525eab commit 5bb7eec

File tree

1 file changed

+22
-24
lines changed

1 file changed

+22
-24
lines changed

APIJSONORM/src/main/java/apijson/orm/AbstractObjectParser.java

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -897,38 +897,36 @@ public JSONObject onSQLExecute() throws Exception {
897897

898898
boolean isSimpleArray = false;
899899
// 提取并缓存数组主表的列表数据
900-
List<JSONObject> rawList = (List<JSONObject>) result.remove(AbstractSQLExecutor.KEY_RAW_LIST);
900+
List<JSONObject> rawList = result == null ? null : (List<JSONObject>) result.remove(AbstractSQLExecutor.KEY_RAW_LIST);
901901

902-
if (isArrayMainTable && position == 0 && result != null) {
902+
if (isArrayMainTable && position == 0 && rawList != null) {
903903

904-
isSimpleArray = (functionMap == null || functionMap.isEmpty())
905-
&& (customMap == null || customMap.isEmpty())
906-
&& (childMap == null || childMap.isEmpty())
907-
&& (table.equals(arrayTable));
904+
isSimpleArray = (functionMap == null || functionMap.isEmpty())
905+
&& (customMap == null || customMap.isEmpty())
906+
&& (childMap == null || childMap.isEmpty())
907+
&& (table.equals(arrayTable));
908908

909-
// APP JOIN 副表时副表返回了这个字段 rawList = (List<JSONObject>) result.remove(AbstractSQLExecutor.KEY_RAW_LIST);
910-
if (rawList != null) {
911-
String arrayPath = parentPath.substring(0, parentPath.lastIndexOf("[]") + 2);
909+
// APP JOIN 副表时副表返回了这个字段 rawList = (List<JSONObject>) result.remove(AbstractSQLExecutor.KEY_RAW_LIST);
910+
String arrayPath = parentPath.substring(0, parentPath.lastIndexOf("[]") + 2);
912911

913-
if (isSimpleArray == false) {
914-
long startTime = System.currentTimeMillis();
912+
if (isSimpleArray == false) {
913+
long startTime = System.currentTimeMillis();
915914

916-
for (int i = 1; i < rawList.size(); i++) { // 从 1 开始,0 已经处理过
917-
JSONObject obj = rawList.get(i);
915+
for (int i = 1; i < rawList.size(); i++) { // 从 1 开始,0 已经处理过
916+
JSONObject obj = rawList.get(i);
918917

919-
if (obj != null) {
920-
parser.putQueryResult(arrayPath + "/" + i + "/" + name, obj); // 解决获取关联数据时requestObject里不存在需要的关联数据
921-
}
922-
}
918+
if (obj != null) {
919+
parser.putQueryResult(arrayPath + "/" + i + "/" + name, obj); // 解决获取关联数据时requestObject里不存在需要的关联数据
920+
}
921+
}
923922

924-
long endTime = System.currentTimeMillis(); // 3ms - 8ms
925-
Log.e(TAG, "\n onSQLExecute <<<<<<<<<<<<<<<<<<<<<<<<<<<<\n for (int i = 1; i < list.size(); i++) startTime = " + startTime
926-
+ "; endTime = " + endTime + "; duration = " + (endTime - startTime) + "\n >>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n ");
927-
}
923+
long endTime = System.currentTimeMillis(); // 3ms - 8ms
924+
Log.e(TAG, "\n onSQLExecute <<<<<<<<<<<<<<<<<<<<<<<<<<<<\n for (int i = 1; i < list.size(); i++) startTime = " + startTime
925+
+ "; endTime = " + endTime + "; duration = " + (endTime - startTime) + "\n >>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n ");
926+
}
928927

929-
parser.putArrayMainCache(arrayPath, rawList);
930-
}
931-
}
928+
parser.putArrayMainCache(arrayPath, rawList);
929+
}
932930

933931
if (isSubquery == false && result != null) {
934932
parser.putQueryResult(path, result); // 解决获取关联数据时requestObject里不存在需要的关联数据

0 commit comments

Comments
 (0)