Skip to content

Commit 5b6f44d

Browse files
Fix Broken Error Handling in CacheFile#acquire (#65342) (#65346)
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)
1 parent a757534 commit 5b6f44d

File tree

1 file changed

+3
-3
lines changed
  • x-pack/plugin/searchable-snapshots/src/main/java/org/elasticsearch/index/store/cache

1 file changed

+3
-3
lines changed

x-pack/plugin/searchable-snapshots/src/main/java/org/elasticsearch/index/store/cache/CacheFile.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,12 @@ public void acquire(final EvictionListener listener) throws IOException {
138138
try {
139139
synchronized (listeners) {
140140
ensureOpen();
141-
final boolean added = listeners.add(listener);
142-
assert added : "listener already exists " + listener;
143-
if (listeners.size() == 1) {
141+
if (listeners.isEmpty()) {
144142
assert channelRef == null;
145143
channelRef = new FileChannelReference();
146144
}
145+
final boolean added = listeners.add(listener);
146+
assert added : "listener already exists " + listener;
147147
}
148148
success = true;
149149
} finally {

0 commit comments

Comments
 (0)