Skip to content

Commit

Permalink
fix: Avoid null exception in removeSubquery (#147)
Browse files Browse the repository at this point in the history
In `CometScalarSubquery.removeSubquery`, we should make sure the `planId` is still in `subqueryMap` before we go to delete subquery from it. Otherwise, null exception could be thrown.
  • Loading branch information
viirya authored Mar 1, 2024
1 parent 9aa42cd commit 5905151
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,12 @@ public static synchronized void setSubquery(long planId, ScalarSubquery subquery
}

public static synchronized void removeSubquery(long planId, ScalarSubquery subquery) {
subqueryMap.get(planId).remove(subquery.exprId().id());
if (subqueryMap.containsKey(planId)) {
subqueryMap.get(planId).remove(subquery.exprId().id());

if (subqueryMap.get(planId).isEmpty()) {
subqueryMap.remove(planId);
if (subqueryMap.get(planId).isEmpty()) {
subqueryMap.remove(planId);
}
}
}

Expand Down

0 comments on commit 5905151

Please sign in to comment.