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

java.lang.ClassCastException: class org.javers.core.metamodel.property.MissingProperty cannot be cast to class java.util.List #851

Closed
tim-ber opened this issue Jun 13, 2019 · 3 comments

Comments

Projects
None yet
2 participants
@tim-ber
Copy link

commented Jun 13, 2019

Using javers-spring-boot-starter-sql 5.5.2, I'm getting the following error message for some types of commits. In the commit, a reference to another entity has been changed to null. Looks like wrapNull method is trying to cast an enum to a List, which throws java.lang.ClassCastException.

java.lang.ClassCastException: class org.javers.core.metamodel.property.MissingProperty cannot be cast to class java.util.List (org.javers.core.metamodel.property.MissingProperty is in unnamed module of loader 'app'; java.util.List is in module java.base of loader 'bootstrap')
	at org.javers.common.collections.Lists.wrapNull(Lists.java:20)
	at org.javers.core.metamodel.type.ListType.map(ListType.java:43)
	at org.javers.core.metamodel.type.EnumerableType.map(EnumerableType.java:37)
	at org.javers.core.graph.LiveNode.getDehydratedPropertyValue(LiveNode.java:85)
	at org.javers.core.diff.NodePair.getRightDehydratedPropertyValueAndSanitize(NodePair.java:40)
	at org.javers.core.diff.appenders.CorePropertyChangeAppender.calculateChanges(CorePropertyChangeAppender.java:44)
	at org.javers.core.diff.DiffFactory.appendChanges(DiffFactory.java:153)
	at org.javers.core.diff.DiffFactory.appendPropertyChanges(DiffFactory.java:143)
	at org.javers.core.diff.DiffFactory.createAndAppendChanges(DiffFactory.java:125)
	at org.javers.core.diff.DiffFactory.create(DiffFactory.java:69)
	at org.javers.core.commit.CommitFactory.createCommit(CommitFactory.java:89)
	at org.javers.core.commit.CommitFactory.create(CommitFactory.java:75)
	at org.javers.core.JaversCore.commit(JaversCore.java:82)
	at org.javers.spring.jpa.JaversTransactionalDecorator.commit(JaversTransactionalDecorator.java:82)
@bartoszwalacik

This comment has been minimized.

Copy link
Member

commented Jun 13, 2019

@bartoszwalacik

This comment has been minimized.

Copy link
Member

commented Jun 13, 2019

looks like I have it

    @TypeName("E")
    class Entity1 {
        @Id int id
    }

    @TypeName("E")
    class Entity2 {
        @Id int id
        List<String> props
    }

    def "should report when a list property is added or removed"(){
      given:
      def javers = javers().build()
      def object1 = new Entity1(id:1)
      def object2 = new Entity2(id:1, props: ["p"])

      when:
      def diff = javers.compare(object1, object2)
      println diff.prettyPrint()
      def changes = diff.getChangesByType(PropertyChange)

      then:
      changes.size() == 1
    }

bartoszwalacik added a commit that referenced this issue Jun 13, 2019

@bartoszwalacik

This comment has been minimized.

Copy link
Member

commented Jun 13, 2019

Fixed in 5.6.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.