]> source.dussan.org Git - sonarqube.git/commitdiff
Fix quality flaws
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Thu, 24 Mar 2016 21:38:16 +0000 (22:38 +0100)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Thu, 24 Mar 2016 21:38:16 +0000 (22:38 +0100)
server/sonar-server/src/main/java/org/sonar/server/ws/WsUtils.java
sonar-plugin-api/src/main/java/org/sonar/api/utils/Duration.java

index 66d172e808a8ceab92bbbae8fb8d12afbe4ef2b8..60df0574a76afa08fc2499a1ac708b367dd88c97 100644 (file)
@@ -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));
         }
       }
index cd397e3df94aee72d13a03e5deb52860722e4c31..554ff4d6a54f026ac985d0170a90f067a88bae6c 100644 (file)
  */
 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);
   }
 
   /**