-
Bug
-
Resolution: Done
-
Major
-
7.0.2.Final
-
None
Hi,
i have some testing code that iterates through a cache and validates all data in this cache for consistency.
The reduced code is:
TransactionManager tm = cache.getAdvancedCache().getTransactionManager();
tm.begin();
try {
for (Entry<Object,Object> entry : metadataCache.entrySet())
} finally {
tm.commit();
}
In some circumstances the iteration starts returning the same Entry every time. I stepped into the code and the value is returned from:
https://github.com/infinispan/infinispan/blob/master/core/src/main/java/org/infinispan/iteration/impl/TransactionAwareCloseableIterator.java#L70
This code block is commented with:
"// We do a last check to make sure no additional values were added to our context while iterating"
And for me it seems that the value returned here never gets added to the "seenContextKeys" Set and so the iterator is always returning the same key.
Maybe a simple "seenContextKeys.add(lookedUpEntry.getKey())" next to Line 70 would fix this issue. Maybe even a 'break' could make sense here because is there the need to walk through the entire list if we have found a candidate?