Skip to content

JaversException CLASS_MAPPING_ERROR when committing generic-tuple-like object #948

@stun4j

Description

@stun4j

I found org.javers.core.Javers#commit not works when committing generic-tuple-like object(i.e. org.apache.commons.lang3.tuple.MutablePair etc.)

This exception can be reproduced using the following simple test case:

class Case948CommitGenericTupleLikeObject extends Specification {
    class Pair<L, R> {
        L left;
        R right;

        public Pair(L left, R right) {
            this.left = left;
            this.right = right;
        }

        @Override
        public String toString() {
            return "Pair [left=" + left + ", right=" + right + "]";
        }
    }

    def "should tracking work when committing generic-tuple-like object"(){
        given:
        Javers javers = JaversBuilder.javers().build();
        //Pair<Long, String> obj = org.apache.commons.lang3.tuple.MutablePair.of(1L, "foo");
        Pair<Long, String> obj = new Pair<>(1L, "foo");
        //    Map<Long,String> obj = new HashMap();
        //    obj.put(1L, "foo")

        when:
        javers.commit("jay", obj);

        //obj.setValue("bar");
        obj.right = "bar";
        //    obj.put(1L, "bar")

        Commit commit = javers.commit("jay", obj);

        then:
        commit.getChanges().size() == 1
    }
}

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