]> source.dussan.org Git - sonarqube.git/commitdiff
fix various quality flaws
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Fri, 24 Apr 2015 14:41:13 +0000 (16:41 +0200)
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Fri, 24 Apr 2015 14:42:19 +0000 (16:42 +0200)
server/sonar-server/src/main/java/org/sonar/server/platform/ServerComponents.java
server/sonar-server/src/main/java/org/sonar/server/plugins/PluginDownloader.java
server/sonar-server/src/main/java/org/sonar/server/plugins/ServerPluginJarsInstaller.java
server/sonar-server/src/main/java/org/sonar/server/ruby/package-info.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/util/AbstractStoppableExecutorService.java
sonar-core/src/main/java/org/sonar/core/plugins/PluginJarInstaller.java

index 47f16ba95672f06eebb26cd4324bbe19621ee304..16aa1ea53ffa066f16d53b01d7779b95414660a4 100644 (file)
@@ -411,7 +411,7 @@ class ServerComponents {
   /**
    * All the stuff required to connect to database
    */
-  Collection<?> level1Components() {
+  Collection<Object> level1Components() {
     List<Object> components = Lists.newArrayList(platform, properties);
     addExtraRootComponents(components);
     components.addAll(Arrays.asList(
index 860ad0f53af97a3d73f65b7e1557dea8b20e06d4..1e2dd190f49fc4d5d8e7b9dbbaa36571199a757f 100644 (file)
@@ -115,7 +115,7 @@ public class PluginDownloader implements Startable {
    * @return the list of download plugins as {@link DefaultPluginMetadata} instances
    */
   public Collection<DefaultPluginMetadata> getDownloadedPlugins() {
-    return newArrayList(transform(listPlugins(this.downloadDir), installer.fileToPlugin(false)));
+    return newArrayList(transform(listPlugins(this.downloadDir), installer.fileToPlugin()));
   }
 
   public void download(String pluginKey, Version version) {
index cbed2cb36029a375ddba8be13d4570a0a74c30fc..9b9ce32dc81bd2e112e8ee1eefb894ec798c3389 100644 (file)
@@ -102,7 +102,7 @@ public class ServerPluginJarsInstaller {
 
   private void loadInstalledPlugins() {
     for (File file : fs.getUserPlugins()) {
-      PluginMetadata metadata = installer.fileToPlugin(false).apply(file);
+      PluginMetadata metadata = installer.fileToPlugin().apply(file);
       if (isNotBlank(metadata.getKey())) {
         loadInstalledPlugin(metadata);
       }
@@ -132,7 +132,7 @@ public class ServerPluginJarsInstaller {
   private void copyBundledPlugins() {
     if (serverUpgradeStatus.isFreshInstall()) {
       for (File sourceFile : fs.getBundledPlugins()) {
-        PluginMetadata metadata = installer.fileToPlugin(false).apply(sourceFile);
+        PluginMetadata metadata = installer.fileToPlugin().apply(sourceFile);
         // lib/bundled-plugins should be copied only if the plugin is not already
         // available in extensions/plugins
         if (!pluginByKeys.containsKey(metadata.getKey())) {
@@ -161,7 +161,7 @@ public class ServerPluginJarsInstaller {
         sourceFile.getAbsolutePath(), destFile.getAbsolutePath()), e);
     }
 
-    PluginMetadata metadata = installer.fileToPlugin(false).apply(destFile);
+    PluginMetadata metadata = installer.fileToPlugin().apply(destFile);
     if (isNotBlank(metadata.getKey())) {
       PluginMetadata existing = pluginByKeys.put(metadata.getKey(), metadata);
       if (existing != null) {
@@ -175,7 +175,7 @@ public class ServerPluginJarsInstaller {
 
   private void loadCorePlugins() {
     for (File file : fs.getCorePlugins()) {
-      PluginMetadata metadata = installer.fileToPlugin(true).apply(file);
+      PluginMetadata metadata = installer.fileToCorePlugin().apply(file);
       PluginMetadata existing = pluginByKeys.put(metadata.getKey(), metadata);
       if (existing != null) {
         throw new IllegalStateException("Found two plugins with the same key '" + metadata.getKey() + "': " + metadata.getFile().getName() + " and "
@@ -218,7 +218,7 @@ public class ServerPluginJarsInstaller {
       return Collections.emptyList();
     }
 
-    return newArrayList(transform(listJarFiles(fs.getTrashPluginsDir()), installer.fileToPlugin(false)));
+    return newArrayList(transform(listJarFiles(fs.getTrashPluginsDir()), installer.fileToPlugin()));
   }
 
   public void cancelUninstalls() {
diff --git a/server/sonar-server/src/main/java/org/sonar/server/ruby/package-info.java b/server/sonar-server/src/main/java/org/sonar/server/ruby/package-info.java
new file mode 100644 (file)
index 0000000..e6dea1c
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+@ParametersAreNonnullByDefault
+package org.sonar.server.ruby;
+
+import javax.annotation.ParametersAreNonnullByDefault;
\ No newline at end of file
index 278eb460f7c80cffd6b4232096472c71fa16d8fa..daf575eba7d6a85d48fb597eefa10fdbec0ee886 100644 (file)
@@ -45,11 +45,13 @@ public abstract class AbstractStoppableExecutorService implements StoppableExecu
 
   @Override
   public void stop() {
-    delegate.shutdown(); // Disable new tasks from being submitted
+    // Disable new tasks from being submitted
+    delegate.shutdown();
     try {
       // Wait a while for existing tasks to terminate
       if (!delegate.awaitTermination(5, TimeUnit.SECONDS)) {
-        delegate.shutdownNow(); // Cancel currently executing tasks
+        // Cancel currently executing tasks
+        delegate.shutdownNow();
         // Wait a while for tasks to respond to being cancelled
         if (!delegate.awaitTermination(5, TimeUnit.SECONDS)) {
           Loggers.get(getClass()).error(format("Pool %s did not terminate", getClass().getSimpleName()));
index 5af5f9c754f50a50afa744562a9d04b67b2dd56b..7c5114a323bb9defecfda5b49a23ec1ecce91300 100644 (file)
@@ -88,8 +88,12 @@ public abstract class PluginJarInstaller implements BatchComponent, ServerCompon
     }
   }
 
-  public Function<File, DefaultPluginMetadata> fileToPlugin(boolean core) {
-    return core ? jarFileToCorePlugin : jarFileToPlugin;
+  public Function<File, DefaultPluginMetadata> fileToPlugin() {
+    return jarFileToPlugin;
+  }
+
+  public Function<File, DefaultPluginMetadata> fileToCorePlugin() {
+    return jarFileToCorePlugin;
   }
 
   private final Function<File, DefaultPluginMetadata> jarFileToCorePlugin = new Function<File, DefaultPluginMetadata>() {