You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Javers finds differences in the object tree when the same instance of a nested object is shared between parent and child #1358
Clear description of my expectations versus reality
I have 2 "complex" objects to compare to find if they changed. The object has a property and a list of items, an item can have the same property as the top-level object. In the old version the property VO's are all unique instances. In the new version I use the same instance of the property VO in both top-level object and list-item. When comparing the objects with old.equals(new) they are considered equal. When comparing with javers.compare(old, new) differences are found. This only happens when the shared property is shared between top-level object and list-item, not when 2 siblings share the same object. It also only happens when the list-item is indeed in a collection (set or list make no difference) not when it is a single property.
I would expect that compare would not find any differences as all properties of both objects are the same and even equals says they are the same.
Steps To Reproduce
I have a **runnable test case ** which isolates the bug and allows Javers Core Team to easily reproduce it. I have pushed this test case to my fork of this repository:
After working with the latest code fixes, I've run into a similar issue where Javers considers properties unset even though their equals method returns true. This seems to occur when I work with properties that have deeper levels of nesting.
As an additional note, I wanted to mention that I temporarily bypassed the issue by commenting out a section of code in the org.javers.core.graph.EdgeBuilder#buildNodeStubOrReuse method. After making this change, the test case passed. Here's the code snippet I commented out for temporary verification purposes:
privateLiveNodebuildNodeStubOrReuse(LiveCdocdo){
if (nodeReuser.isReusable(cdo)){
returnnodeReuser.getForReuse(cdo);
}
else {
// if (nodeReuser.isTraversed(cdo)) {// return buildNodeDouble(nodeReuser.getForDouble(cdo), cdo);// }returnbuildNodeStub(cdo);
}
}
Activity
bartoszwalacik commentedon May 28, 2024
Hi, thanks for reporting, indeed, looks like a bug ...
fix for #1358
fix for #1358
bartoszwalacik commentedon Jun 4, 2024
Fixed in 7.4.4
clarkhan commentedon Jun 5, 2024
After working with the latest code fixes, I've run into a similar issue where Javers considers properties unset even though their equals method returns true. This seems to occur when I work with properties that have deeper levels of nesting.
To illustrate this problem more clearly, I have modified a test case that was initially provided by idegroot.
Here is the link to the modified test case:
https://github.com/clarkhan/javers/blob/test/shared_object_unset/javers-core/src/test/groovy/org/javers/core/cases/CaseSharedObjectUnsetWhenUsedInCollection.groovy
Additionally, for ease of reference, I've included both the content of the test case and the test results below:
Test Results:
clarkhan commentedon Jun 5, 2024
As an additional note, I wanted to mention that I temporarily bypassed the issue by commenting out a section of code in the org.javers.core.graph.EdgeBuilder#buildNodeStubOrReuse method. After making this change, the test case passed. Here's the code snippet I commented out for temporary verification purposes:
bartoszwalacik commentedon Jun 5, 2024
thanks for reporting @clarkhan , I will take a look on it
bartoszwalacik commentedon Jun 5, 2024
okay, I need to drop this node double concept and implement some cycle detection algo
temporarily bypassed the issue javers#1358
second try to fix #1358
second try to fix javers#1358
bartoszwalacik commentedon Jun 7, 2024
Fixed in 7.4.5