Return-Path: Delivered-To: apmail-jackrabbit-commits-archive@www.apache.org Received: (qmail 26871 invoked from network); 13 Oct 2008 10:12:44 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 13 Oct 2008 10:12:44 -0000 Received: (qmail 65155 invoked by uid 500); 13 Oct 2008 10:12:44 -0000 Delivered-To: apmail-jackrabbit-commits-archive@jackrabbit.apache.org Received: (qmail 65071 invoked by uid 500); 13 Oct 2008 10:12:44 -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 65062 invoked by uid 99); 13 Oct 2008 10:12:43 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 13 Oct 2008 03:12:43 -0700 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; Mon, 13 Oct 2008 10:11:46 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id DF91023888A5; Mon, 13 Oct 2008 03:12:22 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r704002 - /jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/AbstractSession.java Date: Mon, 13 Oct 2008 10:12:22 -0000 To: commits@jackrabbit.apache.org From: jukka@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20081013101222.DF91023888A5@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: jukka Date: Mon Oct 13 03:12:22 2008 New Revision: 704002 URL: http://svn.apache.org/viewvc?rev=704002&view=rev Log: JCR-1793: Namespace handling in AbstractSession should be synchronized Synchronize all methods that access the map that contains the session-local namespace mappings. Modified: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/AbstractSession.java Modified: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/AbstractSession.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/AbstractSession.java?rev=704002&r1=704001&r2=704002&view=diff ============================================================================== --- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/AbstractSession.java (original) +++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/AbstractSession.java Mon Oct 13 03:12:22 2008 @@ -57,6 +57,9 @@ /** * Local namespace mappings. Prefixes as keys and namespace URIs as values. + *

+ * This map is only accessed from synchronized methods (see + * JCR-1793). */ private final Map namespaces = new HashMap(); @@ -66,7 +69,7 @@ * super.logout() when overriding this method to avoid * namespace mappings to be carried over to a new session. */ - public void logout() { + public synchronized void logout() { namespaces.clear(); } @@ -85,7 +88,7 @@ * @throws NamespaceException if the namespace is not found * @throws RepositoryException if a repository error occurs */ - public String getNamespacePrefix(String uri) + public synchronized String getNamespacePrefix(String uri) throws NamespaceException, RepositoryException { Iterator iterator = namespaces.entrySet().iterator(); while (iterator.hasNext()) { @@ -121,7 +124,7 @@ * @throws NamespaceException if the namespace is not found * @throws RepositoryException if a repository error occurs */ - public String getNamespaceURI(String prefix) + public synchronized String getNamespaceURI(String prefix) throws NamespaceException, RepositoryException { String uri = (String) namespaces.get(prefix); @@ -152,7 +155,8 @@ * @return namespace prefixes * @throws RepositoryException if a repository error occurs */ - public String[] getNamespacePrefixes() throws RepositoryException { + public synchronized String[] getNamespacePrefixes() + throws RepositoryException { NamespaceRegistry registry = getWorkspace().getNamespaceRegistry(); String[] uris = registry.getURIs(); for (int i = 0; i < uris.length; i++) { @@ -175,7 +179,7 @@ * @throws NamespaceException if the mapping is illegal * @throws RepositoryException if a repository error occurs */ - public void setNamespacePrefix(String prefix, String uri) + public synchronized void setNamespacePrefix(String prefix, String uri) throws NamespaceException, RepositoryException { if (prefix == null) { throw new IllegalArgumentException("Prefix must not be null");