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

Random ClassCastExceptions #218

Closed
peda opened this Issue Oct 5, 2015 · 18 comments

Comments

Projects
None yet
2 participants
@peda

peda commented Oct 5, 2015

Hello,

I do have a structure of nested entity objects (similar to the large depth employee sample). Even if I re-run the application multiple times with the same data set the exception does not occur at every run - at some runs no exceptions happens, at some runs the exceptions occurs just once even though I'm comparing dozens of objects with nearly the same values (just some primitives do have different values) and at some runs nearly every diff throws the exception.

 java.lang.ClassCastException: com.XXX.XXX.domain.MyObject cannot be cast to org.javers.core.metamodel.object.GlobalId
    at org.javers.core.graph.ObjectNode.getReference(ObjectNode.java:75)
    at org.javers.core.diff.RealNodePair.getRightGlobalId(RealNodePair.java:61)
    at org.javers.core.diff.appenders.ReferenceChangeAppender.calculateChanges(ReferenceChangeAppender.java:25)
    at org.javers.core.diff.appenders.ReferenceChangeAppender.calculateChanges(ReferenceChangeAppender.java:15)
    at org.javers.core.diff.DiffFactory.appendChanges(DiffFactory.java:142)
    at org.javers.core.diff.DiffFactory.appendPropertyChanges(DiffFactory.java:132)
    at org.javers.core.diff.DiffFactory.createAndAppendChanges(DiffFactory.java:114)
    at org.javers.core.diff.DiffFactory.create(DiffFactory.java:65)
    at org.javers.core.diff.DiffFactory.compare(DiffFactory.java:58)
    at org.javers.core.JaversCore.compare(JaversCore.java:94)
    at com.XXX.XXX.util.audit.AuditLogEntry.createFromRecord(AuditLogEntry.java:139)
@bartoszwalacik

This comment has been minimized.

Member

bartoszwalacik commented Oct 5, 2015

how can I reproduce it?

@peda

This comment has been minimized.

peda commented Oct 5, 2015

that's the tricky question ;-) any suggestions?

@bartoszwalacik

This comment has been minimized.

Member

bartoszwalacik commented Oct 5, 2015

I need more data to solve this, stack trace is not enought in this case.
Especially, i need to know how your domain objects look like.

Failing test would be nice.

@peda

This comment has been minimized.

peda commented Oct 5, 2015

I'll try to reproduce it in a test project - but I will definitely need a few days for that because I'm really busy at the moment and need to extract that test case from a larger project.

@peda

This comment has been minimized.

peda commented Oct 5, 2015

quick question: is javers.compare(oldObj, newObj) thread-safe? I figured out that it might happen that the same javers instance was used by multiple threads at the same time

@bartoszwalacik

This comment has been minimized.

Member

bartoszwalacik commented Oct 5, 2015

ok, no hurry,
javers.compare() is designed to be thread-safe, but in fact, the case you are describing looks like some concurrency issue...

@peda

This comment has been minimized.

peda commented Oct 5, 2015

I managed to isolate the issue in a smaller project - but as it does still contain some business logic I've sent you the test project as email to javers@javers.org - I hope that works for you, if it doesn't please let me know. Thanks :-)

@bartoszwalacik

This comment has been minimized.

Member

bartoszwalacik commented Oct 9, 2015

Ok , will do

@bartoszwalacik

This comment has been minimized.

Member

bartoszwalacik commented Oct 9, 2015

ok, exception reproduced on my laptop, when running your test

@peda

This comment has been minimized.

peda commented Oct 9, 2015

thanks, that's great to know :-)

@bartoszwalacik

This comment has been minimized.

Member

bartoszwalacik commented Oct 11, 2015

lombok :(
you need a special plugin even just to compile it

@peda

This comment has been minimized.

peda commented Oct 11, 2015

yes, but therefore you don't have to write any getters and setters on your own ;-)

@bartoszwalacik

This comment has been minimized.

Member

bartoszwalacik commented Oct 11, 2015

yes, I know what it is, but I really dont like it,
nevermind, think i found some issue in javers-core, we need to improve thread-safety in TypeMapper

bartoszwalacik added a commit that referenced this issue Oct 13, 2015

#218
fixed redundant JaversType spawning in TypeMapper
@bartoszwalacik

This comment has been minimized.

Member

bartoszwalacik commented Oct 13, 2015

fix is ready, now I need some time for Maven Central sync, stay tuned

@peda

This comment has been minimized.

peda commented Oct 13, 2015

Thank you so much - your dedication for this open source project is amazing. I'll give it a try as soon as it is available on maven central.

@bartoszwalacik

This comment has been minimized.

Member

bartoszwalacik commented Oct 13, 2015

Thanks! release 1.3.14 is now available in Maven Central. Check it out and don't forget to give as a stargazers https://github.com/javers/javers/stargazers if you like JaVers project :)

bartoszwalacik added a commit that referenced this issue Oct 13, 2015

@peda

This comment has been minimized.

peda commented Oct 13, 2015

Thanks I just tried it and it's working fine for me - I gave you a stargazer

Just one more thing I've noticed 1.3.14 does not run on JDK 7 any more as it's missing java.util.function.Function - is that a deiberate change? (Anyway I'm fine with it as I changed my project a few days ago to run with JDK 8)

@bartoszwalacik

This comment has been minimized.

Member

bartoszwalacik commented Oct 13, 2015

No its a mistake, i will fix it, thats because im trying to support java8 types and still beeing runnable on jvm7.

bartoszwalacik added a commit that referenced this issue Oct 13, 2015

#218
fix for broken Java7 compatibility
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment