From 3bbef1ea7f942ba651886c5123075c675c894952 Mon Sep 17 00:00:00 2001 From: Tanguy Leroux Date: Tue, 19 Oct 2021 13:28:40 +0200 Subject: [PATCH] rename --- .../searchablesnapshots/cache/common/CacheFile.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/x-pack/plugin/searchable-snapshots/src/main/java/org/elasticsearch/xpack/searchablesnapshots/cache/common/CacheFile.java b/x-pack/plugin/searchable-snapshots/src/main/java/org/elasticsearch/xpack/searchablesnapshots/cache/common/CacheFile.java index 3e6b719267f54..a827b8f3d610f 100644 --- a/x-pack/plugin/searchable-snapshots/src/main/java/org/elasticsearch/xpack/searchablesnapshots/cache/common/CacheFile.java +++ b/x-pack/plugin/searchable-snapshots/src/main/java/org/elasticsearch/xpack/searchablesnapshots/cache/common/CacheFile.java @@ -127,10 +127,9 @@ protected void closeInternal() { private volatile FileChannelReference channelRef; /** - * Indicates if the file should be created when it is open for the first time. - * This is required to pass the right options for sparse file support. + * {@code true} if the physical cache file exists on disk */ - private volatile boolean created; + private volatile boolean fileExists; public CacheFile(CacheKey cacheKey, long length, Path file, ModificationListener listener) { this(cacheKey, new SparseFileTracker(file.toString(), length), file, listener, false); @@ -146,7 +145,7 @@ private CacheFile(CacheKey cacheKey, SparseFileTracker tracker, Path file, Modif this.file = Objects.requireNonNull(file); this.listener = Objects.requireNonNull(listener); assert fileExists == Files.exists(file) : file + " exists? " + fileExists; - this.created = fileExists; + this.fileExists = fileExists; assert invariant(); } @@ -192,8 +191,8 @@ public void acquire(final EvictionListener listener) throws IOException { ensureOpen(); if (listeners.isEmpty()) { assert channelRef == null; - channelRef = new FileChannelReference(created ? OPEN_OPTIONS : CREATE_OPTIONS); - created = true; + channelRef = new FileChannelReference(fileExists ? OPEN_OPTIONS : CREATE_OPTIONS); + fileExists = true; } final boolean added = listeners.add(listener); assert added : "listener already exists " + listener;