Skip to content

Commit

Permalink
fix quality flaws
Browse files Browse the repository at this point in the history
  • Loading branch information
sns-seb committed Mar 22, 2016
1 parent 8c6e135 commit eec3233
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 28 deletions.
26 changes: 13 additions & 13 deletions server/sonar-ce/src/main/java/org/sonar/ce/app/CeServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,19 +129,6 @@ public void stop() {
}
}

private void stopAwait() {
stopAwait = true;
Thread t = awaitThread.get();
if (t != null) {
t.interrupt();
try {
t.join(1000);
} catch (InterruptedException e) {
// Ignored
}
}
}

private class CeMainThread extends Thread {
private static final int CHECK_FOR_STOP_DELAY = 50;
private volatile boolean stop = false;
Expand Down Expand Up @@ -227,6 +214,19 @@ public void stopIt() {
// interrupt current thread in case its waiting for WebServer
interrupt();
}

private void stopAwait() {
stopAwait = true;
Thread t = awaitThread.get();
if (t != null) {
t.interrupt();
try {
t.join(1000);
} catch (InterruptedException e) {
// Ignored
}
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.rules.TemporaryFolder;
import org.junit.rules.Timeout;
import org.mockito.Mockito;
import org.sonar.ce.ComputeEngine;
Expand All @@ -44,8 +43,6 @@ public class CeServerTest {
public Timeout timeout = Timeout.seconds(50);
@Rule
public ExpectedException expectedException = ExpectedException.none();
@Rule
public TemporaryFolder temp = new TemporaryFolder();

private CeServer underTest = null;
private Thread waitingThread = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@
* <ul>
* <li>First byte contains {@link #EMPTY} until process is UP and writes {@link #UP}</li>
* <li>Second byte contains {@link #EMPTY} until any process requests current one to stop by writing value {@link #STOP}</li>
* <li>Third byte contains {@link #EMPTY} until any process requests current one to restart by writing value {@link #RESTART}. Process acknowledges restart by writing back {@link #EMPTY}</li>
* <li>Fourth byte will always contain {@link #EMPTY} unless process declares that it is operational by writing {@link #OPERATIONAL}. This does not imply that is done starting.</li>
* <li>Third byte contains {@link #EMPTY} until any process requests current one to restart by writing value {@link #RESTART}.
* Process acknowledges restart by writing back {@link #EMPTY}</li>
* <li>Fourth byte will always contain {@link #EMPTY} unless process declares that it is operational by writing {@link #OPERATIONAL}.
* This does not imply that is done starting.</li>
* <li>The next 8 bytes contains a long (value of {@link System#currentTimeMillis()}) which represents the date of the last ping</li>
* </ul>
* </p>
Expand All @@ -76,7 +78,7 @@ public class AllProcessesCommands {
private static final byte UP = (byte) 0x01;
private static final byte EMPTY = (byte) 0x00;

//VisibleForTesting
// VisibleForTesting
final MappedByteBuffer mappedByteBuffer;
private final RandomAccessFile sharedMemory;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ public Set<String> getHandledCeTaskTypes() {

@Override
public CeTaskResult process(CeTask task) {
throw new UnsupportedOperationException("process must not be called in WebServer");
throw new UnsupportedOperationException("process must not be called in WebServer");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ private String getAlertLabel(Condition condition, Measure.Level level) {
stringBuilder.append(metric);

if (alertPeriod != null && !condition.getMetric().getKey().startsWith(VARIATION_METRIC_PREFIX)) {
String variation = i18n.message(Locale.ENGLISH, VARIATION, VARIATION).toLowerCase();
String variation = i18n.message(Locale.ENGLISH, VARIATION, VARIATION).toLowerCase(Locale.ENGLISH);
stringBuilder.append(" ").append(variation);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@
import com.google.common.base.Optional;
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
import org.sonar.ce.taskprocessor.CeTaskProcessor;
import org.sonar.core.util.logs.Profiler;
import org.sonar.db.ce.CeActivityDto;
import org.sonar.ce.log.CeLogging;
import org.sonar.ce.queue.CeQueue;
import org.sonar.ce.queue.CeTask;
import org.sonar.ce.queue.CeTaskResult;
import org.sonar.ce.taskprocessor.CeTaskProcessor;
import org.sonar.core.util.logs.Profiler;
import org.sonar.db.ce.CeActivityDto;
import org.sonar.server.computation.queue.InternalCeQueue;

import static java.lang.String.format;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.rules.TemporaryFolder;
import org.sonar.api.config.Settings;
import org.sonar.api.utils.log.LogTester;
import org.sonar.api.utils.log.LoggerLevel;
Expand All @@ -44,8 +43,6 @@ public class RestartActionTest {
@Rule
public ExpectedException expectedException = ExpectedException.none();
@Rule
public TemporaryFolder temp = new TemporaryFolder();
@Rule
public LogTester logTester = new LogTester();

private Settings settings = new Settings();
Expand Down

0 comments on commit eec3233

Please sign in to comment.