From 48ca0521616a251dc9963f15f9728e0b92aad4f3 Mon Sep 17 00:00:00 2001 From: Stephane Gamard Date: Thu, 14 Aug 2014 13:08:51 +0200 Subject: [PATCH] fix quality flaw --- .../src/main/java/org/sonar/process/NetworkUtils.java | 4 ++++ .../src/main/java/org/sonar/process/ProcessUtils.java | 8 +++++++- .../src/main/java/org/sonar/process/ProcessWrapper.java | 2 +- .../src/main/java/org/sonar/search/SearchServer.java | 4 ++-- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/server/process/sonar-process/src/main/java/org/sonar/process/NetworkUtils.java b/server/process/sonar-process/src/main/java/org/sonar/process/NetworkUtils.java index a037ce0113a..516c57c497a 100644 --- a/server/process/sonar-process/src/main/java/org/sonar/process/NetworkUtils.java +++ b/server/process/sonar-process/src/main/java/org/sonar/process/NetworkUtils.java @@ -24,6 +24,10 @@ import java.net.ServerSocket; public class NetworkUtils { + private NetworkUtils() { + // only static stuff + } + public static int freePort() { try { ServerSocket s = new ServerSocket(0); diff --git a/server/process/sonar-process/src/main/java/org/sonar/process/ProcessUtils.java b/server/process/sonar-process/src/main/java/org/sonar/process/ProcessUtils.java index 92537412587..a762446ec87 100644 --- a/server/process/sonar-process/src/main/java/org/sonar/process/ProcessUtils.java +++ b/server/process/sonar-process/src/main/java/org/sonar/process/ProcessUtils.java @@ -20,10 +20,15 @@ package org.sonar.process; import org.apache.commons.io.IOUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import javax.annotation.Nullable; public class ProcessUtils { + + private static final Logger LOGGER = LoggerFactory.getLogger(ProcessUtils.class); + private ProcessUtils() { // only static stuff } @@ -36,6 +41,7 @@ public class ProcessUtils { process.exitValue(); return false; } catch (IllegalThreadStateException e) { + LOGGER.trace("Process has no exit value yet", e); return true; } } @@ -45,7 +51,7 @@ public class ProcessUtils { try { process.destroy(); } catch (Exception ignored) { - // ignored + LOGGER.warn("Exception while destroying the process", ignored); } } } diff --git a/server/process/sonar-process/src/main/java/org/sonar/process/ProcessWrapper.java b/server/process/sonar-process/src/main/java/org/sonar/process/ProcessWrapper.java index 3eca9804a7c..c3c9949efc1 100644 --- a/server/process/sonar-process/src/main/java/org/sonar/process/ProcessWrapper.java +++ b/server/process/sonar-process/src/main/java/org/sonar/process/ProcessWrapper.java @@ -360,7 +360,7 @@ public class ProcessWrapper extends Thread implements Terminable { logger.info(line); } } catch (Exception ignored) { - LOGGER.trace("Error while Gobbling", ignored); + logger.trace("Error while Gobbling", ignored); } finally { IOUtils.closeQuietly(br); IOUtils.closeQuietly(isr); diff --git a/server/sonar-search/src/main/java/org/sonar/search/SearchServer.java b/server/sonar-search/src/main/java/org/sonar/search/SearchServer.java index 960ce34b272..14d28abd45c 100644 --- a/server/sonar-search/src/main/java/org/sonar/search/SearchServer.java +++ b/server/sonar-search/src/main/java/org/sonar/search/SearchServer.java @@ -76,11 +76,11 @@ public class SearchServer extends MonitoredProcess { @Override protected boolean doIsReady() { - return (node.client().admin().cluster().prepareHealth() + return node.client().admin().cluster().prepareHealth() .setWaitForYellowStatus() .setTimeout(TimeValue.timeValueSeconds(3L)) .get() - .getStatus() != ClusterHealthStatus.RED); + .getStatus() != ClusterHealthStatus.RED; } @Override -- 2.39.5