Skip to content

Commit 0588a4c

Browse files
committed
GH-228 - empty --source-config argument resets source roots and source viewer
1 parent cb7e8c7 commit 0588a4c

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

plugins/sources/src/org/graalvm/visualvm/sources/arguments/SourceConfigArgument.java

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,23 @@ static void process(String[] values, String[] rootsValues, String[] viewerValues
5555

5656

5757
private static final void setValue(String value) throws CommandException {
58-
try (InputStreamReader isr = new InputStreamReader(new FileInputStream(value), "UTF-8")) { // NOI18N
59-
Properties props = new Properties();
60-
props.load(isr);
61-
62-
String sourceRoots = props.getProperty(SourceRootsArgument.LONG_NAME);
63-
if (sourceRoots != null) SourceRootsArgument.setValue(sourceRoots);
64-
65-
String sourceViewer = props.getProperty(SourceViewerArgument.LONG_NAME);
66-
if (sourceViewer != null) SourceViewerArgument.setValue(sourceViewer);
67-
} catch (IOException e) {
68-
throw new CommandException(0, "--" + LONG_NAME + " failed to read config " + value + ": " + e.getMessage()); // NOI18N
58+
if (value != null) value = value.trim();
59+
if (value == null || value.isEmpty()) {
60+
SourceRootsArgument.setValue(null);
61+
SourceViewerArgument.setValue(null);
62+
} else {
63+
try (InputStreamReader isr = new InputStreamReader(new FileInputStream(value), "UTF-8")) { // NOI18N
64+
Properties props = new Properties();
65+
props.load(isr);
66+
67+
String sourceRoots = props.getProperty(SourceRootsArgument.LONG_NAME);
68+
if (sourceRoots != null) SourceRootsArgument.setValue(sourceRoots);
69+
70+
String sourceViewer = props.getProperty(SourceViewerArgument.LONG_NAME);
71+
if (sourceViewer != null) SourceViewerArgument.setValue(sourceViewer);
72+
} catch (IOException e) {
73+
throw new CommandException(0, "--" + LONG_NAME + " failed to read config " + value + ": " + e.getMessage()); // NOI18N
74+
}
6975
}
7076
}
7177

0 commit comments

Comments
 (0)