-
-
Notifications
You must be signed in to change notification settings - Fork 385
Closed
Labels
Description
I have upgraded our project from Javers 3.12.1 to 5.1.3 and now getting NullPointerException (stacktrace below) when committing entities that have older commits that were done before the upgrade. Committing new entities works well. We are using SqlRepository with postgresql database.
Done a bit of digging into the source code and it looks like exception happens when Javers is deserialising commit_date_instant column value in SnapshotQuery:166 which is always null for older commits.
Here is a relevant part of the stack trace:
java.lang.NullPointerException: text
at java.util.Objects.requireNonNull(Objects.java:228)
at java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1846)
at java.time.Instant.parse(Instant.java:395)
at org.javers.core.json.CdoSnapshotSerialized.withCommitDateInstant(CdoSnapshotSerialized.java:45)
at org.javers.repository.sql.finders.SnapshotQuery$CdoSnapshotMapper.get(SnapshotQuery.java:166)
at org.javers.repository.sql.finders.SnapshotQuery$CdoSnapshotMapper.get(SnapshotQuery.java:160)
at org.javers.repository.sql.session.PreparedStatementExecutor.lambda$executeQuery$5(PreparedStatementExecutor.java:64)
at org.javers.repository.sql.session.PreparedStatementExecutor$$Lambda$1279/63189136.callAndGet(Unknown Source)
at org.javers.repository.sql.session.PreparedStatementExecutor.wrapExceptionAndCall(PreparedStatementExecutor.java:126)
at org.javers.repository.sql.session.PreparedStatementExecutor.runSql(PreparedStatementExecutor.java:100)
at org.javers.repository.sql.session.PreparedStatementExecutor.executeQuery(PreparedStatementExecutor.java:58)
at org.javers.repository.sql.session.Session.executeQuery(Session.java:99)
at org.javers.repository.sql.session.SelectBuilder.executeQuery(SelectBuilder.java:99)
at org.javers.repository.sql.finders.SnapshotQuery.run(SnapshotQuery.java:148)
at org.javers.repository.sql.finders.CdoSnapshotFinder.fetchCdoSnapshots(CdoSnapshotFinder.java:92)
at org.javers.repository.sql.finders.CdoSnapshotFinder.lambda$getLatest$1(CdoSnapshotFinder.java:51)
at org.javers.repository.sql.finders.CdoSnapshotFinder$$Lambda$1270/1714142470.apply(Unknown Source)
at java.util.Optional.map(Optional.java:215)
at org.javers.repository.sql.finders.CdoSnapshotFinder.getLatest(CdoSnapshotFinder.java:46)
at org.javers.repository.sql.JaversSqlRepository.lambda$getLatest$0(JaversSqlRepository.java:72)
at org.javers.repository.sql.JaversSqlRepository$$Lambda$1266/145383050.apply(Unknown Source)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.HashMap$KeySpliterator.forEachRemaining(HashMap.java:1540)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:512)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:502)
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.repository.sql.JaversSqlRepository.getLatest(JaversSqlRepository.java:75)
at org.javers.repository.api.JaversExtendedRepository.getLatest(JaversExtendedRepository.java:98)
at org.javers.core.snapshot.SnapshotGraphFactory.createLatest(SnapshotGraphFactory.java:24)
at org.javers.core.commit.CommitFactory.createCommit(CommitFactory.java:86)
at org.javers.core.commit.CommitFactory.create(CommitFactory.java:75)
at org.javers.core.JaversCore.commit(JaversCore.java:82)