From: Evgeny Mandrikov Date: Tue, 10 Jan 2012 09:50:37 +0000 (+0400) Subject: SONAR-3137,SONAR-2292 Fix startup failure X-Git-Tag: 2.14~333 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=e67cf1eecaa2bef3549296d6299faf914b38813e;p=sonarqube.git SONAR-3137,SONAR-2292 Fix startup failure --- diff --git a/sonar-server/src/main/java/org/sonar/server/ui/RealmFactory.java b/sonar-server/src/main/java/org/sonar/server/ui/RealmFactory.java index db3614281b3..3a16c5e179a 100644 --- a/sonar-server/src/main/java/org/sonar/server/ui/RealmFactory.java +++ b/sonar-server/src/main/java/org/sonar/server/ui/RealmFactory.java @@ -78,16 +78,18 @@ public class RealmFactory implements ServerComponent { } public void start() { - try { - INFO.info("Security realm: " + realm.getName()); - realm.init(); - INFO.info("Security realm started"); - } catch (RuntimeException e) { - if (ignoreStartupFailure) { - LOG.error("IGNORED - Realm fails to start: " + e.getMessage()); - } else { - LOG.error("Realm fails to start: " + e.getMessage()); - throw e; + if (realm != null) { + try { + INFO.info("Security realm: " + realm.getName()); + realm.init(); + INFO.info("Security realm started"); + } catch (RuntimeException e) { + if (ignoreStartupFailure) { + LOG.error("IGNORED - Realm fails to start: " + e.getMessage()); + } else { + LOG.error("Realm fails to start: " + e.getMessage()); + throw e; + } } } } diff --git a/sonar-server/src/test/java/org/sonar/server/ui/RealmFactoryTest.java b/sonar-server/src/test/java/org/sonar/server/ui/RealmFactoryTest.java index a0436ac9120..1fab381e138 100644 --- a/sonar-server/src/test/java/org/sonar/server/ui/RealmFactoryTest.java +++ b/sonar-server/src/test/java/org/sonar/server/ui/RealmFactoryTest.java @@ -57,6 +57,7 @@ public class RealmFactoryTest { @Test public void doNotFailIfNoRealms() { RealmFactory factory = new RealmFactory(settings); + factory.start(); assertThat(factory.getRealm(), nullValue()); }