From d9f09c472b32a5144de70bbf95618028624c68ea Mon Sep 17 00:00:00 2001 From: Ruslan Cheremin Date: Tue, 27 May 2025 16:40:32 +0200 Subject: [PATCH] IJPL-189248: fix deadlock - PersistentMapImpl.doContainsMapping() violated the constraint (stated in PersistentEnumeratorBase.myLock) that PersistentMapImpl.myLock must always be acquired _before_ storage lock GitOrigin-RevId: cc54be52d3043ce38c22c58b9688683906e4d567 --- .../intellij/util/io/PersistentMapImpl.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/platform/util/src/com/intellij/util/io/PersistentMapImpl.java b/platform/util/src/com/intellij/util/io/PersistentMapImpl.java index 233de80ecde0..a50d2be1b782 100644 --- a/platform/util/src/com/intellij/util/io/PersistentMapImpl.java +++ b/platform/util/src/com/intellij/util/io/PersistentMapImpl.java @@ -253,11 +253,11 @@ public final class PersistentMapImpl implements PersistentMapBase getKeyDescriptor(){ + public @NotNull KeyDescriptor getKeyDescriptor() { return myKeyDescriptor; } - public @NotNull PersistentMapBuilder builder(){ + public @NotNull PersistentMapBuilder builder() { //builder is mutable, so return a copy of it: return myBuilder.copy(); } @@ -720,22 +720,22 @@ public final class PersistentMapImpl implements PersistentMapBase)myEnumerator).getNonNegativeValue(key) != NULL_ADDR; - } - else { - final int id = myEnumerator.tryEnumerate(key); + if (myDirectlyStoreLongFileOffsetMode) { + return ((PersistentBTreeEnumerator)myEnumerator).getNonNegativeValue(key) != NULL_ADDR; + } + else { + myEnumerator.lockStorageRead(); + try { + int id = myEnumerator.tryEnumerate(key); if (id == DataEnumerator.NULL_ID) { return false; } if (myIntMapping) return true; return readValueId(id) != NULL_ADDR; } - } - finally { - myEnumerator.unlockStorageRead(); + finally { + myEnumerator.unlockStorageRead(); + } } }