Return-Path: X-Original-To: apmail-openjpa-dev-archive@www.apache.org Delivered-To: apmail-openjpa-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 468FFEBC3 for ; Thu, 28 Feb 2013 14:11:17 +0000 (UTC) Received: (qmail 69338 invoked by uid 500); 28 Feb 2013 14:11:16 -0000 Delivered-To: apmail-openjpa-dev-archive@openjpa.apache.org Received: (qmail 69133 invoked by uid 500); 28 Feb 2013 14:11:15 -0000 Mailing-List: contact dev-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@openjpa.apache.org Delivered-To: mailing list dev@openjpa.apache.org Received: (qmail 69082 invoked by uid 99); 28 Feb 2013 14:11:13 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 28 Feb 2013 14:11:13 +0000 Date: Thu, 28 Feb 2013 14:11:12 +0000 (UTC) From: "Rick Curtis (JIRA)" To: dev@openjpa.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Assigned] (OPENJPA-2340) [patch] UnsupportedOperationException on commit/rollback a transaction without writes MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/OPENJPA-2340?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Rick Curtis reassigned OPENJPA-2340: ------------------------------------ Assignee: Rick Curtis > [patch] UnsupportedOperationException on commit/rollback a transaction without writes > ------------------------------------------------------------------------------------- > > Key: OPENJPA-2340 > URL: https://issues.apache.org/jira/browse/OPENJPA-2340 > Project: OpenJPA > Issue Type: Bug > Components: kernel > Affects Versions: 2.2.1 > Reporter: Piotr Kubowicz > Assignee: Rick Curtis > Attachments: BrokerImpl-trans-cache.patch > > > I met the following exception: > Caused by: org.apache.openjpa.persistence.PersistenceException: IteratorChains must contain at least one Iterator > at org.apache.openjpa.kernel.BrokerImpl.afterCompletion(BrokerImpl.java:2036) > at org.apache.openjpa.kernel.LocalManagedRuntime.commit(LocalManagedRuntime.java:94) > at org.apache.openjpa.kernel.BrokerImpl.commit(BrokerImpl.java:1516) > at org.apache.openjpa.kernel.DelegatingBroker.commit(DelegatingBroker.java:933) > at org.apache.openjpa.persistence.EntityManagerImpl.commit(EntityManagerImpl.java:570) > ... 37 more > Caused by: java.lang.UnsupportedOperationException: IteratorChains must contain at least one Iterator > at org.apache.commons.collections.iterators.IteratorChain.checkChainIntegrity(Unknown Source) > 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(BrokerImpl.java:2407) > at org.apache.openjpa.kernel.BrokerImpl.afterCompletion(BrokerImpl.java:2012) > ... 41 more > It's hard for me to provide a minimal reproduction steps. Generally what I am doing is: > manager.getTransaction().begin(); > // save some entities joined in a complex way > manager.getTransaction().commit(); // fine > manager.clear(); > manager.getTransaction().begin(); > manager.getTransaction().rollback(); // throws exception > What is funny, I have an @After method in my test that does another: > manager.getTransaction().rollback(); > and it succeeds. > After some debugging I found that the bug is in how BrokerImpl.endTransaction() initializes transStates: > - 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: http://www.atlassian.com/software/jira