Skip to content

Commit 606e8b1

Browse files
Fix Broken Error Handling in CacheFile#acquire (#65342)
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 509f1d1 commit 606e8b1

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
@@ -148,12 +148,12 @@ public void acquire(final EvictionListener listener) throws IOException {
148148
try {
149149
synchronized (listeners) {
150150
ensureOpen();
151-
final boolean added = listeners.add(listener);
152-
assert added : "listener already exists " + listener;
153-
if (listeners.size() == 1) {
151+
if (listeners.isEmpty()) {
154152
assert channelRef == null;
155153
channelRef = new FileChannelReference();
156154
}
155+
final boolean added = listeners.add(listener);
156+
assert added : "listener already exists " + listener;
157157
}
158158
success = true;
159159
} finally {

0 commit comments

Comments
 (0)