Skip to content
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

Javers ReflectionUtils #860

Closed
14327319 opened this issue Jul 10, 2019 · 2 comments
Closed

Javers ReflectionUtils #860

14327319 opened this issue Jul 10, 2019 · 2 comments

Comments

@14327319
Copy link

Hi,
I am using Javers with Spring Boot. I got this exception during my code execution:

org.javers.common.exception.JaversException: SNAPSHOT_STATE_VIOLATION: snapshots are immutable
	at org.javers.core.metamodel.object.CdoSnapshotStateBuilder.withPropertyValue(CdoSnapshotStateBuilder.java:31)
	at org.javers.core.metamodel.object.CdoSnapshotStateBuilder.withPropertyValue(CdoSnapshotStateBuilder.java:39)
	at org.javers.core.snapshot.SnapshotFactory.createSnapshotState(SnapshotFactory.java:79)
	at org.javers.core.snapshot.SnapshotFactory.createInitial(SnapshotFactory.java:40)
	at org.javers.core.snapshot.ChangedCdoSnapshotsFactory.createInitialSnapshot(ChangedCdoSnapshotsFactory.java:61)
	at org.javers.core.snapshot.ChangedCdoSnapshotsFactory.createSnapshot(ChangedCdoSnapshotsFactory.java:52)
	at org.javers.core.snapshot.ChangedCdoSnapshotsFactory.create(ChangedCdoSnapshotsFactory.java:41)
	at org.javers.core.commit.CommitFactory.createCommit(CommitFactory.java:88)
	at org.javers.core.commit.CommitFactory.create(CommitFactory.java:75)
	at org.javers.core.JaversCore.commit(JaversCore.java:82)
	at org.javers.spring.auditable.aspect.springdata.AbstractSpringAuditableRepositoryAspect.lambda$new$0(AbstractSpringAuditableRepositoryAspect.java:33)
	at org.javers.spring.auditable.aspect.springdata.AbstractSpringAuditableRepositoryAspect.lambda$onVersionEvent$3(AbstractSpringAuditableRepositoryAspect.java:52)
	at java.util.Optional.ifPresent(Optional.java:159)
	at org.javers.spring.auditable.aspect.springdata.AbstractSpringAuditableRepositoryAspect.onVersionEvent(AbstractSpringAuditableRepositoryAspect.java:48)
	at org.javers.spring.auditable.aspect.springdata.AbstractSpringAuditableRepositoryAspect.onSave(AbstractSpringAuditableRepositoryAspect.java:38)
	at org.javers.spring.auditable.aspect.springdata.JaversSpringDataAuditableRepositoryAspect.onSaveExecuted(JaversSpringDataAuditableRepositoryAspect.java:42)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:644)
	at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:626)
	at org.springframework.aop.aspectj.AspectJAfterReturningAdvice.afterReturning(AspectJAfterReturningAdvice.java:66)
	at org.springframework.aop.framework.adapter.AfterReturningAdviceInterceptor.invoke(AfterReturningAdviceInterceptor.java:56)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:174)
	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)
	at com.sun.proxy.$Proxy99.save(Unknown Source)
	......

Basically, I am trying to inspect data repository using @JaversSpringDataAuditable tag and I encountered with this error during this process.

As far as I inspected the Javers source code, interfaces and concrete classes are extracted in ReflectionUtil.calculateHierarchyDistance function for a given custom class and these are given to ManagedType as properties. Then, later, this information becomes a part of a node in the generated LiveGraph.

However, for me, createSnapshotState function checks properties and previously extracted interface and class types causes the exception above.

My main question is, does Javers handle interfaces along with class hierarchy for a given class for this situation and am I doing something wrong? Could you please suggest me a way to overcome this issue?

(I can provide more information if desired)

@bartoszwalacik
Copy link
Member

Pleaae folow Guidelines for Bug Reporting
https://github.com/javers/javers/blob/master/CONTRIBUTING.md#guidelines-for-bug-reporting

and it would be nice if you disclose your name

14327319 pushed a commit to 14327319/javers that referenced this issue Jul 17, 2019
14327319 pushed a commit to 14327319/javers that referenced this issue Jul 17, 2019
bartoszwalacik added a commit that referenced this issue Jul 22, 2019
bartoszwalacik added a commit that referenced this issue Jul 31, 2019
bartoszwalacik added a commit that referenced this issue Aug 1, 2019
bartoszwalacik added a commit that referenced this issue Aug 1, 2019
@bartoszwalacik
Copy link
Member

fixed in 5.6.3

chioai1309 pushed a commit to chioai1309/javers that referenced this issue Sep 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants