openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Piotr Kubowicz (JIRA)" <>
Subject [jira] [Created] (OPENJPA-2340) UnsupportedOperationException on commit/rollback a transaction without writes
Date Wed, 27 Feb 2013 10:03:12 GMT
Piotr Kubowicz created OPENJPA-2340:

             Summary: UnsupportedOperationException on commit/rollback a transaction without
                 Key: OPENJPA-2340
             Project: OpenJPA
          Issue Type: Bug
          Components: kernel
    Affects Versions: 2.2.1
            Reporter: Piotr Kubowicz
         Attachments: BrokerImpl-trans-cache.patch

I met the following exception:

Caused by: <openjpa-2.2.1-r422266:1396819 nonfatal general error> org.apache.openjpa.persistence.PersistenceException:
IteratorChains must contain at least one Iterator
        at org.apache.openjpa.kernel.BrokerImpl.afterCompletion(
        at org.apache.openjpa.kernel.LocalManagedRuntime.commit(
        at org.apache.openjpa.kernel.BrokerImpl.commit(
        at org.apache.openjpa.kernel.DelegatingBroker.commit(
        at org.apache.openjpa.persistence.EntityManagerImpl.commit(
        ... 37 more
Caused by: java.lang.UnsupportedOperationException: IteratorChains must contain at least one
        at org.apache.commons.collections.iterators.IteratorChain.checkChainIntegrity(Unknown
        at org.apache.commons.collections.iterators.IteratorChain.lockChain(Unknown Source)
        at org.apache.commons.collections.iterators.IteratorChain.hasNext(Unknown Source)
        at org.apache.openjpa.kernel.BrokerImpl.endTransaction(
        at org.apache.openjpa.kernel.BrokerImpl.afterCompletion(
        ... 41 more

It's hard for me to provide a minimal reproduction steps. Generally what I am doing is:

// save some entities joined in a complex way
manager.getTransaction().commit(); // fine
manager.getTransaction().rollback(); // throws exception

What is funny, I have an @After method in my test that does another:
and it succeeds.

After some debugging I found that the bug is in how BrokerImpl.endTransaction() initializes
- in the rollback that throws exceptions, hasTransactionalObjects() returns true, although
_transCache.size() returns 0; iterator returned by the empty _transCache throws UnsupportedOperationException
- in the rollback in @After, hasTransactionalObjects() returns false, transStates is initialized
with Collections.EMPTY_SET and there is no problem with the iterator

I attached a patch which makes hasTransactionalObjects() check not only if _transCache is
null, but also if its empty.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see:

View raw message