From commits-return-10288-apmail-jackrabbit-commits-archive=jackrabbit.apache.org@jackrabbit.apache.org Wed Sep 08 09:57:01 2010 Return-Path: Delivered-To: apmail-jackrabbit-commits-archive@www.apache.org Received: (qmail 17034 invoked from network); 8 Sep 2010 09:57:00 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 8 Sep 2010 09:57:00 -0000 Received: (qmail 14770 invoked by uid 500); 8 Sep 2010 09:57:00 -0000 Delivered-To: apmail-jackrabbit-commits-archive@jackrabbit.apache.org Received: (qmail 14671 invoked by uid 500); 8 Sep 2010 09:56:59 -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 14664 invoked by uid 99); 8 Sep 2010 09:56:59 -0000 Received: from Unknown (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 08 Sep 2010 09:56:59 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 08 Sep 2010 09:56:41 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id DC92F238890B; Wed, 8 Sep 2010 09:56:18 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r994955 - /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionState.java Date: Wed, 08 Sep 2010 09:56:18 -0000 To: commits@jackrabbit.apache.org From: jukka@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100908095618.DC92F238890B@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: jukka Date: Wed Sep 8 09:56:18 2010 New Revision: 994955 URL: http://svn.apache.org/viewvc?rev=994955&view=rev Log: JCR-2741: Improved logging for session operations Detect and warn about concurrent writes using the same session Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionState.java Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionState.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionState.java?rev=994955&r1=994954&r2=994955&view=diff ============================================================================== --- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionState.java (original) +++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/session/SessionState.java Wed Sep 8 09:56:18 2010 @@ -63,6 +63,12 @@ public class SessionState { private final Lock lock = new ReentrantLock(); /** + * Flag to indicate that the current operation is a write operation. + * Used to detect concurrent writes. + */ + private volatile boolean isWriteOperation = false; + + /** * Flag to indicate a closed session. When null, the session * is still alive. And when the session is closed, this reference is set * to an exception that contains the stack trace of where the session was @@ -71,6 +77,11 @@ public class SessionState { */ private volatile Exception closed = null; + /** + * Creates a state instance for a session. + * + * @param context component context of this session + */ public SessionState(SessionContext context) { this.context = context; } @@ -148,17 +159,29 @@ public class SessionState { private T internalPerform(SessionOperation operation) throws RepositoryException { if (!lock.tryLock()) { - log.debug("Attempt to perform {} while another thread is" - + " concurrently accessing the session. Blocking until" - + " the other thread is finished using this session.", - operation); + if (isWriteOperation && operation instanceof SessionWriteOperation) { + log.warn("Attempt to perform {} while another thread is" + + " concurrently modifying the session. Blocking until" + + " the other thread is finished using this session.", + operation); + } else { + log.debug("Attempt to perform {} while another thread is" + + " concurrently accessing the session. Blocking until" + + " the other thread is finished using this session.", + operation); + } lock.lock(); } + boolean wasWriteOperation = isWriteOperation; + if (!wasWriteOperation && operation instanceof SessionWriteOperation) { + isWriteOperation = true; + } try { checkAlive(); log.debug("Performing {}", operation); return operation.perform(context); } finally { + isWriteOperation = wasWriteOperation; lock.unlock(); } }