Skip to content

Commit

Permalink
Adjust assertion check to not throw an NPE (#13479)
Browse files Browse the repository at this point in the history
  • Loading branch information
benwtrent committed Jun 11, 2024
1 parent 3cce850 commit c6e604f
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -736,10 +736,14 @@ private boolean assertCreatedOnlyOnce(String field, boolean norms) {
if (timesCached > 1) {
assert norms == false : "[" + field + "] norms must not be cached twice";
boolean isSortField = false;
for (SortField sf : metaData.getSort().getSort()) {
if (field.equals(sf.getField())) {
isSortField = true;
break;
// For things that aren't sort fields, it's possible for sort to be null here
// In the event that we accidentally cache twice, its better not to throw an NPE
if (metaData.getSort() != null) {
for (SortField sf : metaData.getSort().getSort()) {
if (field.equals(sf.getField())) {
isSortField = true;
break;
}
}
}
assert timesCached == 2
Expand Down

0 comments on commit c6e604f

Please sign in to comment.