From dbb037f55331e76b8be24bcdb052d46b152a95a0 Mon Sep 17 00:00:00 2001 From: jason Date: Thu, 14 Dec 2023 13:35:29 +0000 Subject: [PATCH] fix(json): NaN & Infinity values omitted instead of causing invalid error reports --- CHANGELOG.md | 9 +- .../java/com/bugsnag/android/JsonWriter.java | 43 +-- .../com/bugsnag/android/JsonWriterTest.java | 276 +++++++++--------- 3 files changed, 179 insertions(+), 149 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 932d455415..ea6c89da82 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## TBD + +### Bug fixes + +* Metadata that includes non-finite doubles (NaN, +Infinity, -Infinity) are omitted instead of breaking serialization + []() + ## 6.1.0 (2023-12-05) ### Enhancements @@ -9,7 +16,7 @@ ### Bug fixes -* Updating existing feature flags no longer causes them to change location. +* Updating existing feature-flags flags no longer causes them to change location. [#1940](https://github.com/bugsnag/bugsnag-android/pull/1940) * Fixed possible NDK crash when constructing several concurrent `Client` instances [#1950](https://github.com/bugsnag/bugsnag-android/pull/1950) diff --git a/bugsnag-android-core/src/main/java/com/bugsnag/android/JsonWriter.java b/bugsnag-android-core/src/main/java/com/bugsnag/android/JsonWriter.java index 3e352b713d..cb4fdddb43 100644 --- a/bugsnag-android-core/src/main/java/com/bugsnag/android/JsonWriter.java +++ b/bugsnag-android-core/src/main/java/com/bugsnag/android/JsonWriter.java @@ -145,6 +145,7 @@ class JsonWriter implements Closeable, Flushable { */ private static final String[] REPLACEMENT_CHARS; private static final String[] HTML_SAFE_REPLACEMENT_CHARS; + static { REPLACEMENT_CHARS = new String[128]; for (int i = 0; i <= 0x1f; i++) { @@ -165,11 +166,14 @@ class JsonWriter implements Closeable, Flushable { HTML_SAFE_REPLACEMENT_CHARS['\''] = "\\u0027"; } - /** The output data, containing at most one top-level array or object. */ + /** + * The output data, containing at most one top-level array or object. + */ private final Writer out; private int[] stack = new int[32]; private int stackSize = 0; + { push(EMPTY_DOCUMENT); } @@ -337,7 +341,7 @@ private JsonWriter open(int empty, String openBracket) throws IOException { * given bracket. */ private JsonWriter close(int empty, int nonempty, String closeBracket) - throws IOException { + throws IOException { int context = peek(); if (context != nonempty && context != empty) { throw new IllegalStateException("Nesting problem."); @@ -437,7 +441,7 @@ public JsonWriter jsonValue(String value) throws IOException { } writeDeferredName(); beforeValue(); - out.append(value); + out.write(value); return this; } @@ -490,17 +494,18 @@ public JsonWriter value(Boolean value) throws IOException { /** * Encodes {@code value}. * - * @param value a finite value. May not be {@link Double#isNaN() NaNs} or - * {@link Double#isInfinite() infinities}. + * @param value a finite value. * @return this writer. */ public JsonWriter value(double value) throws IOException { - writeDeferredName(); if (!lenient && (Double.isNaN(value) || Double.isInfinite(value))) { - throw new IllegalArgumentException("Numeric values must be finite, but was " + value); + // omit these values instead of attempting to write them + deferredName = null; + } else { + writeDeferredName(); + beforeValue(); + out.write(Double.toString(value)); } - beforeValue(); - out.append(Double.toString(value)); return this; } @@ -520,7 +525,7 @@ public JsonWriter value(long value) throws IOException { * Encodes {@code value}. * * @param value a finite value. May not be {@link Double#isNaN() NaNs} or - * {@link Double#isInfinite() infinities}. + * {@link Double#isInfinite() infinities}. * @return this writer. */ public JsonWriter value(Number value) throws IOException { @@ -528,14 +533,16 @@ public JsonWriter value(Number value) throws IOException { return nullValue(); } - writeDeferredName(); String string = value.toString(); if (!lenient - && (string.equals("-Infinity") || string.equals("Infinity") || string.equals("NaN"))) { - throw new IllegalArgumentException("Numeric values must be finite, but was " + value); + && (string.equals("-Infinity") || string.equals("Infinity") || string.equals("NaN"))) { + // omit this value + deferredName = null; + } else { + writeDeferredName(); + beforeValue(); + out.write(string); } - beforeValue(); - out.append(string); return this; } @@ -634,7 +641,7 @@ void beforeValue() throws IOException { case NONEMPTY_DOCUMENT: if (!lenient) { throw new IllegalStateException( - "JSON must have only one top-level value."); + "JSON must have only one top-level value."); } // fall-through case EMPTY_DOCUMENT: // first in document @@ -647,12 +654,12 @@ void beforeValue() throws IOException { break; case NONEMPTY_ARRAY: // another in array - out.append(','); + out.write(','); newline(); break; case DANGLING_NAME: // value for name - out.append(separator); + out.write(separator); replaceTop(NONEMPTY_OBJECT); break; diff --git a/bugsnag-android-core/src/test/java/com/bugsnag/android/JsonWriterTest.java b/bugsnag-android-core/src/test/java/com/bugsnag/android/JsonWriterTest.java index 65239da116..d0db16b614 100644 --- a/bugsnag-android-core/src/test/java/com/bugsnag/android/JsonWriterTest.java +++ b/bugsnag-android-core/src/test/java/com/bugsnag/android/JsonWriterTest.java @@ -76,7 +76,8 @@ public void testTopLevelValueTypes() throws IOException { // method monkey-patch assertEquals("{\"a\":\"a\"}", string5.toString()); } - @Test public void testInvalidTopLevelTypes() throws IOException { + @Test + public void testInvalidTopLevelTypes() throws IOException { StringWriter stringWriter = new StringWriter(); JsonWriter jsonWriter = new JsonWriter(stringWriter); jsonWriter.name("hello"); @@ -87,7 +88,8 @@ public void testTopLevelValueTypes() throws IOException { // method monkey-patch } } - @Test public void testTwoNames() throws IOException { + @Test + public void testTwoNames() throws IOException { StringWriter stringWriter = new StringWriter(); JsonWriter jsonWriter = new JsonWriter(stringWriter); jsonWriter.beginObject(); @@ -99,7 +101,8 @@ public void testTopLevelValueTypes() throws IOException { // method monkey-patch } } - @Test public void testNameWithoutValue() throws IOException { + @Test + public void testNameWithoutValue() throws IOException { StringWriter stringWriter = new StringWriter(); JsonWriter jsonWriter = new JsonWriter(stringWriter); jsonWriter.beginObject(); @@ -111,7 +114,8 @@ public void testTopLevelValueTypes() throws IOException { // method monkey-patch } } - @Test public void testValueWithoutName() throws IOException { + @Test + public void testValueWithoutName() throws IOException { StringWriter stringWriter = new StringWriter(); JsonWriter jsonWriter = new JsonWriter(stringWriter); jsonWriter.beginObject(); @@ -122,7 +126,8 @@ public void testTopLevelValueTypes() throws IOException { // method monkey-patch } } - @Test public void testMultipleTopLevelValues() throws IOException { + @Test + public void testMultipleTopLevelValues() throws IOException { StringWriter stringWriter = new StringWriter(); JsonWriter jsonWriter = new JsonWriter(stringWriter); jsonWriter.beginArray().endArray(); @@ -133,7 +138,8 @@ public void testTopLevelValueTypes() throws IOException { // method monkey-patch } } - @Test public void testBadNestingObject() throws IOException { + @Test + public void testBadNestingObject() throws IOException { StringWriter stringWriter = new StringWriter(); JsonWriter jsonWriter = new JsonWriter(stringWriter); jsonWriter.beginArray(); @@ -145,7 +151,8 @@ public void testTopLevelValueTypes() throws IOException { // method monkey-patch } } - @Test public void testBadNestingArray() throws IOException { + @Test + public void testBadNestingArray() throws IOException { StringWriter stringWriter = new StringWriter(); JsonWriter jsonWriter = new JsonWriter(stringWriter); jsonWriter.beginArray(); @@ -157,7 +164,8 @@ public void testTopLevelValueTypes() throws IOException { // method monkey-patch } } - @Test public void testNullName() throws IOException { + @Test + public void testNullName() throws IOException { StringWriter stringWriter = new StringWriter(); JsonWriter jsonWriter = new JsonWriter(stringWriter); jsonWriter.beginObject(); @@ -168,7 +176,8 @@ public void testTopLevelValueTypes() throws IOException { // method monkey-patch } } - @Test public void testNullStringValue() throws IOException { + @Test + public void testNullStringValue() throws IOException { StringWriter stringWriter = new StringWriter(); JsonWriter jsonWriter = new JsonWriter(stringWriter); jsonWriter.beginObject(); @@ -178,49 +187,32 @@ public void testTopLevelValueTypes() throws IOException { // method monkey-patch assertEquals("{\"a\":null}", stringWriter.toString()); } - @Test public void testNonFiniteDoubles() throws IOException { + @Test + public void testNonFiniteDoubles() throws IOException { StringWriter stringWriter = new StringWriter(); JsonWriter jsonWriter = new JsonWriter(stringWriter); jsonWriter.beginArray(); - try { - jsonWriter.value(Double.NaN); - fail(); - } catch (IllegalArgumentException expected) { - } - try { - jsonWriter.value(Double.NEGATIVE_INFINITY); - fail(); - } catch (IllegalArgumentException expected) { - } - try { - jsonWriter.value(Double.POSITIVE_INFINITY); - fail(); - } catch (IllegalArgumentException expected) { - } + jsonWriter.value(Double.NaN); + jsonWriter.value(Double.NEGATIVE_INFINITY); + jsonWriter.value(Double.POSITIVE_INFINITY); + jsonWriter.endArray(); + assertEquals("[]", stringWriter.toString()); } - @Test public void testNonFiniteBoxedDoubles() throws IOException { + @Test + public void testNonFiniteBoxedDoubles() throws IOException { StringWriter stringWriter = new StringWriter(); JsonWriter jsonWriter = new JsonWriter(stringWriter); jsonWriter.beginArray(); - try { - jsonWriter.value(Double.valueOf(Double.NaN)); - fail(); - } catch (IllegalArgumentException expected) { - } - try { - jsonWriter.value(Double.valueOf(Double.NEGATIVE_INFINITY)); - fail(); - } catch (IllegalArgumentException expected) { - } - try { - jsonWriter.value(Double.valueOf(Double.POSITIVE_INFINITY)); - fail(); - } catch (IllegalArgumentException expected) { - } + jsonWriter.value(Double.valueOf(Double.NaN)); + jsonWriter.value(Double.valueOf(Double.NEGATIVE_INFINITY)); + jsonWriter.value(Double.valueOf(Double.POSITIVE_INFINITY)); + jsonWriter.endArray(); + assertEquals("[]", stringWriter.toString()); } - @Test public void testNonFiniteBoxedDoublesWhenLenient() throws IOException { + @Test + public void testNonFiniteBoxedDoublesWhenLenient() throws IOException { StringWriter stringWriter = new StringWriter(); JsonWriter jsonWriter = new JsonWriter(stringWriter); jsonWriter.setLenient(true); @@ -232,7 +224,8 @@ public void testTopLevelValueTypes() throws IOException { // method monkey-patch assertEquals("[NaN,-Infinity,Infinity]", stringWriter.toString()); } - @Test public void testDoubles() throws IOException { + @Test + public void testDoubles() throws IOException { StringWriter stringWriter = new StringWriter(); JsonWriter jsonWriter = new JsonWriter(stringWriter); jsonWriter.beginArray(); @@ -248,17 +241,18 @@ public void testTopLevelValueTypes() throws IOException { // method monkey-patch jsonWriter.endArray(); jsonWriter.close(); assertEquals("[-0.0," - + "1.0," - + "1.7976931348623157E308," - + "4.9E-324," - + "0.0," - + "-0.5," - + "2.2250738585072014E-308," - + "3.141592653589793," - + "2.718281828459045]", stringWriter.toString()); + + "1.0," + + "1.7976931348623157E308," + + "4.9E-324," + + "0.0," + + "-0.5," + + "2.2250738585072014E-308," + + "3.141592653589793," + + "2.718281828459045]", stringWriter.toString()); } - @Test public void testLongs() throws IOException { + @Test + public void testLongs() throws IOException { StringWriter stringWriter = new StringWriter(); JsonWriter jsonWriter = new JsonWriter(stringWriter); jsonWriter.beginArray(); @@ -270,13 +264,14 @@ public void testTopLevelValueTypes() throws IOException { // method monkey-patch jsonWriter.endArray(); jsonWriter.close(); assertEquals("[0," - + "1," - + "-1," - + "-9223372036854775808," - + "9223372036854775807]", stringWriter.toString()); + + "1," + + "-1," + + "-9223372036854775808," + + "9223372036854775807]", stringWriter.toString()); } - @Test public void testNumbers() throws IOException { + @Test + public void testNumbers() throws IOException { StringWriter stringWriter = new StringWriter(); JsonWriter jsonWriter = new JsonWriter(stringWriter); jsonWriter.beginArray(); @@ -287,12 +282,13 @@ public void testTopLevelValueTypes() throws IOException { // method monkey-patch jsonWriter.endArray(); jsonWriter.close(); assertEquals("[0," - + "9223372036854775808," - + "-9223372036854775809," - + "3.141592653589793238462643383]", stringWriter.toString()); + + "9223372036854775808," + + "-9223372036854775809," + + "3.141592653589793238462643383]", stringWriter.toString()); } - @Test public void testBooleans() throws IOException { + @Test + public void testBooleans() throws IOException { StringWriter stringWriter = new StringWriter(); JsonWriter jsonWriter = new JsonWriter(stringWriter); jsonWriter.beginArray(); @@ -302,7 +298,8 @@ public void testTopLevelValueTypes() throws IOException { // method monkey-patch assertEquals("[true,false]", stringWriter.toString()); } - @Test public void testBoxedBooleans() throws IOException { + @Test + public void testBoxedBooleans() throws IOException { StringWriter stringWriter = new StringWriter(); JsonWriter jsonWriter = new JsonWriter(stringWriter); jsonWriter.beginArray(); @@ -313,7 +310,8 @@ public void testTopLevelValueTypes() throws IOException { // method monkey-patch assertEquals("[true,false,null]", stringWriter.toString()); } - @Test public void testNulls() throws IOException { + @Test + public void testNulls() throws IOException { StringWriter stringWriter = new StringWriter(); JsonWriter jsonWriter = new JsonWriter(stringWriter); jsonWriter.beginArray(); @@ -323,7 +321,8 @@ public void testTopLevelValueTypes() throws IOException { // method monkey-patch } @SuppressWarnings("AvoidEscapedUnicodeCharacters") - @Test public void testStrings() throws IOException { + @Test + public void testStrings() throws IOException { StringWriter stringWriter = new StringWriter(); JsonWriter jsonWriter = new JsonWriter(stringWriter); jsonWriter.beginArray(); @@ -347,26 +346,27 @@ public void testTopLevelValueTypes() throws IOException { // method monkey-patch jsonWriter.value("\u0019"); jsonWriter.endArray(); assertEquals("[\"a\"," - + "\"a\\\"\"," - + "\"\\\"\"," - + "\":\"," - + "\",\"," - + "\"\\b\"," - + "\"\\f\"," - + "\"\\n\"," - + "\"\\r\"," - + "\"\\t\"," - + "\" \"," - + "\"\\\\\"," - + "\"{\"," - + "\"}\"," - + "\"[\"," - + "\"]\"," - + "\"\\u0000\"," - + "\"\\u0019\"]", stringWriter.toString()); - } - - @Test public void testUnicodeLineBreaksEscaped() throws IOException { + + "\"a\\\"\"," + + "\"\\\"\"," + + "\":\"," + + "\",\"," + + "\"\\b\"," + + "\"\\f\"," + + "\"\\n\"," + + "\"\\r\"," + + "\"\\t\"," + + "\" \"," + + "\"\\\\\"," + + "\"{\"," + + "\"}\"," + + "\"[\"," + + "\"]\"," + + "\"\\u0000\"," + + "\"\\u0019\"]", stringWriter.toString()); + } + + @Test + public void testUnicodeLineBreaksEscaped() throws IOException { StringWriter stringWriter = new StringWriter(); JsonWriter jsonWriter = new JsonWriter(stringWriter); jsonWriter.beginArray(); @@ -375,7 +375,8 @@ public void testTopLevelValueTypes() throws IOException { // method monkey-patch assertEquals("[\"\\u2028 \\u2029\"]", stringWriter.toString()); } - @Test public void testEmptyArray() throws IOException { + @Test + public void testEmptyArray() throws IOException { StringWriter stringWriter = new StringWriter(); JsonWriter jsonWriter = new JsonWriter(stringWriter); jsonWriter.beginArray(); @@ -383,7 +384,8 @@ public void testTopLevelValueTypes() throws IOException { // method monkey-patch assertEquals("[]", stringWriter.toString()); } - @Test public void testEmptyObject() throws IOException { + @Test + public void testEmptyObject() throws IOException { StringWriter stringWriter = new StringWriter(); JsonWriter jsonWriter = new JsonWriter(stringWriter); jsonWriter.beginObject(); @@ -391,7 +393,8 @@ public void testTopLevelValueTypes() throws IOException { // method monkey-patch assertEquals("{}", stringWriter.toString()); } - @Test public void testObjectsInArrays() throws IOException { + @Test + public void testObjectsInArrays() throws IOException { StringWriter stringWriter = new StringWriter(); JsonWriter jsonWriter = new JsonWriter(stringWriter); jsonWriter.beginArray(); @@ -405,10 +408,11 @@ public void testTopLevelValueTypes() throws IOException { // method monkey-patch jsonWriter.endObject(); jsonWriter.endArray(); assertEquals("[{\"a\":5,\"b\":false}," - + "{\"c\":6,\"d\":true}]", stringWriter.toString()); + + "{\"c\":6,\"d\":true}]", stringWriter.toString()); } - @Test public void testArraysInObjects() throws IOException { + @Test + public void testArraysInObjects() throws IOException { StringWriter stringWriter = new StringWriter(); JsonWriter jsonWriter = new JsonWriter(stringWriter); jsonWriter.beginObject(); @@ -424,10 +428,11 @@ public void testTopLevelValueTypes() throws IOException { // method monkey-patch jsonWriter.endArray(); jsonWriter.endObject(); assertEquals("{\"a\":[5,false]," - + "\"b\":[6,true]}", stringWriter.toString()); + + "\"b\":[6,true]}", stringWriter.toString()); } - @Test public void testDeepNestingArrays() throws IOException { + @Test + public void testDeepNestingArrays() throws IOException { StringWriter stringWriter = new StringWriter(); JsonWriter jsonWriter = new JsonWriter(stringWriter); for (int i = 0; i < 20; i++) { @@ -439,7 +444,8 @@ public void testTopLevelValueTypes() throws IOException { // method monkey-patch assertEquals("[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]", stringWriter.toString()); } - @Test public void testDeepNestingObjects() throws IOException { + @Test + public void testDeepNestingObjects() throws IOException { StringWriter stringWriter = new StringWriter(); JsonWriter jsonWriter = new JsonWriter(stringWriter); jsonWriter.beginObject(); @@ -452,11 +458,12 @@ public void testTopLevelValueTypes() throws IOException { // method monkey-patch } jsonWriter.endObject(); assertEquals("{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":" - + "{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{" - + "}}}}}}}}}}}}}}}}}}}}}", stringWriter.toString()); + + "{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{\"a\":{" + + "}}}}}}}}}}}}}}}}}}}}}", stringWriter.toString()); } - @Test public void testRepeatedName() throws IOException { + @Test + public void testRepeatedName() throws IOException { StringWriter stringWriter = new StringWriter(); JsonWriter jsonWriter = new JsonWriter(stringWriter); jsonWriter.beginObject(); @@ -467,7 +474,8 @@ public void testTopLevelValueTypes() throws IOException { // method monkey-patch assertEquals("{\"a\":true,\"a\":false}", stringWriter.toString()); } - @Test public void testPrettyPrintObject() throws IOException { + @Test + public void testPrettyPrintObject() throws IOException { StringWriter stringWriter = new StringWriter(); JsonWriter jsonWriter = new JsonWriter(stringWriter); jsonWriter.setIndent(" "); @@ -488,23 +496,24 @@ public void testTopLevelValueTypes() throws IOException { // method monkey-patch jsonWriter.endObject(); String expected = "{\n" - + " \"a\": true,\n" - + " \"b\": false,\n" - + " \"c\": 5.0,\n" - + " \"e\": null,\n" - + " \"f\": [\n" - + " 6.0,\n" - + " 7.0\n" - + " ],\n" - + " \"g\": {\n" - + " \"h\": 8.0,\n" - + " \"i\": 9.0\n" - + " }\n" - + "}"; + + " \"a\": true,\n" + + " \"b\": false,\n" + + " \"c\": 5.0,\n" + + " \"e\": null,\n" + + " \"f\": [\n" + + " 6.0,\n" + + " 7.0\n" + + " ],\n" + + " \"g\": {\n" + + " \"h\": 8.0,\n" + + " \"i\": 9.0\n" + + " }\n" + + "}"; assertEquals(expected, stringWriter.toString()); } - @Test public void testPrettyPrintArray() throws IOException { + @Test + public void testPrettyPrintArray() throws IOException { StringWriter stringWriter = new StringWriter(); JsonWriter jsonWriter = new JsonWriter(stringWriter); jsonWriter.setIndent(" "); @@ -525,23 +534,24 @@ public void testTopLevelValueTypes() throws IOException { // method monkey-patch jsonWriter.endArray(); String expected = "[\n" - + " true,\n" - + " false,\n" - + " 5.0,\n" - + " null,\n" - + " {\n" - + " \"a\": 6.0,\n" - + " \"b\": 7.0\n" - + " },\n" - + " [\n" - + " 8.0,\n" - + " 9.0\n" - + " ]\n" - + "]"; + + " true,\n" + + " false,\n" + + " 5.0,\n" + + " null,\n" + + " {\n" + + " \"a\": 6.0,\n" + + " \"b\": 7.0\n" + + " },\n" + + " [\n" + + " 8.0,\n" + + " 9.0\n" + + " ]\n" + + "]"; assertEquals(expected, stringWriter.toString()); } - @Test public void testLenientWriterPermitsMultipleTopLevelValues() throws IOException { + @Test + public void testLenientWriterPermitsMultipleTopLevelValues() throws IOException { StringWriter stringWriter = new StringWriter(); JsonWriter writer = new JsonWriter(stringWriter); writer.setLenient(true); @@ -553,7 +563,8 @@ public void testTopLevelValueTypes() throws IOException { // method monkey-patch assertEquals("[][]", stringWriter.toString()); } - @Test public void testStrictWriterDoesNotPermitMultipleTopLevelValues() throws IOException { + @Test + public void testStrictWriterDoesNotPermitMultipleTopLevelValues() throws IOException { StringWriter stringWriter = new StringWriter(); JsonWriter writer = new JsonWriter(stringWriter); writer.beginArray(); @@ -565,7 +576,8 @@ public void testTopLevelValueTypes() throws IOException { // method monkey-patch } } - @Test public void testClosedWriterThrowsOnStructure() throws IOException { + @Test + public void testClosedWriterThrowsOnStructure() throws IOException { StringWriter stringWriter = new StringWriter(); JsonWriter writer = new JsonWriter(stringWriter); writer.beginArray(); @@ -593,7 +605,8 @@ public void testTopLevelValueTypes() throws IOException { // method monkey-patch } } - @Test public void testClosedWriterThrowsOnName() throws IOException { + @Test + public void testClosedWriterThrowsOnName() throws IOException { StringWriter stringWriter = new StringWriter(); JsonWriter writer = new JsonWriter(stringWriter); writer.beginArray(); @@ -606,7 +619,8 @@ public void testTopLevelValueTypes() throws IOException { // method monkey-patch } } - @Test public void testClosedWriterThrowsOnValue() throws IOException { + @Test + public void testClosedWriterThrowsOnValue() throws IOException { StringWriter stringWriter = new StringWriter(); JsonWriter writer = new JsonWriter(stringWriter); writer.beginArray(); @@ -619,7 +633,8 @@ public void testTopLevelValueTypes() throws IOException { // method monkey-patch } } - @Test public void testClosedWriterThrowsOnFlush() throws IOException { + @Test + public void testClosedWriterThrowsOnFlush() throws IOException { StringWriter stringWriter = new StringWriter(); JsonWriter writer = new JsonWriter(stringWriter); writer.beginArray(); @@ -632,7 +647,8 @@ public void testTopLevelValueTypes() throws IOException { // method monkey-patch } } - @Test public void testWriterCloseIsIdempotent() throws IOException { + @Test + public void testWriterCloseIsIdempotent() throws IOException { StringWriter stringWriter = new StringWriter(); JsonWriter writer = new JsonWriter(stringWriter); writer.beginArray();