From 20de5a0d5d0240b7820671d3f292d0cf10301808 Mon Sep 17 00:00:00 2001 From: Maxime Sinclair Date: Thu, 9 Jan 2014 16:53:35 +0100 Subject: [PATCH] [FIX] The Properties is always null --- .../servlet/utility/Configuration.java | 95 +++++++++---------- 1 file changed, 47 insertions(+), 48 deletions(-) diff --git a/src/main/java/net/sourceforge/plantuml/servlet/utility/Configuration.java b/src/main/java/net/sourceforge/plantuml/servlet/utility/Configuration.java index e29d5a9..560a120 100644 --- a/src/main/java/net/sourceforge/plantuml/servlet/utility/Configuration.java +++ b/src/main/java/net/sourceforge/plantuml/servlet/utility/Configuration.java @@ -30,55 +30,54 @@ import java.util.Properties; public class Configuration { - private static Configuration instance; - private Properties config; + private static Configuration instance; + private Properties config; - /** - * Singleton constructor - */ - private Configuration() { - Properties config = new Properties(); - - // Default values - config.setProperty("SHOW_SOCIAL_BUTTONS", "off"); - config.setProperty("USE_GOOGLE_TRACKER", "off"); - // End of default values - - try { - InputStream is = Thread.currentThread().getContextClassLoader(). - getResourceAsStream("config.properties"); - if (is != null) { - config.load(is); - is.close(); - } - } catch (IOException e) { - // Just log a warning - e.printStackTrace(); - } - } + /** + * Singleton constructor + */ + private Configuration() { + config = new Properties(); - /** - * Get the configuration - * - * @return the complete configuration - */ - public static Properties get() { - if (instance == null) { - instance = new Configuration(); - } - return instance.config; - } - - /** - * Get a boolean configuration value - * - * @return true if the value is "on" - */ - public static boolean get(String key) { - if (instance.config.getProperty(key) == null) { - return false; - } - return instance.config.getProperty(key).startsWith("on"); - } + // Default values + config.setProperty("SHOW_SOCIAL_BUTTONS", "off"); + config.setProperty("USE_GOOGLE_TRACKER", "off"); + // End of default values + + try { + InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("config.properties"); + if (is != null) { + config.load(is); + is.close(); + } + } catch (IOException e) { + // Just log a warning + e.printStackTrace(); + } + } + + /** + * Get the configuration + * + * @return the complete configuration + */ + public static Properties get() { + if (instance == null) { + instance = new Configuration(); + } + return instance.config; + } + + /** + * Get a boolean configuration value + * + * @return true if the value is "on" + */ + public static boolean get(String key) { + if (instance.config.getProperty(key) == null) { + return false; + } + return instance.config.getProperty(key).startsWith("on"); + } }