Skip to content

Failure to detect new value object in a set under specific circumstances #795

@robfletcher

Description

@robfletcher

I'm comparing two objects whose topology looks like this:

Entity
- various simple properties
- Set<ValueObject1>

ValueObject1
- various simple properties
- ValueObject2

ValueObject2
- various simple properties

If I add a new ValueObject1 to the set on an entity that only differs from another already in the set by the ValueObject2 property then Javers detects no change.

I did some debugging and it seems ObjectHasher generates a state snapshot of each ValueObject1 where the ValueObject2 property is only represented by a path (and hence looks the same in every instance of ValueObject1 in the set). Thus the ValueObject2 does not affect the hash generated and Javers does not see the new element in the set.

Although I'm working in Kotlin, I created a Gist that demonstrates the issue using Groovy/Spock: https://gist.github.com/robfletcher/97ad78d06f15c92617d734d227218c01 using a simplified version of the model from my real project.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions