[runtargets] IJPL-148234: Starting new java local run/debug configuration takes too much time

GitOrigin-RevId: d0d639522cf440bf5053775a47e35b45b0218962
This commit is contained in:
Andrii Zinchenko
2024-04-15 14:36:57 +02:00
committed by intellij-monorepo-bot
parent 4de3d2c1f1
commit d15820380f

View File

@@ -12,8 +12,8 @@ import com.intellij.openapi.util.io.FileUtil;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.LinkOption;
import java.nio.file.Path;
import java.nio.file.Paths;
@@ -124,7 +124,7 @@ public class LocalTargetEnvironment extends TargetEnvironment {
@NotNull
@Override
public Process createProcess(@NotNull TargetedCommandLine commandLine, @NotNull ProgressIndicator indicator) throws ExecutionException {
public Process createProcess(@NotNull TargetedCommandLine commandLine, @NotNull ProgressIndicator indicator) throws ExecutionException {
return createGeneralCommandLine(commandLine).createProcess();
}
@@ -175,15 +175,32 @@ public class LocalTargetEnvironment extends TargetEnvironment {
myLocalRoot = localRoot;
myTargetRoot = targetRoot;
// Checking for local root existence is a workaround for tests like JavaCommandLineTest that check paths of imaginary files.
boolean real;
myReal = isReal(localRoot, targetRoot);
}
private static boolean isReal(Path localRoot, Path targetRoot) {
if (localRoot.equals(targetRoot)) {
return false;
}
Path realLocalRoot;
try {
real = Files.exists(localRoot) &&
!myLocalRoot.toRealPath(LinkOption.NOFOLLOW_LINKS).equals(myTargetRoot.toRealPath(LinkOption.NOFOLLOW_LINKS));
realLocalRoot = localRoot.toRealPath(LinkOption.NOFOLLOW_LINKS);
}
catch (FileNotFoundException e) {
return false;
}
catch (IOException e) {
real = true;
return true;
}
try {
return !realLocalRoot.equals(targetRoot.toRealPath(LinkOption.NOFOLLOW_LINKS));
}
catch (IOException e) {
return true;
}
myReal = real;
}
@NotNull