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

compare is not thread safe #182

Closed
fuhrmannm opened this Issue Jul 31, 2015 · 2 comments

Comments

Projects
None yet
2 participants
@fuhrmannm

fuhrmannm commented Jul 31, 2015

Here is a stack-trace snippet:

java.util.ConcurrentModificationException: null
at java.util.HashMap$HashIterator.nextNode(HashMap.java:1429) ~[na:1.8.0_31]
at java.util.HashMap$ValueIterator.next(HashMap.java:1458) ~[na:1.8.0_31]
at org.javers.core.metamodel.type.TypeMapper.findNearestAncestor(TypeMapper.java:302) ~[javers-core-1.2.1.jar!/:na]
at org.javers.core.metamodel.type.TypeMapper.infer(TypeMapper.java:276) ~[javers-core-1.2.1.jar!/:na]
at org.javers.core.metamodel.type.TypeMapper.getJaversType(TypeMapper.java:106) ~[javers-core-1.2.1.jar!/:na]
at org.javers.core.metamodel.type.TypeMapper.getPropertyType(TypeMapper.java:126) ~[javers-core-1.2.1.jar!/:na]
at org.javers.core.metamodel.type.TypeMapper.isEntityReferenceOrValueObject(TypeMapper.java:130) ~[javers-core-1.2.1.jar!/:na]
at org.javers.core.graph.ObjectGraphBuilder$1.apply(ObjectGraphBuilder.java:104) ~[javers-core-1.2.1.jar!/:na]
at org.javers.core.graph.ObjectGraphBuilder$1.apply(ObjectGraphBuilder.java:102) ~[javers-core-1.2.1.jar!/:na]
at org.javers.core.metamodel.clazz.ManagedClass.getProperties(ManagedClass.java:42) ~[javers-core-1.2.1.jar!/:na]
at org.javers.core.graph.ObjectGraphBuilder.getSingleReferences(ObjectGraphBuilder.java:102) ~[javers-core-1.2.1.jar!/:na]
at org.javers.core.graph.ObjectGraphBuilder.buildSingleEdges(ObjectGraphBuilder.java:72) ~[javers-core-1.2.1.jar!/:na]
at org.javers.core.graph.ObjectGraphBuilder.buildEdges(ObjectGraphBuilder.java:67) ~[javers-core-1.2.1.jar!/:na]
at org.javers.core.graph.ObjectGraphBuilder.buildGraph(ObjectGraphBuilder.java:55) ~[javers-core-1.2.1.jar!/:na]
at org.javers.core.graph.LiveGraphFactory.createLiveGraph(LiveGraphFactory.java:28) ~[javers-core-1.2.1.jar!/:na]
at org.javers.core.diff.DiffFactory.buildGraph(DiffFactory.java:90) ~[javers-core-1.2.1.jar!/:na]
at org.javers.core.diff.DiffFactory.compare(DiffFactory.java:58) ~[javers-core-1.2.1.jar!/:na]
at org.javers.core.JaversCore.compare(JaversCore.java:86) ~[javers-core-1.2.1.jar!/:na]
...

A possible fix could be to use ConcurrentHashmap for mappedTypes. Or to add a new thread-safe compare function that synchronizes around mappedTypes

@bartoszwalacik

This comment has been minimized.

Member

bartoszwalacik commented Aug 2, 2015

Right, will change to concurrent hash map

@bartoszwalacik bartoszwalacik self-assigned this Aug 2, 2015

@bartoszwalacik

This comment has been minimized.

Member

bartoszwalacik commented Aug 3, 2015

changed to ConcurrentHashMap, released in v1.3.1
http://search.maven.org/#search|ga|1|javers-core

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