diff --git a/platform/core-nio-fs/src/com/intellij/platform/core/nio/fs/BasicFileAttributesHolder2.java b/platform/core-nio-fs/src/com/intellij/platform/core/nio/fs/BasicFileAttributesHolder2.java index e97ed8628668..58f472d8731e 100644 --- a/platform/core-nio-fs/src/com/intellij/platform/core/nio/fs/BasicFileAttributesHolder2.java +++ b/platform/core-nio-fs/src/com/intellij/platform/core/nio/fs/BasicFileAttributesHolder2.java @@ -39,7 +39,11 @@ public interface BasicFileAttributesHolder2 extends BasicFileAttributesHolder { * however strange the original works, this implementation should work the same. *

*/ - protected volatile @NotNull WeakReference<@Nullable BasicFileAttributes> myCachedAttributes = new WeakReference<>(null); + protected final @NotNull WeakReference<@Nullable BasicFileAttributes> myCachedAttributes; + + protected Impl(@Nullable BasicFileAttributes attributes) { + myCachedAttributes = new WeakReference<>(attributes); + } @Override public BasicFileAttributes get() { diff --git a/platform/ijent/impl/src/com/intellij/platform/ijent/community/impl/nio/IjentNioPath.kt b/platform/ijent/impl/src/com/intellij/platform/ijent/community/impl/nio/IjentNioPath.kt index ac0d277cd8d8..e4dc970faa32 100644 --- a/platform/ijent/impl/src/com/intellij/platform/ijent/community/impl/nio/IjentNioPath.kt +++ b/platform/ijent/impl/src/com/intellij/platform/ijent/community/impl/nio/IjentNioPath.kt @@ -21,17 +21,13 @@ class IjentNioPath internal constructor( val ijentPath: IjentPath, internal val nioFs: IjentNioFileSystem, cachedAttributes: BasicFileAttributes?, -) : Path, BasicFileAttributesHolder2.Impl() { +) : Path, BasicFileAttributesHolder2.Impl(cachedAttributes) { private val isWindows get() = when (nioFs.ijentFs) { is IjentFileSystemPosixApi -> false is IjentFileSystemWindowsApi -> true } - init { - myCachedAttributes = WeakReference(cachedAttributes) - } - override fun getFileSystem(): IjentNioFileSystem = nioFs override fun isAbsolute(): Boolean = diff --git a/platform/platform-impl/src/com/intellij/execution/wsl/ijent/nio/IjentWslNioPath.kt b/platform/platform-impl/src/com/intellij/execution/wsl/ijent/nio/IjentWslNioPath.kt index faa31e6c03a3..9df98256a12c 100644 --- a/platform/platform-impl/src/com/intellij/execution/wsl/ijent/nio/IjentWslNioPath.kt +++ b/platform/platform-impl/src/com/intellij/execution/wsl/ijent/nio/IjentWslNioPath.kt @@ -2,23 +2,14 @@ package com.intellij.execution.wsl.ijent.nio import com.intellij.platform.core.nio.fs.BasicFileAttributesHolder2 -import java.lang.ref.WeakReference import java.net.URI -import java.nio.file.LinkOption -import java.nio.file.Path -import java.nio.file.WatchEvent -import java.nio.file.WatchKey -import java.nio.file.WatchService +import java.nio.file.* class IjentWslNioPath( private val fileSystem: IjentWslNioFileSystem, val delegate: Path, cachedAttributes: IjentNioPosixFileAttributesWithDosAdapter?, -) : Path, BasicFileAttributesHolder2.Impl() { - init { - myCachedAttributes = WeakReference(cachedAttributes) - } - +) : Path, BasicFileAttributesHolder2.Impl(cachedAttributes) { override fun getFileSystem(): IjentWslNioFileSystem = fileSystem override fun isAbsolute(): Boolean = delegate.isAbsolute