support windows unicode file path. #571

This commit is contained in:
gongdewei
2019-03-14 20:41:10 +08:00
committed by hengyunabc
parent 6f990a2cf3
commit 4641ec0e6d
3 changed files with 29 additions and 3 deletions
@@ -11,6 +11,8 @@ import com.taobao.middleware.cli.CommandLine;
import com.taobao.middleware.cli.Option;
import com.taobao.middleware.cli.TypedOption;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Arrays;
import java.util.Properties;
@@ -85,8 +87,12 @@ public class Arthas {
}
}
virtualMachine.loadAgent(configure.getArthasAgent(),
configure.getArthasCore() + ";" + configure.toString());
String arthasAgentPath = configure.getArthasAgent();
//convert jar path to unicode string
configure.setArthasAgent(encodeArg(arthasAgentPath));
configure.setArthasCore(encodeArg(configure.getArthasCore()));
virtualMachine.loadAgent(arthasAgentPath,
configure.getArthasCore() + ";" + configure.toString());
} finally {
if (null != virtualMachine) {
virtualMachine.detach();
@@ -94,6 +100,13 @@ public class Arthas {
}
}
private static String encodeArg(String arg) {
try {
return URLEncoder.encode(arg, "utf-8");
} catch (UnsupportedEncodingException e) {
return arg;
}
}
public static void main(String[] args) {
try {