NullPointerException when commit property value is null
See original GitHub issueIt is possible to write a commit property whose value is null (in Java).
But when Javers later tries to read/parse this (by calling new JsonPrimitive() on this line), an NPE is thrown because JsonPrimitive doesn’t handle null.
Caused by: java.lang.NullPointerException
at com.google.gson.JsonPrimitive.isPrimitiveOrString(JsonPrimitive.java:278)
at com.google.gson.JsonPrimitive.setValue(JsonPrimitive.java:101)
at com.google.gson.JsonPrimitive.<init>(JsonPrimitive.java:65)
at org.javers.core.json.typeadapter.commit.CommitPropertiesConverter.toJson(CommitPropertiesConverter.java:34)
at org.javers.core.json.typeadapter.commit.CdoSnapshotAssembler.assembleCommitMetadata(CdoSnapshotAssembler.java:72)
at org.javers.core.json.typeadapter.commit.CdoSnapshotAssembler.assemble(CdoSnapshotAssembler.java:22)
at org.javers.core.json.JsonConverter.fromSerializedSnapshot(JsonConverter.java:82)
at org.javers.repository.sql.finders.CdoSnapshotFinder.lambda$fetchCdoSnapshots$3(CdoSnapshotFinder.java:94)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1380)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
at org.javers.common.collections.Lists.transform(Lists.java:68)
at org.javers.repository.sql.finders.CdoSnapshotFinder.fetchCdoSnapshots(CdoSnapshotFinder.java:93)
at org.javers.repository.sql.finders.CdoSnapshotFinder.lambda$getLatest$0(CdoSnapshotFinder.java:54)
at java.util.Optional.map(Optional.java:215)
at org.javers.repository.sql.finders.CdoSnapshotFinder.getLatest(CdoSnapshotFinder.java:52)
at org.javers.repository.sql.JaversSqlRepository.getLatest(JaversSqlRepository.java:51)
at org.javers.repository.api.JaversExtendedRepository.getLatest(JaversExtendedRepository.java:92)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.HashMap$KeySpliterator.forEachRemaining(HashMap.java:1553)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
at org.javers.core.snapshot.SnapshotGraphFactory.createLatest(SnapshotGraphFactory.java:29)
at org.javers.core.commit.CommitFactory.create(CommitFactory.java:71)
at org.javers.core.JaversCore.commit(JaversCore.java:82)
at org.javers.spring.jpa.JaversTransactionalDecorator.commit(JaversTransactionalDecorator.java:65)
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Javers throws exception when property is null - java
If I commit a User object, if either Person or Address has a null property, Javers fails with the above error. How does...
Read more >NullPointerException when commiting/making roll... - JBoss.org
RuntimeException: Unable to commit the transaction caused by NullPointerException. ... But the property is there so I am wondering why.
Read more >How to Fix and Avoid NullPointerException in Java - Rollbar
NullPointerException in Java occurs when a variable is accessed which is not pointing to any object and refers to nothing or null.
Read more >How can I resolve Null pointer exception in my transaction ...
I get null pointer exception when I try my Server ......20_txnmgr_conf.xml ... <property name="persistent-space" value="jdbm:MyTxnSpace" />.
Read more >System.setProperty(key, value) does not accept null value
If value is null, System.setProperty(key, value) will throw NullPointerException. This behavior is not on the spec and makes it difficult to remove a...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

fix released in 3.7.7
so we need to filter out all keys with null values