aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2016-09-30 23:10:28 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2016-09-30 23:10:28 +0200
commitc89efd188daf9a0b54faa64bec9d8a514b5e0928 (patch)
treeeb8daca161fc8dde0b31c36031bf076fe2d1caee
parent6f621785d7218218432a641e2cbf460763c768f8 (diff)
downloadsonarqube-c89efd188daf9a0b54faa64bec9d8a514b5e0928.tar.gz
sonarqube-c89efd188daf9a0b54faa64bec9d8a514b5e0928.zip
SONAR-8148 do not log data and decrease log level to debug
-rw-r--r--sonar-db/src/main/java/org/sonar/db/version/v51/FeedFileSourcesBinaryData.java5
-rw-r--r--sonar-db/src/test/java/org/sonar/db/version/v51/FeedFileSourcesBinaryDataTest.java9
2 files changed, 12 insertions, 2 deletions
diff --git a/sonar-db/src/main/java/org/sonar/db/version/v51/FeedFileSourcesBinaryData.java b/sonar-db/src/main/java/org/sonar/db/version/v51/FeedFileSourcesBinaryData.java
index 22c5f649e83..9a6f23047e7 100644
--- a/sonar-db/src/main/java/org/sonar/db/version/v51/FeedFileSourcesBinaryData.java
+++ b/sonar-db/src/main/java/org/sonar/db/version/v51/FeedFileSourcesBinaryData.java
@@ -21,6 +21,7 @@ package org.sonar.db.version.v51;
import com.google.common.base.Function;
import com.google.common.base.Splitter;
+import com.google.common.base.Throwables;
import com.google.common.collect.Iterables;
import java.sql.SQLException;
import java.util.Date;
@@ -148,8 +149,8 @@ public class FeedFileSourcesBinaryData extends BaseDataChange {
}
return FileSourceDto.encodeSourceData(dataBuilder.build());
} catch (Exception e) {
- Loggers.get(FeedFileSourcesBinaryData.class).error(
- String.format("Invalid FILE_SOURCES.DATA on row with ID %s, data will be ignored: %s", fileSourceId, data), e);
+ Loggers.get(FeedFileSourcesBinaryData.class).debug(
+ "Invalid FILE_SOURCES.DATA on row with ID {}, data will be ignored. {}", fileSourceId, Throwables.getStackTraceAsString(e));
return FileSourceDto.encodeSourceData(dataBuilder.clear().build());
} finally {
IOUtils.closeQuietly(parser);
diff --git a/sonar-db/src/test/java/org/sonar/db/version/v51/FeedFileSourcesBinaryDataTest.java b/sonar-db/src/test/java/org/sonar/db/version/v51/FeedFileSourcesBinaryDataTest.java
index 836291c23d3..d96d67b6ac7 100644
--- a/sonar-db/src/test/java/org/sonar/db/version/v51/FeedFileSourcesBinaryDataTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/version/v51/FeedFileSourcesBinaryDataTest.java
@@ -23,11 +23,14 @@ import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.util.List;
import org.apache.commons.dbutils.DbUtils;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.sonar.api.utils.System2;
+import org.sonar.api.utils.log.LogTester;
+import org.sonar.api.utils.log.LoggerLevel;
import org.sonar.db.DbTester;
import org.sonar.db.protobuf.DbFileSources;
import org.sonar.db.source.FileSourceDto;
@@ -43,6 +46,9 @@ public class FeedFileSourcesBinaryDataTest {
@Rule
public DbTester db = DbTester.createForSchema(System2.INSTANCE, FeedFileSourcesBinaryDataTest.class, "schema.sql");
+ @Rule
+ public LogTester logTester = new LogTester().setLevel(LoggerLevel.DEBUG);
+
@Test
public void convert_csv_to_protobuf() throws Exception {
db.prepareDbUnit(getClass(), "data.xml");
@@ -79,6 +85,9 @@ public class FeedFileSourcesBinaryDataTest {
DbFileSources.Data data = selectData(connection, 1L);
assertThat(data.getLinesList()).isEmpty();
+ List<String> debugLogs = logTester.logs(LoggerLevel.DEBUG);
+ assertThat(debugLogs.stream()
+ .anyMatch(s -> s.startsWith("Invalid FILE_SOURCES.DATA on row with ID 1, data will be ignored"))).isTrue();
}
}