Skip to content

Commit 83682ea

Browse files
committed
Collapse these checks into a single loop
1 parent 6df93e1 commit 83682ea

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/accesscontrol/DocumentSubsetBitsetCache.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -426,14 +426,15 @@ void verifyInternalConsistency() {
426426
);
427427
}
428428
});
429-
keysByIndex.values().stream().flatMap(Set::stream).forEach(cacheKey -> {
430-
if (bitsetCache.get(cacheKey) == null) {
431-
throw new IllegalStateException("Key [" + cacheKey + "] is in the lookup map, but is not in the cache");
432-
}
433-
});
434429
keysByIndex.forEach((indexKey, keys) -> {
435430
if (keys == null || keys.isEmpty()) {
436431
throw new IllegalStateException("The lookup entry for [" + indexKey + "] is null or empty");
432+
} else {
433+
keys.forEach(cacheKey -> {
434+
if (bitsetCache.get(cacheKey) == null) {
435+
throw new IllegalStateException("Key [" + cacheKey + "] is in the lookup map, but is not in the cache");
436+
}
437+
});
437438
}
438439
});
439440
}

0 commit comments

Comments
 (0)