From e67cf1eecaa2bef3549296d6299faf914b38813e Mon Sep 17 00:00:00 2001 From: Evgeny Mandrikov Date: Tue, 10 Jan 2012 13:50:37 +0400 Subject: [PATCH] SONAR-3137,SONAR-2292 Fix startup failure --- .../org/sonar/server/ui/RealmFactory.java | 22 ++++++++++--------- .../org/sonar/server/ui/RealmFactoryTest.java | 1 + 2 files changed, 13 insertions(+), 10 deletions(-) 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()); } -- 2.39.5