Return-Path: Delivered-To: apmail-openjpa-dev-archive@www.apache.org Received: (qmail 48598 invoked from network); 19 Jun 2007 22:09:47 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 19 Jun 2007 22:09:47 -0000 Received: (qmail 92096 invoked by uid 500); 19 Jun 2007 22:09:50 -0000 Delivered-To: apmail-openjpa-dev-archive@openjpa.apache.org Received: (qmail 92070 invoked by uid 500); 19 Jun 2007 22:09:50 -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 92061 invoked by uid 99); 19 Jun 2007 22:09:50 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 19 Jun 2007 15:09:50 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO brutus.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 19 Jun 2007 15:09:46 -0700 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 04BCC71404B for ; Tue, 19 Jun 2007 15:09:26 -0700 (PDT) Message-ID: <25387213.1182290966000.JavaMail.jira@brutus> Date: Tue, 19 Jun 2007 15:09:25 -0700 (PDT) From: "Patrick Linskey (JIRA)" To: dev@openjpa.apache.org Subject: [jira] Commented: (OPENJPA-261) NullPointerException occurred in BrokerImpl.java In-Reply-To: <3937301.1182290605958.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/OPENJPA-261?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12506312 ] Patrick Linskey commented on OPENJPA-261: ----------------------------------------- So you're saying that Collections.EMPTY_LIST.iterator() is returning null? That seems surprising. What version of Java are you using? Can you check if your Java version is returning null from Collecitons.EMPTY_LIST.iterator()? > NullPointerException occurred in BrokerImpl.java > ------------------------------------------------ > > Key: OPENJPA-261 > URL: https://issues.apache.org/jira/browse/OPENJPA-261 > Project: OpenJPA > Issue Type: Bug > Components: kernel > Affects Versions: 0.9.7 > Environment: Window XP > Reporter: Teresa Kan > Priority: Critical > Attachments: NPE.patch > > > While I was testing against the openjpa code, I got a NPE in the BrokerImpl.endtransaction() method. The method set the transState to an empty Collection if there is no cache for transactions. Later the code did not check this Collection and tried to iterate on it and a NullPointerException occurred. > Original code: > Collection transStates = _transCache; > if (transStates == null) > transStates = Collections.EMPTY_LIST; > ..... > for (Iterator itr = transStates.iterator(); itr.hasNext();) { <--- NPE occurred here. > sm = (StateManagerImpl) itr.next(); > try { > if (rollback) { > // tell objects that may have been derefed then flushed > // (and therefore deleted) to un-deref > sm.setDereferencedDependent(false, false); > sm.rollback(); > } else > sm.commit(); > } catch (RuntimeException re) { > exceps = add(exceps, re); > } > } > I put a check before this "for" loop then the NPE disappeared. > if (!transStates.isEmpty()) { > for (Iterator itr = transStates.iterator(); itr.hasNext();) { > sm = (StateManagerImpl) itr.next(); > try { > if (rollback) { > // tell objects that may have been derefed then flushed > // (and therefore deleted) to un-deref > sm.setDereferencedDependent(false, false); > sm.rollback(); > } else > sm.commit(); > } catch (RuntimeException re) { > exceps = add(exceps, re); > } > } > } > The NPE.patch is attached in this jiar. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.