Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Null field of type LocalDateTime fails JSON verification #531

Closed
mikybars opened this issue Jul 8, 2024 · 0 comments
Closed

Null field of type LocalDateTime fails JSON verification #531

mikybars opened this issue Jul 8, 2024 · 0 comments

Comments

@mikybars
Copy link

mikybars commented Jul 8, 2024

I get this error when I use JsonApprovals.verifyAsJson() on an object with a null field of type LocalDateTime:

Cannot invoke "java.time.LocalDateTime.toString()" because "instant" is null
java.lang.NullPointerException: Cannot invoke "java.time.LocalDateTime.toString()" because "instant" is null
	at com.spun.util.JsonUtils$LocalDateTimeAdapter.write(JsonUtils.java:115)
	at com.spun.util.JsonUtils$LocalDateTimeAdapter.write(JsonUtils.java:110)
	at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRuntimeTypeWrapper.java:70)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.write(ReflectiveTypeAdapterFactory.java:196)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.write(ReflectiveTypeAdapterFactory.java:368)
	at com.google.gson.Gson.toJson(Gson.java:842)
	at com.google.gson.Gson.toJson(Gson.java:812)
	at com.google.gson.Gson.toJson(Gson.java:759)
	at com.google.gson.Gson.toJson(Gson.java:736)
	at com.spun.util.JsonUtils.asJson(JsonUtils.java:53)
	at com.spun.util.JsonUtils.asJson(JsonUtils.java:38)
	at org.approvaltests.JsonApprovals.verifyAsJson(JsonApprovals.java:46)
	at org.approvaltests.JsonApprovals.verifyAsJson(JsonApprovals.java:33)

I tried "regular verification" with Approvals.verify() and it works well. I'd expect both to be consistent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant