Return-Path: Delivered-To: apmail-jackrabbit-commits-archive@www.apache.org Received: (qmail 5918 invoked from network); 31 Oct 2006 08:35:57 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 31 Oct 2006 08:35:57 -0000 Received: (qmail 6683 invoked by uid 500); 31 Oct 2006 08:36:07 -0000 Delivered-To: apmail-jackrabbit-commits-archive@jackrabbit.apache.org Received: (qmail 6592 invoked by uid 500); 31 Oct 2006 08:36:07 -0000 Mailing-List: contact commits-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@jackrabbit.apache.org Delivered-To: mailing list commits@jackrabbit.apache.org Received: (qmail 6583 invoked by uid 99); 31 Oct 2006 08:36:07 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 31 Oct 2006 00:36:07 -0800 X-ASF-Spam-Status: No, hits=0.6 required=10.0 tests=NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 31 Oct 2006 00:35:55 -0800 Received: by eris.apache.org (Postfix, from userid 65534) id D8FB31A9846; Tue, 31 Oct 2006 00:35:31 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r469412 - /jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/XAItemStateManager.java Date: Tue, 31 Oct 2006 08:35:31 -0000 To: commits@jackrabbit.apache.org From: mreutegg@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20061031083531.D8FB31A9846@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: mreutegg Date: Tue Oct 31 00:35:31 2006 New Revision: 469412 URL: http://svn.apache.org/viewvc?view=rev&rev=469412 Log: JCR-600: Repository does not release all resources on shutdown - replaced usage of ThreadLocal with an IdentityHashMap using the current Thread as key to get the ChangeLog. Modified: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/XAItemStateManager.java Modified: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/XAItemStateManager.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/XAItemStateManager.java?view=diff&rev=469412&r1=469411&r2=469412 ============================================================================== --- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/XAItemStateManager.java (original) +++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/XAItemStateManager.java Tue Oct 31 00:35:31 2006 @@ -31,6 +31,9 @@ import javax.jcr.ReferentialIntegrityException; import javax.jcr.PropertyType; import java.util.Iterator; +import java.util.Map; +import java.util.IdentityHashMap; +import java.util.Collections; /** * Extension to LocalItemStateManager that remembers changes on @@ -50,15 +53,11 @@ private static final String DEFAULT_ATTRIBUTE_NAME = "ChangeLog"; /** - * ThreadLocal that holds the ChangeLog while this state manager is in one - * of the {@link #prepare}, {@link #commit}, {@link #rollback} - * methods. - */ - private ThreadLocal commitLog = new ThreadLocal() { - protected synchronized Object initialValue() { - return new CommitLog(); - } - }; + * This map holds the ChangeLog on a per thread basis while this state + * manager is in one of the {@link #prepare}, {@link #commit}, {@link + * #rollback} methods. + */ + private final Map commitLogs = Collections.synchronizedMap(new IdentityHashMap()); /** * Current instance-local change log. @@ -134,7 +133,7 @@ public void beforeOperation(TransactionContext tx) { ChangeLog txLog = (ChangeLog) tx.getAttribute(attributeName); if (txLog != null) { - ((CommitLog) commitLog.get()).setChanges(txLog); + commitLogs.put(Thread.currentThread(), txLog); } } @@ -195,7 +194,7 @@ * {@inheritDoc} */ public void afterOperation(TransactionContext tx) { - ((CommitLog) commitLog.get()).setChanges(null); + commitLogs.remove(Thread.currentThread()); } /** @@ -204,7 +203,7 @@ * change log was found. */ public ChangeLog getChangeLog() { - ChangeLog changeLog = ((CommitLog) commitLog.get()).getChanges(); + ChangeLog changeLog = (ChangeLog) commitLogs.get(Thread.currentThread()); if (changeLog == null) { changeLog = txLog; } @@ -426,43 +425,6 @@ if (refs != null) { refs.removeReference(sourceId); virtualProvider.setNodeReferences(refs); - } - } - - //--------------------------< inner classes >------------------------------- - - /** - * Helper class that serves as a container for a ChangeLog in a ThreadLocal. - * The CommitLog is associated with a ChangeLog - * while the TransactionalItemStateManager is in the commit - * method. - */ - private static class CommitLog { - - /** - * The changes that are about to be committed - */ - private ChangeLog changes; - - /** - * Sets changes that are about to be committed. - * - * @param changes that are about to be committed, or null - * if changes have been committed and the commit log should be reset. - */ - private void setChanges(ChangeLog changes) { - this.changes = changes; - } - - /** - * The changes that are about to be committed, or null if - * the TransactionalItemStateManager is currently not - * committing any changes. - * - * @return the changes about to be committed. - */ - private ChangeLog getChanges() { - return changes; } } }