Skip to content

Commit

Permalink
fix: Move ratio calculation for whether to use read API to avoid NPE …
Browse files Browse the repository at this point in the history
…with setUseReadAPI(false)

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 88f6910
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 88f6910

Please sign in to comment.