Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ public AtomicIntegerArray read(JsonReader in) throws IOException {
try {
int integer = in.nextInt();
list.add(integer);
} catch (NumberFormatException e) {
} catch (NumberFormatException | IllegalStateException e) {
throw new JsonSyntaxException(e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,22 @@ public void testAtomicIntegerArray() {
assertThat(json).isEqualTo("[10,13,14]");
}

@Test
public void testAtomicIntegerArrayWithNullElement() {
JsonSyntaxException e =
assertThrows(
JsonSyntaxException.class, () -> gson.fromJson("[1,null,3]", AtomicIntegerArray.class));
assertThat(e).hasCauseThat().isInstanceOf(IllegalStateException.class);
}

@Test
public void testAtomicIntegerArrayWithNonNumericElement() {
JsonSyntaxException e =
assertThrows(
JsonSyntaxException.class, () -> gson.fromJson("[1,true,3]", AtomicIntegerArray.class));
assertThat(e).hasCauseThat().isInstanceOf(IllegalStateException.class);
}

@Test
public void testAtomicLongArray() {
AtomicLongArray target = gson.fromJson("[10, 13, 14]", AtomicLongArray.class);
Expand Down