KEYCLOAK-2039 NPE on startup if keycloak-server.json can't be found
- fix NPE and throw RuntimeException if config file not found
This commit is contained in:
parent
54b5a6c41e
commit
fd5cb84dd1
1 changed files with 5 additions and 3 deletions
|
@ -141,8 +141,10 @@ public class KeycloakApplication extends Application {
|
||||||
|
|
||||||
if (node == null) {
|
if (node == null) {
|
||||||
URL resource = Thread.currentThread().getContextClassLoader().getResource("META-INF/keycloak-server.json");
|
URL resource = Thread.currentThread().getContextClassLoader().getResource("META-INF/keycloak-server.json");
|
||||||
log.info("Load config from " + resource);
|
if (resource != null) {
|
||||||
node = new ObjectMapper().readTree(resource);
|
log.info("Load config from " + resource);
|
||||||
|
node = new ObjectMapper().readTree(resource);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node != null) {
|
if (node != null) {
|
||||||
|
@ -150,7 +152,7 @@ public class KeycloakApplication extends Application {
|
||||||
Config.init(new JsonConfigProvider(node, properties));
|
Config.init(new JsonConfigProvider(node, properties));
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
log.warn("Config 'keycloak-server.json' not found");
|
throw new RuntimeException("Config 'keycloak-server.json' not found");
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException("Failed to load config", e);
|
throw new RuntimeException("Failed to load config", e);
|
||||||
|
|
Loading…
Reference in a new issue