Skip to content

Commit

Permalink
✨ feat(QueryHelper.java): Add null check for objectMap to prevent…
Browse files Browse the repository at this point in the history
… NPE.
  • Loading branch information
vnobo committed Dec 19, 2024
1 parent 639f2ae commit 660e006
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,8 @@ public static QueryFragment query(Object object, Pageable pageable, String prefi
*/
public static QueryFragment query(Object object, Pageable pageable, Collection<String> skipKeys, String prefix) {
Map<String, Object> objectMap = BeanUtils.beanToMap(object, false, true);
Map<String, Object> filterMap = Maps.filterKeys(objectMap, key -> !SKIP_CRITERIA_KEYS.contains(key) && !skipKeys.contains(key));
Map<String, Object> filterMap = ObjectUtils.isEmpty(objectMap) ? Map.of() :
Maps.filterKeys(objectMap, key -> !SKIP_CRITERIA_KEYS.contains(key) && !skipKeys.contains(key));

QueryFragment queryFragment = QueryFragment.withMap(pageable.getPageSize(), pageable.getOffset(), filterMap);
applySort(queryFragment, pageable.getSort(), prefix);
Expand All @@ -225,7 +226,6 @@ public static QueryFragment query(Object object, Pageable pageable, Collection<S
processSecurityCodeKey(queryFragment, objectMap, skipKeys, prefix);
processSearchKey(queryFragment, objectMap, prefix);
}

return queryFragment;
}

Expand Down

0 comments on commit 660e006

Please sign in to comment.