Skip to content

Commit b8c388b

Browse files
authored
Merge pull request #3491 from ControlSystemStudio/restore_bundled_settings
Always check bundled settings.ini, regardless of additional -settings
2 parents 0c63c8d + 68cd18a commit b8c388b

File tree

1 file changed

+17
-32
lines changed

1 file changed

+17
-32
lines changed

core/launcher/src/main/java/org/phoebus/product/Launcher.java

Lines changed: 17 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,15 @@
2727

2828
@SuppressWarnings("nls")
2929
public class Launcher {
30-
private static final String SETTINGS_OPTION = "-settings";
3130
private static final String LOGGING_OPTION = "-logging";
3231
private static final String DEFAULT_LOGGING_FILE="/logging.properties";
3332
private static final String LOGGING_PROP = "java.util.logging.config.file";
34-
33+
3534
public static void main(final String[] original_args) throws Exception {
3635
// First Handle arguments, potentially not even starting the UI
37-
// settings and logging will define the phoebus.install value if not exist
36+
// settings and logging will define the phoebus.install value if not exist
3837
final List<String> args = new ArrayList<>(List.of(original_args));
39-
38+
4039
//Handle logging first
4140
int indexOf = args.indexOf(LOGGING_OPTION);
4241
String loggingFilePath = null;
@@ -60,22 +59,22 @@ public static void main(final String[] original_args) throws Exception {
6059
errorLoggingOption = "User logging file " + loggingFilePath + " not found";
6160
}
6261
}
63-
62+
6463
//If no logging found use the default one
6564
if(loggingStream == null) {
6665
loggingFilePath = Launcher.class.getResource(DEFAULT_LOGGING_FILE).getFile();
6766
loggingStream = Launcher.class.getResourceAsStream(DEFAULT_LOGGING_FILE);
6867
}
69-
68+
7069
//Load logging configuration
7170
LogManager.getLogManager().readConfiguration(loggingStream);
7271
final Logger logger = Logger.getLogger(Launcher.class.getPackageName());
7372
logger.log(Level.CONFIG, "Loading logging configuration from " + loggingFilePath);
74-
73+
7574
if(errorLoggingOption != null) {
7675
logger.log(Level.WARNING, errorLoggingOption);
7776
}
78-
77+
7978
boolean showLaunchError = false;
8079

8180
// Can't change default charset, but warn if it's not UTF-8.
@@ -92,35 +91,21 @@ public static void main(final String[] original_args) throws Exception {
9291
logger.severe("Default charset is " + cs.displayName() + " instead of UTF-8.");
9392
logger.severe("Add -D\"file.encoding=UTF-8\" to java command line or JAVA_TOOL_OPTIONS");
9493
}
95-
96-
//Handle user settings.ini in order to get Locations informations
97-
//as user home directory and phoebus folder name
98-
//Install path will be set on call of install()
99-
//Locations.initialize();
100-
indexOf = args.indexOf(SETTINGS_OPTION);
101-
File site_settings = null;
102-
if(indexOf > 0 && indexOf <= args.size()) {
103-
String settingsFilePath = args.get(indexOf + 1);
104-
site_settings = new File(settingsFilePath);
105-
}
106-
107-
if(site_settings == null || !site_settings.exists()) {
108-
// Check for site-specific settings.ini bundled into distribution
109-
// before potentially adding command-line settings.
110-
String settingsError = site_settings != null ? site_settings.getAbsolutePath() + " not found" : "is not defined";
111-
logger.log(Level.WARNING, "Settings file " + settingsError);
112-
site_settings = new File(Locations.install(), "settings.ini");
113-
}
114-
115-
if(site_settings != null && site_settings.exists()) {
116-
logger.info("Loading settings from " + site_settings.getAbsolutePath());
117-
FileInputStream fileInputStream = new FileInputStream(site_settings);
94+
95+
Locations.initialize();
96+
// Check for site-specific settings.ini bundled into distribution
97+
// before potentially adding command-line settings.
98+
final File site_settings = new File(Locations.install(), "settings.ini");
99+
if (site_settings.canRead())
100+
{
101+
logger.info("Loading bundled settings from " + site_settings.getAbsolutePath());
102+
final FileInputStream fileInputStream = new FileInputStream(site_settings);
118103
if (site_settings.getName().endsWith(".xml"))
119104
Preferences.importPreferences(fileInputStream);
120105
else
121106
PropertyPreferenceLoader.load(fileInputStream);
122107
}
123-
108+
124109
// Handle arguments, potentially not even starting the UI
125110
final Iterator<String> iter = args.iterator();
126111
int port = -1;

0 commit comments

Comments
 (0)