From 032847976c0cba7c131e95aa6608882987f1eca8 Mon Sep 17 00:00:00 2001 From: Jake Wharton Date: Wed, 17 Jun 2015 22:00:03 -0400 Subject: [PATCH] There is no I/O writing to a StringWriter. --- gson/src/main/java/com/google/gson/TypeAdapter.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gson/src/main/java/com/google/gson/TypeAdapter.java b/gson/src/main/java/com/google/gson/TypeAdapter.java index 58dd6424..4646d271 100644 --- a/gson/src/main/java/com/google/gson/TypeAdapter.java +++ b/gson/src/main/java/com/google/gson/TypeAdapter.java @@ -211,9 +211,13 @@ public abstract class TypeAdapter { * @param value the Java object to convert. May be null. * @since 2.2 */ - public final String toJson(T value) throws IOException { + public final String toJson(T value) { StringWriter stringWriter = new StringWriter(); - toJson(stringWriter, value); + try { + toJson(stringWriter, value); + } catch (IOException e) { + throw new AssertionError(e); // No I/O writing to a StringWriter. + } return stringWriter.toString(); }