]> source.dussan.org Git - sonarqube.git/commitdiff
Fix some quality flaws
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Fri, 20 Mar 2015 10:51:54 +0000 (11:51 +0100)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Fri, 20 Mar 2015 10:51:54 +0000 (11:51 +0100)
server/sonar-server/src/main/java/org/sonar/server/activity/index/ActivityResultSetIterator.java
server/sonar-server/src/main/java/org/sonar/server/source/index/SourceFileResultSetIterator.java
server/sonar-server/src/test/java/org/sonar/server/util/DateCollectorTest.java

index 9bb8cdd7b359c2574354f98c367ecf39ab2c8afe..8a292c0e8f3b6a187875e9c2ecb35027d3a67f7d 100644 (file)
@@ -19,6 +19,7 @@
  */
 package org.sonar.server.activity.index;
 
+import org.apache.commons.io.Charsets;
 import org.apache.commons.lang.StringUtils;
 import org.elasticsearch.action.update.UpdateRequest;
 import org.sonar.api.utils.KeyValueFormat;
@@ -80,7 +81,7 @@ class ActivityResultSetIterator extends ResultSetIterator<UpdateRequest> {
   protected UpdateRequest read(ResultSet rs) throws SQLException {
     ByteArrayOutputStream bytes = new ByteArrayOutputStream();
     // all the fields must be present, even if value is null
-    JsonWriter writer = JsonWriter.of(new OutputStreamWriter(bytes)).setSerializeNulls(true);
+    JsonWriter writer = JsonWriter.of(new OutputStreamWriter(bytes, Charsets.UTF_8)).setSerializeNulls(true);
     writer.beginObject();
     String key = rs.getString(1);
     writer.prop(ActivityIndexDefinition.FIELD_KEY, key);
index cf346eaf8b0d49fba4b880cd017723391bcc2f33..a662fa02207950913f7b19bea2cfcef8214fc4a0 100644 (file)
@@ -19,6 +19,7 @@
  */
 package org.sonar.server.source.index;
 
+import org.apache.commons.io.Charsets;
 import org.apache.commons.lang.StringUtils;
 import org.elasticsearch.action.update.UpdateRequest;
 import org.sonar.api.utils.text.JsonWriter;
@@ -117,7 +118,7 @@ public class SourceFileResultSetIterator extends ResultSetIterator<SourceFileRes
       ByteArrayOutputStream bytes = new ByteArrayOutputStream();
 
       // all the fields must be present, even if value is null
-      JsonWriter writer = JsonWriter.of(new OutputStreamWriter(bytes)).setSerializeNulls(true);
+      JsonWriter writer = JsonWriter.of(new OutputStreamWriter(bytes, Charsets.UTF_8)).setSerializeNulls(true);
       writer.beginObject();
       writer.prop(SourceLineIndexDefinition.FIELD_PROJECT_UUID, projectUuid);
       writer.prop(SourceLineIndexDefinition.FIELD_FILE_UUID, fileUuid);
index da7369eee7f50e2369b0d19808464612ecf8218d..9b7a28d8859343cf81b83679ac8184dabc3fab16 100644 (file)
@@ -36,6 +36,7 @@ public class DateCollectorTest {
   @Test
   public void max() throws Exception {
     collector.add(DateUtils.parseDate("2013-06-01"));
+    collector.add(null);
     collector.add(DateUtils.parseDate("2014-01-01"));
     collector.add(DateUtils.parseDate("2013-08-01"));