From e68cdb60364f89610d78b3aa1639abb04d40e4b4 Mon Sep 17 00:00:00 2001 From: Kate Botsman Date: Fri, 22 Mar 2024 14:52:18 +0100 Subject: [PATCH] RDCT-1200 Fix JetBrains Client doesn't report native crashes To find and report native crashes `PerformanceWatcherImpl` requires two files: `.pid` and `.appinfo` These files are stored in the system directory (`PathManager.getSystemPath()`). For JetBrainsClient we replace default system path (`JetBrains/IntelliJIdea[VERSION]`) with custom per process path (`JetBrains/JetBrainsClient[VERSION]/tmp/per_process_system_0`) This custom directory is cleaned up on every start therefore `.pid` and `.appinfo` files are also deleted and `PerformanceWatcherImpl` cannot send crash reports. To fix that, we now keep these files between client restarts. GitOrigin-RevId: 7c50445d07767cc3a12e36c5511778235e8142b6 --- .../startup/multiProcess/PerProcessPathCustomizer.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/platform/bootstrap/src/com/intellij/platform/ide/impl/startup/multiProcess/PerProcessPathCustomizer.java b/platform/bootstrap/src/com/intellij/platform/ide/impl/startup/multiProcess/PerProcessPathCustomizer.java index 034261683cdd..0ecd8bb2c2e9 100644 --- a/platform/bootstrap/src/com/intellij/platform/ide/impl/startup/multiProcess/PerProcessPathCustomizer.java +++ b/platform/bootstrap/src/com/intellij/platform/ide/impl/startup/multiProcess/PerProcessPathCustomizer.java @@ -5,6 +5,7 @@ import com.intellij.openapi.application.PathCustomizer; import com.intellij.openapi.application.PathManager; import com.intellij.openapi.project.impl.P3SupportInstaller; import com.intellij.openapi.util.io.NioFiles; +import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -15,6 +16,7 @@ import java.nio.channels.FileLock; import java.nio.file.*; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; +import java.util.Set; import static com.intellij.idea.Main.customTargetDirectoryToImportConfig; import static com.intellij.idea.Main.isConfigImportNeeded; @@ -30,6 +32,12 @@ import static com.intellij.idea.Main.isConfigImportNeeded; public final class PerProcessPathCustomizer implements PathCustomizer { private static final String LOCK_FILE_NAME = "process.lock"; + private static final Set FILES_TO_KEEP = ContainerUtil.newHashSet( + LOCK_FILE_NAME, + ".pid", // Required by PerformanceWatcherImpl to report native crashes + ".appinfo" // Required by PerformanceWatcherImpl to report native crashes + ); + // Leave the folder locked until we exit. Store reference to keep CleanerFactory from releasing the file channel. @SuppressWarnings("unused") private static FileLock ourConfigLock; private static volatile boolean enabled; @@ -141,7 +149,7 @@ public final class PerProcessPathCustomizer implements PathCustomizer { private static void cleanDirectory(@NotNull Path directory) { try (DirectoryStream stream = Files.newDirectoryStream(directory)) { stream.forEach(path -> { - if (!path.getFileName().toString().equals(LOCK_FILE_NAME)) { + if (!FILES_TO_KEEP.contains(path.getFileName().toString())) { try { NioFiles.deleteRecursively(path); }