Uploaded image for project: 'JBRULES'
  2. JBRULES-3600

DroolsSpringTransactionManager throws NPE instead of handling JPA transaction state



      I posted on this in the forums: https://community.jboss.org/message/751900#751900 but really didn't receive a useful reply.

      Since there are clearly bugs in the DroolsSpringTransactionManager, I am posting this bug report too. I have covered them in the forum post, although I do not know if my mitigating solution is correct even though it seems to work.

      The DroolsSpringTransactionManager has two inherent NullPointerExceptions.

      First, (from my post): There is an obvious bug in the begin() method in that if the call to getStatus() returns STATUS_NO_TRANSACTION, which it will if the wrapped tm (ptm) is null, it immediately dereferences the null ptm. (this.ptm.getTransaction(td)). I'm not too woried about this one as it seems rather unlikely.

      However, the second problem (which affects me) is a NPE masking an IllegalStateException which should probably be caught to return a valid or UNKNOWN state. The issue (in the getStatus() method) is that it's making the call "transaction = this.ptm.getTransaction(td);" which is occasionally throwing an "IllegalStateException: Transaction already active," wrapped in an outer RuntimeException and dropping down to the finally block (there is no catch). There, the still null transaction is committed, throwing an NPE that masks the original exception. To mitigate this, I added a catch RuntimeException and if the cause is an IllegalStateException, I return STATUS_UNKNOWN. In the finally block, I also ensure that I don't try to commit a null transaction.

      A better description of the second bug and mitigation are in the referenced post.

        Gliffy Diagrams




              • Assignee:
                mark.proctor Mark Proctor
                jbize John Bize
              • Votes:
                1 Vote for this issue
                1 Start watching this issue


                • Created: