tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1592052 - in /tomcat/tc7.0.x/trunk: java/org/apache/naming/resources/BaseDirContext.java test/org/apache/naming/resources/TestNamingContext.java webapps/docs/changelog.xml
Date Fri, 02 May 2014 21:52:12 GMT
Author: markt
Date: Fri May  2 21:52:12 2014
New Revision: 1592052

URL: http://svn.apache.org/r1592052
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=56451
Make resources accessed via a context alias accessible via JNDI in the same way standard resources
are available.

Modified:
    tomcat/tc7.0.x/trunk/java/org/apache/naming/resources/BaseDirContext.java
    tomcat/tc7.0.x/trunk/test/org/apache/naming/resources/TestNamingContext.java
    tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml

Modified: tomcat/tc7.0.x/trunk/java/org/apache/naming/resources/BaseDirContext.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/naming/resources/BaseDirContext.java?rev=1592052&r1=1592051&r2=1592052&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/naming/resources/BaseDirContext.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/naming/resources/BaseDirContext.java Fri May  2 21:52:12
2014
@@ -181,11 +181,7 @@ public abstract class BaseDirContext imp
      * Add an alias.
      */
     public void addAlias(String path, BaseDirContext dirContext) {
-        if (!path.startsWith("/")) {
-            throw new IllegalArgumentException(
-                    sm.getString("resources.invalidAliasPath", path));
-        }
-        aliases.put(path, dirContext);
+        aliases.put(convertPathToName(path), dirContext);
     }
 
     
@@ -193,14 +189,21 @@ public abstract class BaseDirContext imp
      * Remove an alias.
      */
     public void removeAlias(String path) {
+        aliases.remove(convertPathToName(path));
+    }
+    
+    
+    private String convertPathToName(String path) {
+        // Path should have a leading /
         if (!path.startsWith("/")) {
             throw new IllegalArgumentException(
                     sm.getString("resources.invalidAliasPath", path));
         }
-        aliases.remove(path);
+        
+        // Name should not have a leading /
+        return path.substring(1);
     }
     
-    
     /**
      * Get the current alias configuration in String form. If no aliases are
      * configured, an empty string will be returned.
@@ -217,6 +220,7 @@ public abstract class BaseDirContext imp
                 result.append(',');
             }
             Entry<String,BaseDirContext> entry = iter.next();
+            result.append('/');
             result.append(entry.getKey());
             result.append('=');
             result.append(entry.getValue().getDocBase());

Modified: tomcat/tc7.0.x/trunk/test/org/apache/naming/resources/TestNamingContext.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/naming/resources/TestNamingContext.java?rev=1592052&r1=1592051&r2=1592052&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/test/org/apache/naming/resources/TestNamingContext.java (original)
+++ tomcat/tc7.0.x/trunk/test/org/apache/naming/resources/TestNamingContext.java Fri May 
2 21:52:12 2014
@@ -148,7 +148,7 @@ public class TestNamingContext extends T
                        +",/a2=" + alternate2.getCanonicalPath());
 
         // Check first alias
-        Object file = ctx.lookup("/a1/test1.txt");
+        Object file = ctx.lookup("a1/test1.txt");
 
         Assert.assertNotNull(file);
         Assert.assertTrue(file instanceof Resource);
@@ -168,7 +168,7 @@ public class TestNamingContext extends T
         assertEquals(foxText, contents);
 
         // Check second alias
-        file = ctx.lookup("/a2/test2.txt");
+        file = ctx.lookup("a2/test2.txt");
 
         Assert.assertNotNull(file);
         Assert.assertTrue(file instanceof Resource);
@@ -191,7 +191,7 @@ public class TestNamingContext extends T
                        + ",");
 
         // Check first alias
-        file = ctx.lookup("/a1/test1.txt");
+        file = ctx.lookup("a1/test1.txt");
 
         Assert.assertNotNull(file);
         Assert.assertTrue(file instanceof Resource);
@@ -208,7 +208,7 @@ public class TestNamingContext extends T
         assertEquals(foxText, contents);
 
         // Check second alias
-        file = ctx.lookup("/a2/test2.txt");
+        file = ctx.lookup("a2/test2.txt");
 
         Assert.assertNotNull(file);
         Assert.assertTrue(file instanceof Resource);

Modified: tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml?rev=1592052&r1=1592051&r2=1592052&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Fri May  2 21:52:12 2014
@@ -136,6 +136,10 @@
         problem is encountered calling a getter or setter on a component
         attribute. The logging level is raised from debug to warning. (markt)
       </fix>
+      <fix>
+        <bug>56451</bug>: Make resources accessed via a context alias accessible
+        via JNDI in the same way standard resources are available. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Coyote">



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message