Fix Broken Error Handling in CacheFile#acquire (#65342) (#65347)

If we fail to create the `FileChannelReference` (e.g. because the directory it should be created in
was deleted in a test) we have to remove the listener from the `listeners` set to not trip internal
consistency assertions.

Relates #65302 (does not fix it though, but reduces noise from failures by removing secondary
tripped assertions after the test fails)
This commit is contained in:
Armin Braun 2020-11-23 08:57:24 +01:00 committed by GitHub
parent 67b6317488
commit b0cea04f95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -138,12 +138,12 @@ public class CacheFile {
try {
synchronized (listeners) {
ensureOpen();
final boolean added = listeners.add(listener);
assert added : "listener already exists " + listener;
if (listeners.size() == 1) {
if (listeners.isEmpty()) {
assert channelRef == null;
channelRef = new FileChannelReference();
}
final boolean added = listeners.add(listener);
assert added : "listener already exists " + listener;
}
success = true;
} finally {