Skip to content

Commit 509aa7a

Browse files
committed
Fix standalone attach on Windows (#484)
1 parent 273f9bc commit 509aa7a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

spark-standalone-agent/src/main/java/me/lucko/spark/standalone/StandaloneSparkAgent.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@
2323
import com.sun.tools.attach.VirtualMachine;
2424
import com.sun.tools.attach.VirtualMachineDescriptor;
2525

26+
import java.io.File;
2627
import java.lang.instrument.Instrumentation;
28+
import java.net.URI;
29+
import java.nio.file.Files;
30+
import java.nio.file.Paths;
2731
import java.util.Arrays;
2832
import java.util.HashMap;
2933
import java.util.List;
@@ -51,9 +55,9 @@ public static void main(String[] args) {
5155

5256
try {
5357
VirtualMachine vm = VirtualMachine.attach(args[0]);
54-
String agentPath = StandaloneSparkAgent.class.getProtectionDomain().getCodeSource().getLocation().getPath();
58+
URI agentPath = StandaloneSparkAgent.class.getProtectionDomain().getCodeSource().getLocation().toURI();
5559
String arguments = String.join(",", Arrays.copyOfRange(args, 1, args.length));
56-
vm.loadAgent(agentPath, arguments);
60+
vm.loadAgent(Paths.get(agentPath).toAbsolutePath().toString(), arguments);
5761
System.out.println("[spark] Agent loaded successfully.");
5862
vm.detach();
5963
} catch (Throwable e) {

0 commit comments

Comments
 (0)