From: Simon Brandhof Date: Thu, 24 Mar 2016 21:38:16 +0000 (+0100) Subject: Fix quality flaws X-Git-Tag: 5.5-M11~13 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=4250bb53f050b5a7f86b211ec2b34f85f7cc3ddc;p=sonarqube.git Fix quality flaws --- diff --git a/server/sonar-server/src/main/java/org/sonar/server/ws/WsUtils.java b/server/sonar-server/src/main/java/org/sonar/server/ws/WsUtils.java index 66d172e808a..60df0574a76 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/ws/WsUtils.java +++ b/server/sonar-server/src/main/java/org/sonar/server/ws/WsUtils.java @@ -24,6 +24,7 @@ import com.google.common.base.Throwables; import com.google.protobuf.Message; import java.io.OutputStream; import java.io.OutputStreamWriter; +import java.nio.charset.StandardCharsets; import javax.annotation.Nullable; import org.apache.commons.io.IOUtils; import org.sonar.api.server.ws.Request; @@ -54,7 +55,7 @@ public class WsUtils { msg.writeTo(output); } else { response.stream().setMediaType(MediaTypes.JSON); - try (OutputStreamWriter writer = new OutputStreamWriter(output)) { + try (OutputStreamWriter writer = new OutputStreamWriter(output, StandardCharsets.UTF_8)) { ProtobufJsonFormat.write(msg, JsonWriter.of(writer)); } } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/Duration.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/Duration.java index cd397e3df94..554ff4d6a54 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/Duration.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/Duration.java @@ -19,15 +19,13 @@ */ package org.sonar.api.utils; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.lang.builder.ToStringBuilder; -import org.apache.commons.lang.builder.ToStringStyle; - -import javax.annotation.Nullable; - import java.io.Serializable; import java.util.regex.Matcher; import java.util.regex.Pattern; +import javax.annotation.Nullable; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang.builder.ToStringBuilder; +import org.apache.commons.lang.builder.ToStringStyle; /** * @since 4.3 @@ -47,7 +45,7 @@ public class Duration implements Serializable { } private Duration(int days, int hours, int minutes, int hoursInDay) { - this((days * hoursInDay * MINUTES_IN_ONE_HOUR) + (hours * MINUTES_IN_ONE_HOUR) + minutes); + this(((long) days * hoursInDay * MINUTES_IN_ONE_HOUR) + (hours * MINUTES_IN_ONE_HOUR) + minutes); } /**