aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2016-07-12 16:00:13 +0200
committerJulien Lancelot <julien.lancelot@sonarsource.com>2016-07-12 16:00:13 +0200
commit1c1fb04a3997dc6ed6e1b9c9006d591bcde6e269 (patch)
tree77cd57580b892032168207243a2d5b11793b4c48 /sonar-plugin-api
parent6bffda848ed609d1761de69db7f7360c02172719 (diff)
downloadsonarqube-1c1fb04a3997dc6ed6e1b9c9006d591bcde6e269.tar.gz
sonarqube-1c1fb04a3997dc6ed6e1b9c9006d591bcde6e269.zip
Do not hide exception when fail to close json
Diffstat (limited to 'sonar-plugin-api')
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/utils/text/JsonWriter.java3
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/utils/text/JsonWriterTest.java11
2 files changed, 6 insertions, 8 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/text/JsonWriter.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/text/JsonWriter.java
index bea1dcc2d27..de3b3cd988d 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/text/JsonWriter.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/text/JsonWriter.java
@@ -382,8 +382,7 @@ public class JsonWriter {
}
private static IllegalStateException rethrow(Exception e) {
- // stacktrace is not helpful
- throw new WriterException("Fail to write JSON: " + e.getMessage());
+ throw new WriterException("Fail to write JSON", e);
}
@Nullable
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/utils/text/JsonWriterTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/utils/text/JsonWriterTest.java
index 8c853620404..0ed59a44c00 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/utils/text/JsonWriterTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/utils/text/JsonWriterTest.java
@@ -20,17 +20,16 @@
package org.sonar.api.utils.text;
import com.google.common.collect.ImmutableMap;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.sonar.api.utils.DateUtils;
-
import java.io.IOException;
import java.io.StringWriter;
import java.util.Arrays;
import java.util.Date;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.sonar.api.utils.DateUtils;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.fail;
@@ -208,7 +207,7 @@ public class JsonWriterTest {
com.google.gson.stream.JsonWriter gson = mock(com.google.gson.stream.JsonWriter.class);
when(gson.beginArray()).thenThrow(new IOException("the reason"));
thrown.expect(WriterException.class);
- thrown.expectMessage("Fail to write JSON: the reason");
+ thrown.expectMessage("Fail to write JSON");
new JsonWriter(gson).beginArray();
}