Skip to content

Javers ReflectionUtils #860

@14327319

Description

@14327319

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)

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