Apache Lucene open-source search software
Fix WindowsFS onClose race condition (#15951)
Szymon Bialkowski181c3ad8dca2
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txtindex 56e68616a12..648b7876f30 100644--- a/lucene/CHANGES.txt+++ b/lucene/CHANGES.txt@@ -378,6 +378,8 @@ Other* GITHUB#15891: Add the ability to pass DataAccessHints in Lucene104ScalarQuantizedVectorsReader (Navneet Verma)+* GITHUB#15951: Fix WindowsFS onClose race condition (Szymon Bialkowski)+======================= Lucene 10.4.0 =======================API Changesdiff --git a/lucene/test-framework/src/java/org/apache/lucene/tests/mockfile/WindowsFS.java b/lucene/test-framework/src/java/org/apache/lucene/tests/mockfile/WindowsFS.javaindex d1fcfb46918..d896e7b89b1 100644--- a/lucene/test-framework/src/java/org/apache/lucene/tests/mockfile/WindowsFS.java+++ b/lucene/test-framework/src/java/org/apache/lucene/tests/mockfile/WindowsFS.java@@ -74,10 +74,12 @@ public class WindowsFS extends HandleTrackingFS {@Overrideprotected void onClose(Path path, Object stream) throws IOException {- Object key = getKey(path); // here we can read this outside of the locksynchronized (openFiles) {+ // we have to read the key under the lock; otherwise concurrent move might change the inode+ // of the path and therefore the key, meaning won't be able to find it in openFiles+ Object key = getKey(path);Map<Path, Integer> pathMap = openFiles.get(key);- assert pathMap != null;+ assert pathMap != null : "no open file for key " + key + " on path " + path;assert pathMap.containsKey(path);Integer v = pathMap.get(path);if (v != null) {