in src/main/java/com/intellij/rt/debugger/agent/DebuggerAgent.java [44:89]
private static void readAndApplyProperties(String args, Instrumentation instrumentation) {
Properties properties = new Properties();
if (args == null || args.isEmpty()) {
initAll(instrumentation, properties);
return;
}
// Parse "keep setting file" suffix: -javaagent:<path>/debugger-agent.jar=<uri-or-path-to-props>([keep])?
String path;
boolean keepSettings = false;
String argsTrimmed = args.trim();
if (argsTrimmed.endsWith(KEEP_SUFFIX)) {
path = argsTrimmed.substring(0, argsTrimmed.length() - KEEP_SUFFIX.length()).trim();
keepSettings = true;
} else {
path = argsTrimmed;
}
Path filePath = null;
try {
try {
filePath = Paths.get(new URI(path));
} catch (URISyntaxException ignored) {
filePath = Paths.get(path);
}
try (InputStream stream = Files.newInputStream(filePath)) {
// use ISO 8859-1 character encoding
properties.load(stream);
}
} catch (Exception e) {
System.out.println("Capture agent: unable to read settings");
e.printStackTrace();
}
initAll(instrumentation, properties);
// delete settings file only if it was read correctly
boolean keep = keepSettings || !Boolean.parseBoolean(properties.getProperty("deleteSettings", "true"));
if (!keep && filePath != null) {
try {
Files.deleteIfExists(filePath);
} catch (IOException e) {
System.out.println("Capture agent: could not delete settings file: " + filePath);
e.printStackTrace();
}
}
}