tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kkoli...@apache.org
Subject svn commit: r1204856 - in /tomcat/trunk: java/org/apache/tomcat/util/http/mapper/Mapper.java test/org/apache/tomcat/util/http/mapper/TestMapper.java
Date Tue, 22 Nov 2011 08:34:08 GMT
Author: kkolinko
Date: Tue Nov 22 08:34:06 2011
New Revision: 1204856

URL: http://svn.apache.org/viewvc?rev=1204856&view=rev
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=52225
Fix ClassCastException in Alias added for existing host via JMX

Modified:
    tomcat/trunk/java/org/apache/tomcat/util/http/mapper/Mapper.java
    tomcat/trunk/test/org/apache/tomcat/util/http/mapper/TestMapper.java

Modified: tomcat/trunk/java/org/apache/tomcat/util/http/mapper/Mapper.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/http/mapper/Mapper.java?rev=1204856&r1=1204855&r2=1204856&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/http/mapper/Mapper.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/http/mapper/Mapper.java Tue Nov 22 08:34:06 2011
@@ -147,7 +147,7 @@ public final class Mapper {
         Host newHost = new Host();
         newHost.name = alias;
         newHost.contextList = realHost.contextList;
-        newHost.object = realHost;
+        newHost.object = realHost.object;
         if (insertMap(hosts, newHosts, newHost)) {
             hosts = newHosts;
         }

Modified: tomcat/trunk/test/org/apache/tomcat/util/http/mapper/TestMapper.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/tomcat/util/http/mapper/TestMapper.java?rev=1204856&r1=1204855&r2=1204856&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/tomcat/util/http/mapper/TestMapper.java (original)
+++ tomcat/trunk/test/org/apache/tomcat/util/http/mapper/TestMapper.java Tue Nov 22 08:34:06
2011
@@ -48,6 +48,7 @@ public class TestMapper {
         mapper.addHost("zzzuyopjvewpovewjhfewoih", new String[0], "blah12");
         mapper.addHost("xxxxgqwiwoih", new String[0], "blah13");
         mapper.addHost("qwigqwiwoih", new String[0], "blah14");
+        mapper.addHostAlias("iowejoiejfoiew", "iowejoiejfoiew_alias");
 
         mapper.setDefaultHostName("ylwrehirkuewh");
 
@@ -84,11 +85,13 @@ public class TestMapper {
 
     @Test
     public void testAddHost() throws Exception {
-        // Check we have the right number (add 16 but one is a duplicate)
-        assertEquals(15, mapper.hosts.length);
+        // Check we have the right number
+        // (added 17 including one host alias but one is a duplicate)
+        assertEquals(16, mapper.hosts.length);
 
         // Make sure adding a duplicate *does not* overwrite
-        assertEquals("blah7", mapper.hosts[3].object);
+        final int iowPos = 3;
+        assertEquals("blah7", mapper.hosts[iowPos].object);
 
         // Check for alphabetical order of host names
         String previous;
@@ -98,6 +101,14 @@ public class TestMapper {
             current = mapper.hosts[i].name;
             assertTrue(previous.compareTo(current) < 0);
         }
+
+        // Check that host alias has the same data
+        Mapper.Host host = mapper.hosts[iowPos];
+        Mapper.Host alias = mapper.hosts[iowPos + 1];
+        assertEquals("iowejoiejfoiew", host.name);
+        assertEquals("iowejoiejfoiew_alias", alias.name);
+        assertEquals(host.contextList, alias.contextList);
+        assertEquals(host.object, alias.object);
     }
 
     @Test
@@ -105,6 +116,8 @@ public class TestMapper {
         MappingData mappingData = new MappingData();
         MessageBytes host = MessageBytes.newInstance();
         host.setString("iowejoiejfoiew");
+        MessageBytes alias = MessageBytes.newInstance();
+        alias.setString("iowejoiejfoiew_alias");
         MessageBytes uri = MessageBytes.newInstance();
         uri.setString("/foo/bar/blah/bobou/foo");
         uri.toChars();
@@ -132,6 +145,19 @@ public class TestMapper {
         assertEquals("/bobou", mappingData.wrapperPath.toString());
         assertEquals("/foo", mappingData.pathInfo.toString());
         assertTrue(mappingData.redirectPath.isNull());
+
+        mappingData.recycle();
+        uri.setString("/foo/bar/bla/bobou/foo");
+        uri.toChars();
+        uri.getCharChunk().setLimit(-1);
+        mapper.map(alias, uri, null, mappingData);
+        assertEquals("blah7", mappingData.host);
+        assertEquals("context3", mappingData.context);
+        assertEquals("wrapper7", mappingData.wrapper);
+        assertEquals("/foo/bar/bla", mappingData.contextPath.toString());
+        assertEquals("/bobou", mappingData.wrapperPath.toString());
+        assertEquals("/foo", mappingData.pathInfo.toString());
+        assertTrue(mappingData.redirectPath.isNull());
     }
 
     @Test



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


Mime
View raw message