Skip to content

Commit

Permalink
Move ratio calcation of read API to avoid NPE with useReadAPI(false)
Browse files Browse the repository at this point in the history
If a query takes longer than 10+ seconds, the returned job will not have results / totalRows
thus totalRows will be null,
However, if useReadAPI is false the moved line would throw a null pointer exception trying to unbox
the (nullable -- and actually null) Long for division.
  • Loading branch information
jonathanswenson committed Feb 3, 2023
1 parent 6b7c0a9 commit 8e11d07
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1217,8 +1217,8 @@ boolean useReadAPI(Long totalRows, Long pageRows, Schema schema, Boolean hasQuer
return false;
}

long resultRatio = totalRows / pageRows;
if (Boolean.TRUE.equals(connectionSettings.getUseReadAPI())) {
long resultRatio = totalRows / pageRows;
return resultRatio >= connectionSettings.getTotalToPageRowCountRatio()
&& totalRows > connectionSettings.getMinResultSize();
} else {
Expand Down

0 comments on commit 8e11d07

Please sign in to comment.