]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-6366 fix quality flaws
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Tue, 5 May 2015 14:59:51 +0000 (16:59 +0200)
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Tue, 5 May 2015 14:59:51 +0000 (16:59 +0200)
server/sonar-server/src/main/java/org/sonar/server/db/migrations/PlatformDatabaseMigration.java
server/sonar-server/src/main/java/org/sonar/server/ruby/PlatformRubyBridge.java
server/sonar-server/src/main/java/org/sonar/server/ruby/package-info.java

index a983979c1244c9b1f8f41c04994d0df15788ce72..6addd3412f5c2478812caec78795a99cd312567d 100644 (file)
@@ -87,7 +87,7 @@ public class PlatformDatabaseMigration implements DatabaseMigration {
   }
 
   /**
-   * This method is not thread safe and must be external protected from concurrent executions.
+   * This method is not thread safe and must be externally protected from concurrent executions.
    */
   private void startAsynchronousDBMigration() {
     if (this.running.get()) {
@@ -98,50 +98,52 @@ public class PlatformDatabaseMigration implements DatabaseMigration {
     executorService.execute(new Runnable() {
       @Override
       public void run() {
-        status = Status.RUNNING;
-        startDate = new Date();
-        failureError = null;
-        Profiler profiler = Profiler.create(LOGGER);
-        try {
-          profiler.startInfo("Starting DB Migration");
-          upgradeDb();
-          restartContainer();
-          recreateWebRoutes();
-          status = Status.SUCCEEDED;
-          profiler.stopInfo("DB Migration ended successfully");
-        } catch (Throwable t) {
-          profiler.stopInfo("DB migration failed");
-          LOGGER.error(
-            "DB Migration or container restart failed. Process ended with an exception", t
-            );
-          status = Status.FAILED;
-          failureError = t;
-        } finally {
-          running.getAndSet(false);
-        }
+        doDatabaseMigration();
       }
+    });
+  }
 
-      private void upgradeDb() {
-        Profiler profiler = Profiler.createIfTrace(LOGGER);
-        profiler.startTrace("Starting DB Migration");
-        rubyBridge.databaseMigration().trigger();
-        profiler.stopTrace("DB Migration ended");
-      }
+  private void doDatabaseMigration() {
+    status = Status.RUNNING;
+    startDate = new Date();
+    failureError = null;
+    Profiler profiler = Profiler.create(LOGGER);
+    try {
+      profiler.startInfo("Starting DB Migration");
+      doUpgradeDb();
+      doRestartContainer();
+      doRecreateWebRoutes();
+      status = Status.SUCCEEDED;
+      profiler.stopInfo("DB Migration ended successfully");
+    } catch (Throwable t) {
+      profiler.stopInfo("DB migration failed");
+      LOGGER.error("DB Migration or container restart failed. Process ended with an exception", t);
+      status = Status.FAILED;
+      failureError = t;
+    } finally {
+      running.getAndSet(false);
+    }
+  }
 
-      private void restartContainer() {
-        Profiler profiler = Profiler.createIfTrace(LOGGER);
-        profiler.startTrace("Restarting container");
-        platform.doStart();
-        profiler.stopTrace("Container restarted successfully");
-      }
+  private void doUpgradeDb() {
+    Profiler profiler = Profiler.createIfTrace(LOGGER);
+    profiler.startTrace("Starting DB Migration");
+    rubyBridge.databaseMigration().trigger();
+    profiler.stopTrace("DB Migration ended");
+  }
 
-      private void recreateWebRoutes() {
-        Profiler profiler = Profiler.createIfTrace(LOGGER);
-        profiler.startTrace("Recreating web routes");
-        rubyBridge.railsRoutes().recreate();
-        profiler.startTrace("Routes recreated successfully");
-      }
-    });
+  private void doRestartContainer() {
+    Profiler profiler = Profiler.createIfTrace(LOGGER);
+    profiler.startTrace("Restarting container");
+    platform.doStart();
+    profiler.stopTrace("Container restarted successfully");
+  }
+
+  private void doRecreateWebRoutes() {
+    Profiler profiler = Profiler.createIfTrace(LOGGER);
+    profiler.startTrace("Recreating web routes");
+    rubyBridge.railsRoutes().recreate();
+    profiler.startTrace("Routes recreated successfully");
   }
 
   @Override
index 3ac71e4f0135a50527ac02d23b7c6459ff1a6f9f..2fbe60b39ef68e630eeeb75af51222da66a29eb0 100644 (file)
@@ -24,7 +24,6 @@ import java.io.InputStream;
 import javax.annotation.Nullable;
 import org.jruby.Ruby;
 import org.jruby.RubyNil;
-import org.jruby.RubyRuntimeAdapter;
 import org.jruby.embed.InvokeFailedException;
 import org.jruby.javasupport.JavaEmbedUtils;
 import org.jruby.javasupport.JavaUtil;
@@ -35,7 +34,6 @@ public class PlatformRubyBridge implements RubyBridge {
   private static final String CALL_LOAD_JAVA_WEB_SERVICES_RB_FILENAME = "call_load_java_web_services.rb";
 
   private final RackBridge rackBridge;
-  private final RubyRuntimeAdapter adapter = JavaEmbedUtils.newRuntimeAdapter();
 
   public PlatformRubyBridge(RackBridge rackBridge) {
     this.rackBridge = rackBridge;
index e6dea1c89ed5217e09f8a68423eda56260972080..448b07571c33ff931321193fbde176f3031926a2 100644 (file)
@@ -20,4 +20,4 @@
 @ParametersAreNonnullByDefault
 package org.sonar.server.ruby;
 
-import javax.annotation.ParametersAreNonnullByDefault;
\ No newline at end of file
+import javax.annotation.ParametersAreNonnullByDefault;