GUAC-587: Do not require guacamole.properties. Use defaults if missing.

This commit is contained in:
Michael Jumper
2015-05-12 13:59:30 -07:00
parent 2c027e9cb2
commit d066d58ee1

View File

@@ -95,28 +95,28 @@ public class LocalEnvironment implements Environment {
properties = new Properties(); properties = new Properties();
try { try {
InputStream stream; InputStream stream = null;
// If not a directory, load from classpath // If not a directory, load from classpath
if (!guacHome.isDirectory()) { if (!guacHome.isDirectory())
// Read from classpath
stream = LocalEnvironment.class.getResourceAsStream("/guacamole.properties"); stream = LocalEnvironment.class.getResourceAsStream("/guacamole.properties");
if (stream == null)
throw new GuacamoleServerException(
"guacamole.properties not loaded from " + guacHome
+ " (not a directory), and guacamole.properties could"
+ " not be found as a resource in the classpath.");
}
// Otherwise, try to load from file // Otherwise, try to load from file
else else {
stream = new FileInputStream(new File(guacHome, "guacamole.properties")); File propertiesFile = new File(guacHome, "guacamole.properties");
if (propertiesFile.exists())
stream = new FileInputStream(propertiesFile);
}
// Load properties, always close stream // Load properties from stream, if any, always closing stream when done
try { properties.load(stream); } if (stream != null) {
finally { stream.close(); } try { properties.load(stream); }
finally { stream.close(); }
}
// Notify if we're proceeding without guacamole.properties
else
logger.info("No guacamole.properties file found within GUACAMOLE_HOME or the classpath. Using defaults.");
} }
catch (IOException e) { catch (IOException e) {