Skip to content

Commit 181c3ad

Browse files
szybiauschindlerdweiss
authored
Fix WindowsFS onClose race condition (#15951)
* Fix WindowsFS onClose race condition * add changelog and fix styling --------- Co-authored-by: Uwe Schindler <uschindler@apache.org> Co-authored-by: Dawid Weiss <dawid.weiss@carrotsearch.com>
1 parent 294f5c4 commit 181c3ad

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

lucene/CHANGES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,8 @@ Other
378378

379379
* GITHUB#15891: Add the ability to pass DataAccessHints in Lucene104ScalarQuantizedVectorsReader (Navneet Verma)
380380

381+
* GITHUB#15951: Fix WindowsFS onClose race condition (Szymon Bialkowski)
382+
381383
======================= Lucene 10.4.0 =======================
382384

383385
API Changes

lucene/test-framework/src/java/org/apache/lucene/tests/mockfile/WindowsFS.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,12 @@ protected void onOpen(Path path, Object stream) throws IOException {
7474

7575
@Override
7676
protected void onClose(Path path, Object stream) throws IOException {
77-
Object key = getKey(path); // here we can read this outside of the lock
7877
synchronized (openFiles) {
78+
// we have to read the key under the lock; otherwise concurrent move might change the inode
79+
// of the path and therefore the key, meaning won't be able to find it in openFiles
80+
Object key = getKey(path);
7981
Map<Path, Integer> pathMap = openFiles.get(key);
80-
assert pathMap != null;
82+
assert pathMap != null : "no open file for key " + key + " on path " + path;
8183
assert pathMap.containsKey(path);
8284
Integer v = pathMap.get(path);
8385
if (v != null) {

0 commit comments

Comments
 (0)