From 4c7e2a21dc9a069f01835df452392e2ef4c516b3 Mon Sep 17 00:00:00 2001 From: Nikolay Chashnikov Date: Fri, 31 Oct 2025 11:58:20 +0100 Subject: [PATCH] [wsl] logging: add trace-level logging to find out which code accesses WSL (IJPL-214732) This is needed to find problematic code which should be disabled if access to WSL is restricted. (cherry picked from commit cf6f60541d8d1cd6604c0a015d21332b7e326e97) IJ-MR-180846 GitOrigin-RevId: c8490a5d1782d2d3ea356fab0c25079c2353b151 --- .../src/com/intellij/execution/wsl/WSLDistribution.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/platform/platform-impl/src/com/intellij/execution/wsl/WSLDistribution.java b/platform/platform-impl/src/com/intellij/execution/wsl/WSLDistribution.java index 4dfaab72bded..62f64dca7058 100644 --- a/platform/platform-impl/src/com/intellij/execution/wsl/WSLDistribution.java +++ b/platform/platform-impl/src/com/intellij/execution/wsl/WSLDistribution.java @@ -42,6 +42,7 @@ import java.nio.charset.StandardCharsets; import java.nio.file.InvalidPathException; import java.nio.file.Path; import java.util.*; +import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Function; import java.util.function.Supplier; import java.util.regex.Pattern; @@ -431,10 +432,15 @@ public class WSLDistribution implements AbstractWslDistribution { testOverriddenWslExe = path; } + private static final AtomicBoolean isAttemptToFindWslExeLogged = new AtomicBoolean(false); + public static @Nullable Path findWslExe() { if (testOverriddenWslExe != null) return testOverriddenWslExe; File file = PathEnvironmentVariableUtil.findInPath(WSL_EXE); + if (LOG.isTraceEnabled() && isAttemptToFindWslExeLogged.compareAndSet(false, true)) { + LOG.trace(new Throwable("findWslExe called")); + } return file != null ? file.toPath() : null; }