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) { if (timesCached > 1) {
assert norms == false : "[" + field + "] norms must not be cached twice"; assert norms == false : "[" + field + "] norms must not be cached twice";
boolean isSortField = false; boolean isSortField = false;
for (SortField sf : metaData.getSort().getSort()) { // For things that aren't sort fields, it's possible for sort to be null here
if (field.equals(sf.getField())) { // In the event that we accidentally cache twice, its better not to throw an NPE
isSortField = true; if (metaData.getSort() != null) {
break; for (SortField sf : metaData.getSort().getSort()) {
if (field.equals(sf.getField())) {
isSortField = true;
break;
}
} }
} }
assert timesCached == 2 assert timesCached == 2