Files
floci/src/test/java
Allen Sanborn 1b89d5da39 fix(storage): skip keys deleted mid-iteration in StorageBackedMap views (#6017)
* fix(storage): skip keys deleted mid-iteration in StorageBackedMap views

The entry iterator walks a key snapshot and each entry's getValue() re-read
storage, so a key deleted after the snapshot made values()/entrySet() yield
null. Callers streaming values() (AutoScaling was patched per-site in #5751;
many other services do the same) then hit NullPointerExceptions.

Fix it once in the map: the iterator looks one element ahead and skips keys
whose value is gone, and entries carry the value read at iteration time.
Because size() is a separate snapshot, the entrySet/keySet/values views now
report unknown-size spliterators; a SIZED stream would otherwise throw
"End size N is less than fixed size M" when a key disappears mid-stream.

* test(storage): cover iterator remove after lookahead, exhaustion and entry setValue

* fix(storage): bind view spliterators lazily at first traversal

The view spliterators wrapped iterator() at spliterator() time, so the key
snapshot was taken when stream() was called rather than when the terminal
operation ran. Collection.spliterator()'s default, which these views used
before, is late-binding. Defer taking the iterator to the first tryAdvance
or split, still reporting unknown size.
2026-10-19 18:21:18 -04:00
..