bugfix: fix bug when spaces in agent path. resolve #1219 (#2350)

* bugfix: fix bug when spaces in agent path. resolve #1219

* fix code style

* fix code style
This commit is contained in:
kezhenxu94 2019-03-14 16:06:13 +08:00 committed by 吴晟 Wu Sheng
parent 30e4089128
commit d5d46ae02a
1 changed files with 4 additions and 1 deletions

View File

@ -19,6 +19,7 @@
package org.apache.skywalking.apm.agent.core.boot;
import java.net.URISyntaxException;
import org.apache.skywalking.apm.agent.core.logging.api.ILog;
import org.apache.skywalking.apm.agent.core.logging.api.LogManager;
@ -61,9 +62,11 @@ public class AgentPackagePath {
urlString = urlString.substring(urlString.indexOf("file:"), insidePathIndex);
File agentJarFile = null;
try {
agentJarFile = new File(new URL(urlString).getFile());
agentJarFile = new File(new URL(urlString).toURI());
} catch (MalformedURLException e) {
logger.error(e, "Can not locate agent jar file by url:" + urlString);
} catch (URISyntaxException e) {
logger.error(e, "Can not locate agent jar file by url:" + urlString);
}
if (agentJarFile.exists()) {
return agentJarFile.getParentFile();