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

Default comparator for raw Collections #746

bartoszwalacik opened this Issue Nov 25, 2018 · 3 comments


None yet
2 participants

bartoszwalacik commented Nov 25, 2018

Currently, JaVers skips comparing fields of Collection type

For example, in this class, clients field is ignored:

public class Company {
    private String id; 
    private Collection<Person> clients;
    private List<Person> partners;

and only this warnign is logged. Expected behaviour would be using List comparator.

10:19:40.332 [main] WARN  o.j.c.d.a.CollectionChangeFakeAppender - Collections: Field Collection<Person> clients; //declared in Company
are not equals but can't be compared. Raw Collection properties are not supported. Expected Set, List or any of their subclasses. JaVers uses different algorithms for comparing Sets and Lists and needs to know (statically) which one to test.

bartoszwalacik added a commit that referenced this issue Nov 25, 2018


bartoszwalacik added a commit that referenced this issue Nov 25, 2018


This comment has been minimized.


bartoszwalacik commented Nov 27, 2018

released in 4.0.0-RC3


This comment has been minimized.

baumgartner commented Dec 3, 2018

    public void equalEntityClientTest() {
        Person e1 = new Person("james", "ignore this");
        List<Person> l1 = new ArrayList<Person>();
        Company le1 = new Company("1", null, l1, null);

        Person e2 = new Person("james", "");
        List<Person> l2 = new ArrayList<Person>();
        Company le2 = new Company("1", null, l2, null);
        Diff diff =, le2);

        assertEquals(0, diff.getChanges().size());

Works with ListCompareAlgorithm.Simple
Assert fails with ListCompareAlgorithm.AS_SET
Exception with ListCompareAlgorithm.LEVENSHTEIN_DISTANCE

java.lang.ClassCastException: java.util.Collections$UnmodifiableSet cannot be cast to java.util.List
	at org.javers.core.diff.appenders.levenshtein.LevenshteinListChangeAppender.calculateChanges(
	at org.javers.core.diff.appenders.levenshtein.LevenshteinListChangeAppender.calculateChanges(
	at org.javers.core.diff.appenders.CollectionAsListChangeAppender.calculateChanges(
	at org.javers.core.diff.appenders.CollectionAsListChangeAppender.calculateChanges(
	at org.javers.core.diff.appenders.CorePropertyChangeAppender.calculateChanges(
	at org.javers.core.diff.DiffFactory.appendChanges(
	at org.javers.core.diff.DiffFactory.appendPropertyChanges(
	at org.javers.core.diff.DiffFactory.createAndAppendChanges(
	at org.javers.core.diff.DiffFactory.create(
	at javers.test.JaversListTest.equalEntityClientTest(
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(
	at java.lang.reflect.Method.invoke(
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(


bartoszwalacik added a commit that referenced this issue Dec 5, 2018


This comment has been minimized.


bartoszwalacik commented Dec 5, 2018

Fixed in 5.0.1 for all algorithms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment