]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-3137,SONAR-2292 Fix startup failure
authorEvgeny Mandrikov <mandrikov@gmail.com>
Tue, 10 Jan 2012 09:50:37 +0000 (13:50 +0400)
committerEvgeny Mandrikov <mandrikov@gmail.com>
Tue, 10 Jan 2012 09:50:37 +0000 (13:50 +0400)
sonar-server/src/main/java/org/sonar/server/ui/RealmFactory.java
sonar-server/src/test/java/org/sonar/server/ui/RealmFactoryTest.java

index db3614281b3c21df5917c2782ee8764c9d7349aa..3a16c5e179acb15b26a584555f731ed3bc7eca1b 100644 (file)
@@ -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;
+        }
       }
     }
   }
index a0436ac9120204537012dbbc0596d2d68a996c58..1fab381e13866e887f14a0c42158707de2726d72 100644 (file)
@@ -57,6 +57,7 @@ public class RealmFactoryTest {
   @Test
   public void doNotFailIfNoRealms() {
     RealmFactory factory = new RealmFactory(settings);
+    factory.start();
     assertThat(factory.getRealm(), nullValue());
   }