Skip to content

Commit

Permalink
优化代码:预防 NPE,减少重复执行逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
TommyLemon committed Jan 29, 2023
1 parent 6a5764d commit b973f3e
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions APIJSONORM/src/main/java/apijson/orm/AbstractObjectParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -249,17 +249,19 @@ public AbstractObjectParser parse(String name, boolean isReuse) throws Exception
break;
}

Object value = entry.getValue();
String key = entry == null ? null : entry.getKey();
Object value = key == null ? null : entry.getValue();
if (value == null) {
continue;
}
String key = entry.getKey();


// 处理url crud, 将crud 转换为真实method
RequestMethod _method = this.parser.getRealMethod(method, key, value);
// 没有执行校验流程的情况,比如url head, sql@子查询, sql@ method=GET
if (key.endsWith("@") && request.get(key) instanceof JSONObject) {
request.getJSONObject(key).put(apijson.JSONObject.KEY_METHOD, GET);
// 没有执行校验流程的情况,比如url head, sql@子查询, sql@ method=GET

Object obj = key.endsWith("@") ? request.get(key) : null;
if (obj instanceof JSONObject) {
((JSONObject) obj).put(apijson.JSONObject.KEY_METHOD, GET);
}

try {
Expand Down

0 comments on commit b973f3e

Please sign in to comment.