Skip to content

Commit 4827c31

Browse files
author
mgricken
committed
Fixed lazy initialization of DrJava config.
git-svn-id: file:///tmp/test-svn/trunk@5188 fe72c1cf-3628-48e9-8b72-1c46755d3cff
1 parent f5dd2de commit 4827c31

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

drjava/src/edu/rice/cs/drjava/DrJava.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,14 +144,20 @@ public class DrJava {
144144
/** Properties file used by the configuration object. Defaults to DEFAULT_PROPERTIES_FILE. */
145145
private static volatile File _propertiesFile = DEFAULT_PROPERTIES_FILE;
146146

147-
/** Configuration object with all customized and default values. Initialized from _propertiesFile. */
147+
/** Configuration object with all customized and default values.
148+
* Lazily initialized from _propertiesFile in getConfig() or handleCommandLineArgs(). */
148149
private static volatile FileConfiguration _config;
149150

150151
/** Returns the properties file used by the configuration object. */
151152
public static File getPropertiesFile() { return _propertiesFile; }
152153

153154
/** Returns the configuration object with all customized and default values. */
154-
public static FileConfiguration getConfig() { return _config; }
155+
public static synchronized FileConfiguration getConfig() {
156+
if (_config==null) {
157+
_config = _initConfig(); // read specified .djrava file into _config
158+
}
159+
return _config;
160+
}
155161

156162
/** @return an array of the files that were passed on the command line. */
157163
public static synchronized String[] getFilesToOpen() { return _filesToOpen.toArray(new String[0]); }
@@ -437,7 +443,9 @@ else if (arg.equals("-help") || arg.equals("-?")) {
437443
}
438444
}
439445

440-
_config = _initConfig(); // read specified .djrava file into _config
446+
synchronized(DrJava.class) {
447+
_config = _initConfig(); // read specified .djrava file into _config
448+
}
441449

442450
if ((!("".equals(getConfig().getSetting(MASTER_JVM_XMX)))) &&
443451
(!(edu.rice.cs.drjava.config.OptionConstants.heapSizeChoices.get(0).equals(getConfig().getSetting(MASTER_JVM_XMX))))) {

0 commit comments

Comments
 (0)