Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions core/launcher/src/main/java/org/phoebus/product/Launcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
// Handle arguments, potentially not even starting the UI
final Iterator<String> iter = args.iterator();
int port = -1;
boolean forceStart = false;
try {
while (iter.hasNext()) {
final String cmd = iter.next();
Expand All @@ -132,6 +133,9 @@
final String filename = iter.next();
iter.remove();
LogManager.getLogManager().readConfiguration(new FileInputStream(filename));
} else if (cmd.equals("-force_start")) {
iter.remove();
forceStart = true;
} else if (cmd.equals("-settings")) {
if (!iter.hasNext())
throw new Exception("Missing -settings file name");
Expand All @@ -140,10 +144,18 @@
iter.remove();

logger.info("Loading settings from " + location);
if (location.endsWith(".xml"))
Preferences.importPreferences(new FileInputStream(location));
else
PropertyPreferenceLoader.load(location);
try {

Check warning on line 147 in core/launcher/src/main/java/org/phoebus/product/Launcher.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Extract this nested try block into a separate method.

See more on https://sonarcloud.io/project/issues?id=ControlSystemStudio_phoebus&issues=AaFUUFjVHgtdV_wvKrFb&open=AaFUUFjVHgtdV_wvKrFb&pullRequest=3968
if (location.endsWith(".xml"))
Preferences.importPreferences(new FileInputStream(location));
else
PropertyPreferenceLoader.load(location);
} catch (Exception e) {
if (forceStart) {
logger.log(Level.SEVERE, "Failed to load settings from " + location, e);

Check warning on line 154 in core/launcher/src/main/java/org/phoebus/product/Launcher.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Lambda should be used to defer string concatenation.

See more on https://sonarcloud.io/project/issues?id=ControlSystemStudio_phoebus&issues=AaF3m0MWiDZ120csGsyD&open=AaF3m0MWiDZ120csGsyD&pullRequest=3968
} else {
throw e;
}
}

} else if (cmd.equals("-export_settings")) {
if (!iter.hasNext())
Expand Down Expand Up @@ -237,6 +249,7 @@
System.out.println("-nosplash - Suppress the splash screen");
System.out.println("-launch_error_dialog - Shows dialog if launch fails. Must be first program argument.");
System.out.println("-settings settings.xml - Import settings from file, either exported XML or property file format");
System.out.println("-force_start - Start even if the -settings file does not exist. Must be set before -settings.");

Check warning on line 252 in core/launcher/src/main/java/org/phoebus/product/Launcher.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this use of System.out by a logger.

See more on https://sonarcloud.io/project/issues?id=ControlSystemStudio_phoebus&issues=AaF3lnvNzgNxdXwPlEZy&open=AaF3lnvNzgNxdXwPlEZy&pullRequest=3968
System.out.println("-export_settings settings.xml - Export settings to file");
System.out.println("-logging logging.properties - Load log settings");
System.out.println("-list - List available application features");
Expand Down
Loading