jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
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 GMT
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.
+     * <p>
+     * This map is only accessed from synchronized methods (see
+     * <a href="https://issues.apache.org/jira/browse/JCR-1793">JCR-1793</a>).
      */
     private final Map namespaces = new HashMap();
 
@@ -66,7 +69,7 @@
      * <code>super.logout()</code> 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");



Mime
View raw message