Uploaded image for project: 'Spring Data Neo4j'
  1. Spring Data Neo4j
  2. DATAGRAPH-997

NPE during transaction rollback when custom query fails

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 4.2.3 (Ingalls SR3)
    • Component/s: CORE
    • Labels:
      None
    • Environment:
      Java 1.8.0_51

      Description

      Hello,

      I'm facing an issue where Neo4jTransactionManager fails to rollback transaction after runtime exception in a custom Cypher query. Attached github repository contains a project to reproduce the problem.

      It contains a repository which extends GraphRepository and adds a single method with a custom query MATCH (m:Movie) WHERE m.title = '' RETURN m AS movie, 10/0 AS other. This query obviously generates a "division by zero" runtime exception. However I can also see NPE stacktrace. It seems to occur because Neo4jTransactionManager tries to rollback transaction that has already been rolled back by OGM code in BoltResponse#next().

      Division by zero in this example is artificial, in reality queries can fail in many different ways at runtime (deadlocks, type errors, etc.).

      Seen stacktrace:

      Exception in thread "main" java.lang.NullPointerException
      at org.springframework.data.neo4j.transaction.Neo4jTransactionManager.doRollback(Neo4jTransactionManager.java:275)
      at org.springframework.transaction.support.AbstractPlatformTransactionManager.processRollback(AbstractPlatformTransactionManager.java:853)
      at org.springframework.transaction.support.AbstractPlatformTransactionManager.rollback(AbstractPlatformTransactionManager.java:830)
      at org.springframework.transaction.interceptor.TransactionAspectSupport.completeTransactionAfterThrowing(TransactionAspectSupport.java:522)
      at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:286)
      at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
      at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:656)
      at org.neo4j.services.MovieService$$EnhancerBySpringCGLIB$$b8f1a8e3.findByTitle(<generated>)
      at org.neo4j.SampleMovieApplication.main(SampleMovieApplication.java:30)
      

        Attachments

          Activity

            People

            Assignee:
            nmervaillie Nicolas Mervaillie
            Reporter:
            lutovich Konstantin Lutovich
            Last updater:
            Spring Issues Spring Issues
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: