From c34b3a8017b328c474f6778d286322cf4fb61372 Mon Sep 17 00:00:00 2001 From: gerbermichi Date: Tue, 16 Dec 2014 18:44:09 +0100 Subject: [PATCH] Bugfix: Can not read keycloak-server.json if the path contains a space https://issues.jboss.org/browse/KEYCLOAK-892 --- .../services/resources/KeycloakApplication.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/services/src/main/java/org/keycloak/services/resources/KeycloakApplication.java b/services/src/main/java/org/keycloak/services/resources/KeycloakApplication.java index 36679123f3..0e72e392b9 100755 --- a/services/src/main/java/org/keycloak/services/resources/KeycloakApplication.java +++ b/services/src/main/java/org/keycloak/services/resources/KeycloakApplication.java @@ -104,23 +104,24 @@ public class KeycloakApplication extends Application { public static void loadConfig() { try { - URL config = null; + JsonNode node = null; String configDir = System.getProperty("jboss.server.config.dir"); if (configDir != null) { File f = new File(configDir + File.separator + "keycloak-server.json"); if (f.isFile()) { - config = f.toURI().toURL(); + node = new ObjectMapper().readTree(f); + log.info("Loaded config from " + f.getAbsolutePath()); } } - if (config == null) { - config = Thread.currentThread().getContextClassLoader().getResource("META-INF/keycloak-server.json"); + if (node == null) { + URL resource = Thread.currentThread().getContextClassLoader().getResource("META-INF/keycloak-server.json"); + node = new ObjectMapper().readTree(resource); + log.info("Loaded config from " + resource); } - if (config != null) { - JsonNode node = new ObjectMapper().readTree(config); - + if (node != null) { Properties properties = new Properties(); properties.putAll(System.getProperties()); for(Map.Entry e : System.getenv().entrySet()) { @@ -129,7 +130,6 @@ public class KeycloakApplication extends Application { Config.init(new JsonConfigProvider(node, properties)); - log.info("Loaded config from " + config); return; } else { log.warn("Config 'keycloak-server.json' not found");