]> source.dussan.org Git - sonarqube.git/commitdiff
Fix quality flaws
authorJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>
Tue, 3 Dec 2013 17:50:53 +0000 (18:50 +0100)
committerJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>
Tue, 3 Dec 2013 17:50:53 +0000 (18:50 +0100)
sonar-core/src/main/java/org/sonar/core/profiling/Profiling.java
sonar-core/src/main/java/org/sonar/core/profiling/package-info.java [new file with mode: 0644]
sonar-server/src/main/java/org/sonar/server/platform/ProfilingFilter.java
sonar-server/src/main/java/org/sonar/server/search/SearchIndex.java
sonar-server/src/main/java/org/sonar/server/search/SearchNode.java
sonar-server/src/main/java/org/sonar/server/ui/JRubyI18n.java

index e2be2c5ee09cdd248a043304d8a639e6a508a047..f9ff151ac053bea37511c2e8efa6477c8d4dd72d 100644 (file)
@@ -29,9 +29,6 @@ import org.sonar.api.config.Settings;
  */
 public final class Profiling implements ServerExtension {
 
-  /**
-   * 
-   */
   public static final String CONFIG_PROFILING_LEVEL = "sonar.log.profilingLevel";
 
   private static final Logger LOGGER = LoggerFactory.getLogger(Profiling.class);
diff --git a/sonar-core/src/main/java/org/sonar/core/profiling/package-info.java b/sonar-core/src/main/java/org/sonar/core/profiling/package-info.java
new file mode 100644 (file)
index 0000000..5a8addb
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2013 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.core.profiling;
+
+import javax.annotation.ParametersAreNonnullByDefault;
+
index 0ecd10feada62ade71c43a2f7ae31e24d4d7d5e2..2d91f7ed3503b88ed99ee7e017a3311ea91fdf9d 100644 (file)
 
 package org.sonar.server.platform;
 
+import com.google.common.annotations.VisibleForTesting;
 import com.google.common.collect.ImmutableSet;
 import org.apache.commons.lang.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.sonar.api.config.Settings;
 import org.sonar.core.profiling.Profiling;
 import org.sonar.core.profiling.Profiling.Level;
 import org.sonar.core.profiling.StopWatch;
@@ -42,6 +46,8 @@ import java.util.Set;
  */
 public class ProfilingFilter implements Filter {
 
+  private static final Logger LOG = LoggerFactory.getLogger(ProfilingFilter.class);
+
   private static final String CONFIG_SEPARATOR = ",";
   private static final String URL_SEPARATOR = "/";
 
@@ -105,12 +111,13 @@ public class ProfilingFilter implements Filter {
     // Nothing
   }
 
-
+  @VisibleForTesting
   Profiling getProfiling() {
     try {
       return (Profiling) Platform.component(Profiling.class);
     } catch(Exception initException) {
-      return null;
+      LOG.error("Could not initialize platform profiling", initException);
+      return new Profiling(new Settings());
     }
   }
 }
index bf9ebcc410f07c0456543ea985c05d1a17b04373..11de7b748c4bc12215ee89119a179365429ee575 100644 (file)
@@ -53,6 +53,9 @@ import java.util.concurrent.ExecutionException;
 
 public class SearchIndex {
 
+  private static final String BULK_EXECUTE_FAILED = "Execution of bulk operation failed";
+  private static final String BULK_INTERRUPTED = "Interrupted during bulk operation";
+
   private static final String PROFILE_DOMAIN = "es";
   private static final Logger LOG = LoggerFactory.getLogger(SearchIndex.class);
 
@@ -116,9 +119,9 @@ public class SearchIndex {
         }
       }
     } catch (InterruptedException e) {
-      LOG.error("Interrupted during bulk operation", e);
+      LOG.error(BULK_INTERRUPTED, e);
     } catch (ExecutionException e) {
-      LOG.error("Execution of bulk operation failed", e);
+      LOG.error(BULK_EXECUTE_FAILED, e);
     } finally {
       watch.stop("bulk index of %d documents with type '%s' into index '%s'", ids.length, type, index);
     }
@@ -215,9 +218,9 @@ public class SearchIndex {
         }
       }
     } catch (InterruptedException e) {
-      LOG.error("Interrupted during bulk operation", e);
+      LOG.error(BULK_INTERRUPTED, e);
     } catch (ExecutionException e) {
-      LOG.error("Execution of bulk operation failed", e);
+      LOG.error(BULK_EXECUTE_FAILED, e);
     } finally {
       watch.stop("bulk delete of %d documents with type '%s' from index '%s'", ids.length, type, index);
     }
index 1e09e2571f537963570647e845194e00d65fcc63..4b5f88c49fe64055eb578cd69481fe5daf54caa4 100644 (file)
@@ -42,6 +42,8 @@ import java.io.File;
 public class SearchNode implements Startable {
 
   private static final Logger LOG = LoggerFactory.getLogger(SearchIndex.class);
+
+  private static final String HTTP_ENABLED = "http.enabled";
   private static final String INSTANCE_NAME = "sonarqube";
   static final String DATA_DIR = "data/es";
 
@@ -83,11 +85,11 @@ public class SearchNode implements Startable {
     int httpPort = settings.getInt("sonar.es.http.port");
     if (httpPort > 0) {
       LOG.warn("Elasticsearch HTTP console enabled on port {}. Only for debugging purpose.", httpPort);
-      esSettings.put("http.enabled", true);
+      esSettings.put(HTTP_ENABLED, true);
       esSettings.put("http.host", "127.0.0.1");
       esSettings.put("http.port", httpPort);
     } else {
-      esSettings.put("http.enabled", false);
+      esSettings.put(HTTP_ENABLED, false);
     }
   }
 
index 2460ad039e9d3204c1d283859cd27095beb278ca..bf992bc661709e7e24db4d19586eb1809cd7a87d 100644 (file)
@@ -27,7 +27,7 @@ import org.sonar.core.i18n.GwtI18n;
 import org.sonar.core.i18n.RuleI18nManager;
 
 import javax.annotation.Nullable;
-import java.util.List;
+
 import java.util.Locale;
 import java.util.Map;