Skip to content

Commit a8ffa25

Browse files
committed
Split this method into two sub-methods
1 parent e4f5760 commit a8ffa25

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

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

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,10 +364,20 @@ public String toString() {
364364
}
365365

366366
/**
367-
* This method verifies that the two internal data structures ({@link #bitsetCache} and {@link #keysByIndex}) are consistent with one
368-
* another. This method is only called by tests.
367+
* This test-only method verifies that the two internal data structures ({@link #bitsetCache} and {@link #keysByIndex}) are consistent
368+
* with one another.
369369
*/
370+
// visible for testing
370371
void verifyInternalConsistency() {
372+
verifyInternalConsistencyCacheToKeys();
373+
verifyInternalConsistencyKeysToCache();
374+
}
375+
376+
/**
377+
* This test-only method iterates over the {@link #bitsetCache} and checks that {@link #keysByIndex} is consistent with it.
378+
*/
379+
// visible for testing
380+
void verifyInternalConsistencyCacheToKeys() {
371381
bitsetCache.keys().forEach(cacheKey -> {
372382
final Set<BitsetCacheKey> keys = keysByIndex.get(cacheKey.indexKey);
373383
if (keys == null || keys.contains(cacheKey) == false) {
@@ -376,6 +386,13 @@ void verifyInternalConsistency() {
376386
);
377387
}
378388
});
389+
}
390+
391+
/**
392+
* This test-only method iterates over the {@link #keysByIndex} and checks that {@link #bitsetCache} is consistent with it.
393+
*/
394+
// visible for testing
395+
void verifyInternalConsistencyKeysToCache() {
379396
keysByIndex.forEach((indexKey, keys) -> {
380397
if (keys == null || keys.isEmpty()) {
381398
throw new IllegalStateException("The lookup entry for [" + indexKey + "] is null or empty");

0 commit comments

Comments
 (0)