Skip to content

Commit 7edd529

Browse files
authored
Fix main_class displaying extra arguments on Arthas startup (#3150)
1 parent 8ef722e commit 7edd529

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

common/src/main/java/com/taobao/arthas/common/PidUtils.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ public class PidUtils {
2828
}
2929

3030
try {
31-
MAIN_CLASS = System.getProperty("sun.java.command", "");
31+
String command = System.getProperty("sun.java.command", "");
32+
// sun.java.command contains the main class name followed by its arguments,
33+
// so only take the first token as the main class name
34+
int spaceIndex = command.indexOf(' ');
35+
MAIN_CLASS = spaceIndex != -1 ? command.substring(0, spaceIndex) : command;
3236
} catch (Throwable e) {
3337
// ignore
3438
}

0 commit comments

Comments
 (0)