Skip to content

Commit

Permalink
Modified getLogString with more NULL Safety
Browse files Browse the repository at this point in the history
The old implementation causes a NPE if the `session` or the `project` is null in line 1102.  This new implementation of will not.

The session being NULL is plausible, because the `appendLogParameters` function, which is called in line 1111, starts with a NULL check.
  • Loading branch information
rostup authored and lukasj committed Feb 22, 2022
1 parent b83b67c commit c069f46
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1099,7 +1099,7 @@ public String getLogString(Accessor accessor) {
session = getQuery().getSession();
}
List<String> procedureArgs = getProcedureArgumentNames();
boolean indexBased = procedureArgs.size() == 0 || procedureArgs.get(0) == null || session.getProject().namingIntoIndexed();
boolean indexBased = isIndexBased(procedureArgs, session);
Collection<String> parameters = new ArrayList<>();
for (int index = 0; index < getParameters().size(); index++) {
if (indexBased) {
Expand All @@ -1115,4 +1115,13 @@ public String getLogString(Accessor accessor) {
return getSQLString();
}
}

private boolean isIndexBased(List<String> procedureArgs, AbstractSession session) {
boolean hasNoArgs = procedureArgs.size() == 0 || procedureArgs.get(0) == null;
boolean isNamingIntoIndexed = false;
if (session != null && session.getProject() != null) {
isNamingIntoIndexed = session.getProject().namingIntoIndexed();
}
return hasNoArgs || isNamingIntoIndexed;
}
}

0 comments on commit c069f46

Please sign in to comment.