jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r349939 - /incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/NamespaceRegistryImpl.java
Date Wed, 30 Nov 2005 13:07:47 GMT
Author: stefan
Date: Wed Nov 30 05:07:44 2005
New Revision: 349939

URL: http://svn.apache.org/viewcvs?rev=349939&view=rev
Log:
JCR-283 NamespaceRegistry.registerNamespace(pre, uri) might accidentally remove namespace
in certain situations

Modified:
    incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/NamespaceRegistryImpl.java

Modified: incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/NamespaceRegistryImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/NamespaceRegistryImpl.java?rev=349939&r1=349938&r2=349939&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/NamespaceRegistryImpl.java
(original)
+++ incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/NamespaceRegistryImpl.java
Wed Nov 30 05:07:44 2005
@@ -239,18 +239,12 @@
                     + prefix + " -> " + uri + ": invalid prefix");
         }
 
+        // check existing mappings
         String oldPrefix = (String) uriToPrefix.get(uri);
-        if (oldPrefix != null) {
-            // existing namespace
-            if (oldPrefix.equals(prefix)) {
-                throw new NamespaceException("failed to register namespace "
-                        + prefix + " -> " + uri + ": mapping already exists");
-            }
-            // remove old prefix
-            prefixToURI.remove(oldPrefix);
-            uriToPrefix.remove(uri);
+        if (prefix.equals(oldPrefix)) {
+            throw new NamespaceException("failed to register namespace "
+                    + prefix + " -> " + uri + ": mapping already exists");
         }
-
         if (prefixToURI.containsKey(prefix)) {
             /**
              * prevent remapping of existing prefixes because this would in effect
@@ -263,6 +257,13 @@
                     + ": remapping existing prefixes is not supported.");
         }
 
+        if (oldPrefix != null) {
+            // remove old prefix mapping
+            prefixToURI.remove(oldPrefix);
+            uriToPrefix.remove(uri);
+        }
+
+        // add new prefix mapping
         prefixToURI.put(prefix, uri);
         uriToPrefix.put(uri, prefix);
 



Mime
View raw message