java.util.ConcurrentModificationException: Node Michael field int age rel: false idx: true changed in between previous ExistingValue{value=null, fromGraph=true} current 35

Spring JIRA | Nicki Watt | 3 years ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    When using the advanced mapping mode to set a property outside of a transaction (i.e. making use of an implicit transaction), upon subsequent persistence of that enity via the persist() method, a ConcurrentModificationException occurs. StackTrace snippet shown below {noformat} http://java.util.ConcurrentModificationException: Node Michael field int age rel: false idx: true changed in between previous ExistingValue{value=null, fromGraph=true} current 35 at org.springframework.data.neo4j.fieldaccess.DetachedEntityState.checkConcurrentModification(DetachedEntityState.java:261) at org.springframework.data.neo4j.fieldaccess.DetachedEntityState.flushDirty(DetachedEntityState.java:208) at org.springframework.data.neo4j.fieldaccess.DetachedEntityState.persist(DetachedEntityState.java:290) at org.springframework.data.neo4j.aspects.support.node.Neo4jNodeBacking.ajc$interMethod$org_springframework_data_neo4j_aspects_support_node_Neo4jNodeBacking$org_springframework_data_neo4j_aspects_core_NodeBacked$persist(Neo4jNodeBacking.aj:133) at org.springframework.data.neo4j.aspects.Person.persist(Person.java:1) at org.springframework.data.neo4j.aspects.support.node.Neo4jNodeBacking.ajc$interMethodDispatch1$org_springframework_data_neo4j_aspects_support_node_Neo4jNodeBacking$org_springframework_data_neo4j_aspects_core_NodeBacked$persist(Neo4jNodeBacking.aj) at org.springframework.data.neo4j.aspects.support.ModificationOutsideOfTransactionTests.testSetPropertyOutsideTransactionCanBePersistedThereafter(ModificationOutsideOfTransactionTests.java:193) {noformat} The following JUnit test snippet was used to recreate this problem (It can simply be added to the {{org.springframework.data.neo4j.aspects.support.ModificationOutsideOfTransactionTests}} class) {noformat} @Test public void testSetPropertyOutsideTransactionCanBePersistedThereafter() { Person p = persistedPerson( "Michael", 35 ); p.setAge( 25 ); assertEquals(25, p.getAge()); try (Transaction tx = neo4jTemplate.getGraphDatabase().beginTx()) { assertEquals( 35, nodeFor( p ).getProperty("age") ); tx.success(); } p.persist(); try (Transaction tx = neo4jTemplate.getGraphDatabase().beginTx()) { assertEquals( 25, nodeFor( p ).getProperty("age") ); tx.success(); } } {noformat} PR Issued for possible fix: https://github.com/spring-projects/spring-data-neo4j/pull/150

    Spring JIRA | 3 years ago | Nicki Watt
    java.util.ConcurrentModificationException: Node Michael field int age rel: false idx: true changed in between previous ExistingValue{value=null, fromGraph=true} current 35
  2. 0

    When using the advanced mapping mode to set a property outside of a transaction (i.e. making use of an implicit transaction), upon subsequent persistence of that enity via the persist() method, a ConcurrentModificationException occurs. StackTrace snippet shown below {noformat} http://java.util.ConcurrentModificationException: Node Michael field int age rel: false idx: true changed in between previous ExistingValue{value=null, fromGraph=true} current 35 at org.springframework.data.neo4j.fieldaccess.DetachedEntityState.checkConcurrentModification(DetachedEntityState.java:261) at org.springframework.data.neo4j.fieldaccess.DetachedEntityState.flushDirty(DetachedEntityState.java:208) at org.springframework.data.neo4j.fieldaccess.DetachedEntityState.persist(DetachedEntityState.java:290) at org.springframework.data.neo4j.aspects.support.node.Neo4jNodeBacking.ajc$interMethod$org_springframework_data_neo4j_aspects_support_node_Neo4jNodeBacking$org_springframework_data_neo4j_aspects_core_NodeBacked$persist(Neo4jNodeBacking.aj:133) at org.springframework.data.neo4j.aspects.Person.persist(Person.java:1) at org.springframework.data.neo4j.aspects.support.node.Neo4jNodeBacking.ajc$interMethodDispatch1$org_springframework_data_neo4j_aspects_support_node_Neo4jNodeBacking$org_springframework_data_neo4j_aspects_core_NodeBacked$persist(Neo4jNodeBacking.aj) at org.springframework.data.neo4j.aspects.support.ModificationOutsideOfTransactionTests.testSetPropertyOutsideTransactionCanBePersistedThereafter(ModificationOutsideOfTransactionTests.java:193) {noformat} The following JUnit test snippet was used to recreate this problem (It can simply be added to the {{org.springframework.data.neo4j.aspects.support.ModificationOutsideOfTransactionTests}} class) {noformat} @Test public void testSetPropertyOutsideTransactionCanBePersistedThereafter() { Person p = persistedPerson( "Michael", 35 ); p.setAge( 25 ); assertEquals(25, p.getAge()); try (Transaction tx = neo4jTemplate.getGraphDatabase().beginTx()) { assertEquals( 35, nodeFor( p ).getProperty("age") ); tx.success(); } p.persist(); try (Transaction tx = neo4jTemplate.getGraphDatabase().beginTx()) { assertEquals( 25, nodeFor( p ).getProperty("age") ); tx.success(); } } {noformat} PR Issued for possible fix: https://github.com/spring-projects/spring-data-neo4j/pull/150

    Spring JIRA | 3 years ago | Nicki Watt
    java.util.ConcurrentModificationException: Node Michael field int age rel: false idx: true changed in between previous ExistingValue{value=null, fromGraph=true} current 35

    Root Cause Analysis

    1. java.util.ConcurrentModificationException

      Node Michael field int age rel: false idx: true changed in between previous ExistingValue{value=null, fromGraph=true} current 35

      at org.springframework.data.neo4j.fieldaccess.DetachedEntityState.checkConcurrentModification()
    2. Spring Data Neo4j
      DetachedEntityState.persist
      1. org.springframework.data.neo4j.fieldaccess.DetachedEntityState.checkConcurrentModification(DetachedEntityState.java:261)
      2. org.springframework.data.neo4j.fieldaccess.DetachedEntityState.flushDirty(DetachedEntityState.java:208)
      3. org.springframework.data.neo4j.fieldaccess.DetachedEntityState.persist(DetachedEntityState.java:290)
      3 frames
    3. Spring Data Neo4j - AspectJ Advanced Mapping
      Neo4jNodeBacking.ajc$interMethod$org_springframework_data_neo4j_aspects_support_node_Neo4jNodeBacking$org_springframework_data_neo4j_aspects_core_NodeBacked$persist
      1. org.springframework.data.neo4j.aspects.support.node.Neo4jNodeBacking.ajc$interMethod$org_springframework_data_neo4j_aspects_support_node_Neo4jNodeBacking$org_springframework_data_neo4j_aspects_core_NodeBacked$persist(Neo4jNodeBacking.aj:133)
      1 frame
    4. org.springframework.data
      Person.persist
      1. org.springframework.data.neo4j.aspects.Person.persist(Person.java:1)
      1 frame
    5. Spring Data Neo4j - AspectJ Advanced Mapping
      Neo4jNodeBacking.ajc$interMethodDispatch1$org_springframework_data_neo4j_aspects_support_node_Neo4jNodeBacking$org_springframework_data_neo4j_aspects_core_NodeBacked$persist
      1. org.springframework.data.neo4j.aspects.support.node.Neo4jNodeBacking.ajc$interMethodDispatch1$org_springframework_data_neo4j_aspects_support_node_Neo4jNodeBacking$org_springframework_data_neo4j_aspects_core_NodeBacked$persist(Neo4jNodeBacking.aj)
      1 frame
    6. org.springframework.data
      ModificationOutsideOfTransactionTests.testSetPropertyOutsideTransactionCanBePersistedThereafter
      1. org.springframework.data.neo4j.aspects.support.ModificationOutsideOfTransactionTests.testSetPropertyOutsideTransactionCanBePersistedThereafter(ModificationOutsideOfTransactionTests.java:193)
      1 frame