Skip to content

Commit 9307737

Browse files
author
talhadilber
committed
Fix: null Instant gson parse error fixed.
1 parent 0002ec5 commit 9307737

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/test/java/com/beyt/TestUtil.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
77
import com.google.gson.*;
88
import com.google.gson.stream.JsonReader;
9+
import com.google.gson.stream.JsonToken;
910
import com.google.gson.stream.JsonWriter;
1011
import org.apache.logging.log4j.util.Strings;
1112
import org.hamcrest.Description;
@@ -46,7 +47,11 @@ public void write(JsonWriter out, Instant value) throws IOException {
4647

4748
@Override
4849
public Instant read(JsonReader in) throws IOException {
49-
// FIXME thrown exception when date is null
50+
if (in.peek() == JsonToken.NULL) {
51+
in.nextNull();
52+
return null;
53+
}
54+
5055
String nextString = in.nextString();
5156
if (Strings.isBlank(nextString)) {
5257
return null;

0 commit comments

Comments
 (0)