Browse Source

Fix quality flaws

tags/5.2-RC1
Simon Brandhof 9 years ago
parent
commit
81e17e86cb

+ 1
- 1
server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/JavaProcessLauncher.java View File

@@ -99,7 +99,7 @@ public class JavaProcessLauncher {
Properties props = new Properties();
props.putAll(javaCommand.getArguments());
props.setProperty(ProcessEntryPoint.PROPERTY_PROCESS_KEY, javaCommand.getKey());
props.setProperty(ProcessEntryPoint.PROPERTY_PROCESS_INDEX, "" + javaCommand.getProcessIndex());
props.setProperty(ProcessEntryPoint.PROPERTY_PROCESS_INDEX, Integer.toString(javaCommand.getProcessIndex()));
props.setProperty(ProcessEntryPoint.PROPERTY_TERMINATION_TIMEOUT, String.valueOf(timeouts.getTerminationTimeout()));
props.setProperty(ProcessEntryPoint.PROPERTY_SHARED_PATH, javaCommand.getTempDir().getAbsolutePath());
OutputStream out = new FileOutputStream(propertiesFile);

+ 24
- 14
server/sonar-server/src/main/java/org/sonar/server/notification/NotificationService.java View File

@@ -22,6 +22,7 @@ package org.sonar.server.notification;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Multimap;
import com.google.common.collect.SetMultimap;
import java.util.ArrayList;
import java.util.Collection;
@@ -31,6 +32,7 @@ import java.util.Set;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import javax.annotation.Nullable;
import org.picocontainer.Startable;
import org.sonar.api.Properties;
import org.sonar.api.Property;
@@ -155,24 +157,12 @@ public class NotificationService implements Startable {
public void deliver(Notification notification) {
final SetMultimap<String, NotificationChannel> recipients = HashMultimap.create();
for (NotificationDispatcher dispatcher : dispatchers) {
NotificationDispatcher.Context context = new NotificationDispatcher.Context() {
@Override
public void addUser(String username) {
// This method is not used anymore
}

@Override
public void addUser(String userLogin, NotificationChannel notificationChannel) {
if (userLogin != null) {
recipients.put(userLogin, notificationChannel);
}
}
};
NotificationDispatcher.Context context = new ContextImpl(recipients);
try {
dispatcher.performDispatch(notification, context);
} catch (Exception e) {
// catch all exceptions in order to dispatch using other dispatchers
LOG.warn("Unable to dispatch notification " + notification + " using " + dispatcher, e);
LOG.warn(String.format("Unable to dispatch notification %s using %s", notification, dispatcher), e);
}
}
dispatch(notification, recipients);
@@ -213,4 +203,24 @@ public class NotificationService implements Startable {

return dbClient.propertiesDao().hasProjectNotificationSubscribersForDispatchers(projectUuid, dispatcherKeys);
}

private static class ContextImpl implements NotificationDispatcher.Context {
private final Multimap<String, NotificationChannel> recipients;

public ContextImpl(Multimap<String, NotificationChannel> recipients) {
this.recipients = recipients;
}

@Override
public void addUser(String username) {
// This method is not used anymore
}

@Override
public void addUser(@Nullable String userLogin, NotificationChannel notificationChannel) {
if (userLogin != null) {
recipients.put(userLogin, notificationChannel);
}
}
}
}

+ 2
- 2
sonar-plugin-api/src/main/java/org/sonar/api/measures/Metric.java View File

@@ -789,8 +789,8 @@ public class Metric<G extends Serializable> implements Serializable, org.sonar.a
*/
public <G extends Serializable> Metric<G> create() {
if (ValueType.PERCENT.equals(this.type)) {
this.bestValue = (direction == DIRECTION_BETTER ? 100.0 : 0.0);
this.worstValue = (direction == DIRECTION_BETTER ? 0.0 : 100.0);
this.bestValue = (direction == DIRECTION_BETTER) ? 100.0 : 0.0;
this.worstValue = (direction == DIRECTION_BETTER) ? 0.0 : 100.0;
}
return new Metric<>(this);
}

Loading…
Cancel
Save