Adjust assertion check to not throw an NPE (#13479)

This commit is contained in:
Benjamin Trent 2024-06-11 09:48:21 -04:00 committed by GitHub
parent 51e60f49f8
commit cfdc747cde
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 4 deletions

View File

@ -736,10 +736,14 @@ public final class SortingCodecReader extends FilterCodecReader {
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