Author: markt
Date: Mon Aug  1 09:53:57 2016
New Revision: 1754718

URL: http://svn.apache.org/viewvc?rev=1754718&view=rev
Log:
Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=18500
The original request for regular expression support would be too expensive to 
implement.
This commit adds support for wild card host names.
It adds overhead for requests where the Host header is not an exact match since 
the code now has to convert the name in the header to the wild card form and 
then search for that.
However, this overhead is offset by caching the default host so it is not 
necessary to do a look up for the default host.
I've also expanded the performance tests. On my laptop the before and after 
results are broadly similar with some small improvements and some small 
increases.

Modified:
    tomcat/tc8.5.x/trunk/   (props changed)
    tomcat/tc8.5.x/trunk/java/org/apache/catalina/mapper/Mapper.java
    tomcat/tc8.5.x/trunk/test/org/apache/catalina/mapper/TestMapper.java
    
tomcat/tc8.5.x/trunk/test/org/apache/catalina/mapper/TestMapperPerformance.java
    tomcat/tc8.5.x/trunk/webapps/docs/changelog.xml
    tomcat/tc8.5.x/trunk/webapps/docs/config/host.xml

Propchange: tomcat/tc8.5.x/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Aug  1 09:53:57 2016
@@ -1 +1 @@
-/tomcat/trunk:1734785,1734799,1734845,1734928,1735041,1735044,1735480,1735577,1735597,1735599-1735600,1735615,1736145,1736162,1736209,1736280,1736297,1736299,1736489,1736646,1736703,1736836,1736849,1737104-1737105,1737112,1737117,1737119-1737120,1737155,1737157,1737192,1737280,1737339,1737632,1737664,1737715,1737748,1737785,1737834,1737860,1737903,1737959,1738005,1738007,1738014-1738015,1738018,1738022,1738039,1738043,1738059-1738060,1738147,1738149,1738174-1738175,1738261,1738589,1738623-1738625,1738643,1738816,1738850,1738855,1738946-1738948,1738953-1738954,1738979,1738982,1739079-1739081,1739087,1739113,1739153,1739172,1739176,1739191,1739474,1739726,1739762,1739775,1739814,1739817-1739818,1739975,1740131,1740324,1740465,1740495,1740508-1740509,1740520,1740535,1740707,1740803,1740810,1740969,1740980,1740991,1740997,1741015,1741033,1741036,1741058,1741060,1741080,1741147,1741159,1741164,1741173,1741181,1741190,1741197,1741202,1741208,1741213,1741221,1741225,1741232,1741409,1741501
 
,1741677,1741892,1741896,1741984,1742023,1742042,1742071,1742090,1742093,1742101,1742105,1742111,1742139,1742146,1742148,1742166,1742181,1742184,1742187,1742246,1742248-1742251,1742263-1742264,1742268,1742276,1742369,1742387,1742448,1742509-1742512,1742917,1742919,1742933,1742975-1742976,1742984,1742986,1743019,1743115,1743117,1743124-1743125,1743134,1743425,1743554,1743679,1743696-1743698,1743700-1743701,1744058,1744064-1744065,1744125,1744194,1744229,1744270,1744323,1744432,1744684,1744697,1744705,1744713,1744760,1744786,1745083,1745142-1745143,1745145,1745177,1745179-1745180,1745227,1745248,1745254,1745337,1745467,1745473,1745576,1745735,1745744,1746304,1746306-1746307,1746319,1746327,1746338,1746340-1746341,1746344,1746427,1746441,1746473,1746490,1746492,1746495-1746496,1746499-1746501,1746503-1746507,1746509,1746549,1746551,1746554,1746556,1746558,1746584,1746620,1746649,1746724,1746939,1746989,1747014,1747028,1747035,1747210,1747225,1747234,1747253,1747404,1747506,1747536,1747
 
924,1747980,1747993,1748001,1748253,1748452,1748547,1748629,1748676,1748715,1749287,1749296,1749328,1749373,1749465,1749506,1749508,1749665-1749666,1749763,1749865-1749866,1749898,1749978,1749980,1750011,1750015,1750056,1750480,1750617,1750634,1750692,1750697,1750700,1750703,1750707,1750714,1750718,1750723,1750899,1750975,1750995,1751061,1751097,1751438,1751447,1751463,1751702,1752212,1752737,1752745,1753358,1753363,1754111,1754140-1754141,1754281,1754310,1754467,1754613
+/tomcat/trunk:1734785,1734799,1734845,1734928,1735041,1735044,1735480,1735577,1735597,1735599-1735600,1735615,1736145,1736162,1736209,1736280,1736297,1736299,1736489,1736646,1736703,1736836,1736849,1737104-1737105,1737112,1737117,1737119-1737120,1737155,1737157,1737192,1737280,1737339,1737632,1737664,1737715,1737748,1737785,1737834,1737860,1737903,1737959,1738005,1738007,1738014-1738015,1738018,1738022,1738039,1738043,1738059-1738060,1738147,1738149,1738174-1738175,1738261,1738589,1738623-1738625,1738643,1738816,1738850,1738855,1738946-1738948,1738953-1738954,1738979,1738982,1739079-1739081,1739087,1739113,1739153,1739172,1739176,1739191,1739474,1739726,1739762,1739775,1739814,1739817-1739818,1739975,1740131,1740324,1740465,1740495,1740508-1740509,1740520,1740535,1740707,1740803,1740810,1740969,1740980,1740991,1740997,1741015,1741033,1741036,1741058,1741060,1741080,1741147,1741159,1741164,1741173,1741181,1741190,1741197,1741202,1741208,1741213,1741221,1741225,1741232,1741409,1741501
 
,1741677,1741892,1741896,1741984,1742023,1742042,1742071,1742090,1742093,1742101,1742105,1742111,1742139,1742146,1742148,1742166,1742181,1742184,1742187,1742246,1742248-1742251,1742263-1742264,1742268,1742276,1742369,1742387,1742448,1742509-1742512,1742917,1742919,1742933,1742975-1742976,1742984,1742986,1743019,1743115,1743117,1743124-1743125,1743134,1743425,1743554,1743679,1743696-1743698,1743700-1743701,1744058,1744064-1744065,1744125,1744194,1744229,1744270,1744323,1744432,1744684,1744697,1744705,1744713,1744760,1744786,1745083,1745142-1745143,1745145,1745177,1745179-1745180,1745227,1745248,1745254,1745337,1745467,1745473,1745576,1745735,1745744,1746304,1746306-1746307,1746319,1746327,1746338,1746340-1746341,1746344,1746427,1746441,1746473,1746490,1746492,1746495-1746496,1746499-1746501,1746503-1746507,1746509,1746549,1746551,1746554,1746556,1746558,1746584,1746620,1746649,1746724,1746939,1746989,1747014,1747028,1747035,1747210,1747225,1747234,1747253,1747404,1747506,1747536,1747
 
924,1747980,1747993,1748001,1748253,1748452,1748547,1748629,1748676,1748715,1749287,1749296,1749328,1749373,1749465,1749506,1749508,1749665-1749666,1749763,1749865-1749866,1749898,1749978,1749980,1750011,1750015,1750056,1750480,1750617,1750634,1750692,1750697,1750700,1750703,1750707,1750714,1750718,1750723,1750899,1750975,1750995,1751061,1751097,1751173,1751438,1751447,1751463,1751702,1752212,1752737,1752745,1753358,1753363,1754111,1754140-1754141,1754281,1754310,1754467,1754613

Modified: tomcat/tc8.5.x/trunk/java/org/apache/catalina/mapper/Mapper.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/catalina/mapper/Mapper.java?rev=1754718&r1=1754717&r2=1754718&view=diff
==============================================================================
--- tomcat/tc8.5.x/trunk/java/org/apache/catalina/mapper/Mapper.java (original)
+++ tomcat/tc8.5.x/trunk/java/org/apache/catalina/mapper/Mapper.java Mon Aug  1 
09:53:57 2016
@@ -65,6 +65,7 @@ public final class Mapper {
      * Default host name.
      */
     private String defaultHostName = null;
+    private volatile MappedHost defaultHost = null;
 
 
     /**
@@ -82,10 +83,16 @@ public final class Mapper {
      *
      * @param defaultHostName Default host name
      */
-    public void setDefaultHostName(String defaultHostName) {
-        this.defaultHostName = defaultHostName;
+    public synchronized void setDefaultHostName(String defaultHostName) {
+        this.defaultHostName = renameWildcardHost(defaultHostName);
+        if (this.defaultHostName == null) {
+            defaultHost = null;
+        } else {
+            defaultHost = exactFind(hosts, this.defaultHostName);
+        }
     }
 
+
     /**
      * Add a new host to the mapper.
      *
@@ -95,10 +102,14 @@ public final class Mapper {
      */
     public synchronized void addHost(String name, String[] aliases,
                                      Host host) {
+        name = renameWildcardHost(name);
         MappedHost[] newHosts = new MappedHost[hosts.length + 1];
         MappedHost newHost = new MappedHost(name, host);
         if (insertMap(hosts, newHosts, newHost)) {
             hosts = newHosts;
+            if (newHost.name.equals(defaultHostName)) {
+                defaultHost = newHost;
+            }
             if (log.isDebugEnabled()) {
                 log.debug(sm.getString("mapper.addHost.success", name));
             }
@@ -121,6 +132,7 @@ public final class Mapper {
         }
         List<MappedHost> newAliases = new ArrayList<>(aliases.length);
         for (String alias : aliases) {
+            alias = renameWildcardHost(alias);
             MappedHost newAlias = new MappedHost(alias, newHost);
             if (addHostAliasImpl(newAlias)) {
                 newAliases.add(newAlias);
@@ -136,6 +148,7 @@ public final class Mapper {
      * @param name Virtual host name
      */
     public synchronized void removeHost(String name) {
+        name = renameWildcardHost(name);
         // Find and remove the old host
         MappedHost host = exactFind(hosts, name);
         if (host == null || host.isAlias()) {
@@ -164,6 +177,7 @@ public final class Mapper {
             // just in case...
             return;
         }
+        alias = renameWildcardHost(alias);
         MappedHost newAlias = new MappedHost(alias, realHost);
         if (addHostAliasImpl(newAlias)) {
             realHost.addAlias(newAlias);
@@ -174,6 +188,9 @@ public final class Mapper {
         MappedHost[] newHosts = new MappedHost[hosts.length + 1];
         if (insertMap(hosts, newHosts, newAlias)) {
             hosts = newHosts;
+            if (newAlias.name.equals(defaultHostName)) {
+                defaultHost = newAlias;
+            }
             if (log.isDebugEnabled()) {
                 log.debug(sm.getString("mapper.addHostAlias.success",
                         newAlias.name, newAlias.getRealHostName()));
@@ -202,6 +219,7 @@ public final class Mapper {
      * @param alias The alias to remove
      */
     public synchronized void removeHostAlias(String alias) {
+        alias = renameWildcardHost(alias);
         // Find and remove the alias
         MappedHost hostMapping = exactFind(hosts, alias);
         if (hostMapping == null || !hostMapping.isAlias()) {
@@ -244,6 +262,8 @@ public final class Mapper {
             String version, Context context, String[] welcomeResources,
             WebResourceRoot resources, Collection<WrapperMappingInfo> 
wrappers) {
 
+        hostName = renameWildcardHost(hostName);
+
         MappedHost mappedHost  = exactFind(hosts, hostName);
         if (mappedHost == null) {
             addHost(hostName, new String[0], host);
@@ -308,6 +328,7 @@ public final class Mapper {
     public void removeContextVersion(Context ctxt, String hostName,
             String path, String version) {
 
+        hostName = renameWildcardHost(hostName);
         contextObjectToContextVersionMap.remove(ctxt);
 
         MappedHost host = exactFind(hosts, hostName);
@@ -351,7 +372,7 @@ public final class Mapper {
      */
     public void pauseContextVersion(Context ctxt, String hostName,
             String contextPath, String version) {
-
+        hostName = renameWildcardHost(hostName);
         ContextVersion contextVersion = findContextVersion(hostName,
                 contextPath, version, true);
         if (contextVersion == null || !ctxt.equals(contextVersion.object)) {
@@ -393,6 +414,7 @@ public final class Mapper {
     public void addWrapper(String hostName, String contextPath, String version,
                            String path, Wrapper wrapper, boolean jspWildCard,
                            boolean resourceOnly) {
+        hostName = renameWildcardHost(hostName);
         ContextVersion contextVersion = findContextVersion(hostName,
                 contextPath, version, false);
         if (contextVersion == null) {
@@ -403,6 +425,7 @@ public final class Mapper {
 
     public void addWrappers(String hostName, String contextPath,
             String version, Collection<WrapperMappingInfo> wrappers) {
+        hostName = renameWildcardHost(hostName);
         ContextVersion contextVersion = findContextVersion(hostName,
                 contextPath, version, false);
         if (contextVersion == null) {
@@ -503,6 +526,7 @@ public final class Mapper {
      */
     public void removeWrapper(String hostName, String contextPath,
             String version, String path) {
+        hostName = renameWildcardHost(hostName);
         ContextVersion contextVersion = findContextVersion(hostName,
                 contextPath, version, true);
         if (contextVersion == null || contextVersion.isPaused()) {
@@ -587,6 +611,7 @@ public final class Mapper {
      */
     public void addWelcomeFile(String hostName, String contextPath, String 
version,
             String welcomeFile) {
+        hostName = renameWildcardHost(hostName);
         ContextVersion contextVersion = findContextVersion(hostName, 
contextPath, version, false);
         if (contextVersion == null) {
             return;
@@ -609,6 +634,7 @@ public final class Mapper {
      */
     public void removeWelcomeFile(String hostName, String contextPath,
             String version, String welcomeFile) {
+        hostName = renameWildcardHost(hostName);
         ContextVersion contextVersion = findContextVersion(hostName, 
contextPath, version, false);
         if (contextVersion == null || contextVersion.isPaused()) {
             return;
@@ -641,6 +667,7 @@ public final class Mapper {
      * @param version     The version of the context to be cleared
      */
     public void clearWelcomeFiles(String hostName, String contextPath, String 
version) {
+        hostName = renameWildcardHost(hostName);
         ContextVersion contextVersion = findContextVersion(hostName, 
contextPath, version, false);
         if (contextVersion == null) {
             return;
@@ -719,12 +746,24 @@ public final class Mapper {
         MappedHost[] hosts = this.hosts;
         MappedHost mappedHost = exactFindIgnoreCase(hosts, host);
         if (mappedHost == null) {
-            if (defaultHostName == null) {
-                return;
+            // Note: Internally, the Mapper does not use the leading * on a
+            //       wildcard host. This is to allow this shortcut.
+            int firstDot = host.indexOf('.');
+            if (firstDot > -1) {
+                int offset = host.getOffset();
+                try {
+                    host.setOffset(firstDot + offset);
+                    mappedHost = exactFindIgnoreCase(hosts, host);
+                } finally {
+                    // Make absolutely sure this gets reset
+                    host.setOffset(offset);
+                }
             }
-            mappedHost = exactFind(hosts, defaultHostName);
             if (mappedHost == null) {
-                return;
+                mappedHost = defaultHost;
+                if (mappedHost == null) {
+                    return;
+                }
             }
         }
         mappingData.host = mappedHost.object;
@@ -1496,6 +1535,22 @@ public final class Mapper {
     }
 
 
+    /*
+     * To simplify the mapping process, wild card hosts take the form
+     * ".apache.org" rather than "*.apache.org" internally. However, for ease
+     * of use the external form remains "*.apache.org". Any host name passed
+     * into this class needs to be passed through this method to rename and
+     * wild card host names from the external to internal form.
+     */
+    private static String renameWildcardHost(String hostName) {
+        if (hostName.startsWith("*.")) {
+            return hostName.substring(1);
+        } else {
+            return hostName;
+        }
+    }
+
+
     // ------------------------------------------------- MapElement Inner Class
 
 

Modified: tomcat/tc8.5.x/trunk/test/org/apache/catalina/mapper/TestMapper.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/test/org/apache/catalina/mapper/TestMapper.java?rev=1754718&r1=1754717&r2=1754718&view=diff
==============================================================================
--- tomcat/tc8.5.x/trunk/test/org/apache/catalina/mapper/TestMapper.java 
(original)
+++ tomcat/tc8.5.x/trunk/test/org/apache/catalina/mapper/TestMapper.java Mon 
Aug  1 09:53:57 2016
@@ -88,6 +88,9 @@ public class TestMapper extends LoggingB
         mapper.addHost("zzzuyopjvewpovewjhfewoih", new String[0], 
createHost("blah12"));
         mapper.addHost("xxxxgqwiwoih", new String[0], createHost("blah13"));
         mapper.addHost("qwigqwiwoih", new String[0], createHost("blah14"));
+        mapper.addHost("qwerty.net", new String[0], createHost("blah15"));
+        mapper.addHost("*.net", new String[0], createHost("blah16"));
+        mapper.addHost("zzz.com", new String[0], createHost("blah17"));
         mapper.addHostAlias("iowejoiejfoiew", "iowejoiejfoiew_alias");
 
         mapper.setDefaultHostName("ylwrehirkuewh");
@@ -135,6 +138,14 @@ public class TestMapper extends LoggingB
                 null,
                 Arrays.asList(new WrapperMappingInfo[] { new 
WrapperMappingInfo(
                         "/bobou/*", createWrapper("wrapper7"), false, false) 
}));
+
+        host = createHost("blah16");
+        mapper.addContextVersion("*.net", host, "", "0", 
createContext("context4"),
+                new String[0], null, null);
+        mapper.addWrappers("*.net", "", "0", Arrays
+                .asList(new WrapperMappingInfo[] {
+                        new WrapperMappingInfo("/",
+                                createWrapper("context4-defaultWrapper"), 
false, false) }));
     }
 
     @Test
@@ -153,14 +164,14 @@ public class TestMapper extends LoggingB
         mapper.addHostAlias("iowejoiejfoiew", "iowejoiejfoiew_alias");
 
         // Check we have the right number
-        // (added 16 including one host alias. Three duplicates do not 
increase the count.)
-        assertEquals(16, mapper.hosts.length);
+        // (added 17 including one host alias. Three duplicates do not 
increase the count.)
+        assertEquals(19, mapper.hosts.length);
 
         // Make sure adding a duplicate *does not* overwrite
-        final int iowPos = 3;
+        final int iowPos = 4;
         assertEquals("blah7", mapper.hosts[iowPos].object.getName());
 
-        final int qwigPos = 8;
+        final int qwigPos = 10;
         assertEquals("blah14", mapper.hosts[qwigPos].object.getName());
 
         // Check for alphabetical order of host names
@@ -185,38 +196,38 @@ public class TestMapper extends LoggingB
         Host hostZ = createHost("zzzz");
         Context contextZ = createContext("contextZ");
 
-        assertEquals(16, mapper.hosts.length);
+        assertEquals(19, mapper.hosts.length);
         mapper.addContextVersion("zzzz", hostZ, "/", "", contextZ, null, null,
                 null);
-        assertEquals(17, mapper.hosts.length);
+        assertEquals(20, mapper.hosts.length);
 
         mapper.addHost("zzzz", new String[] { "zzzz_alias1", "zzzz_alias2" },
                 hostZ);
-        assertEquals(19, mapper.hosts.length);
+        assertEquals(22, mapper.hosts.length);
 
-        assertEquals("zzzz", mapper.hosts[16].name);
-        assertEquals("zzzz_alias1", mapper.hosts[17].name);
-        assertEquals("zzzz_alias2", mapper.hosts[18].name);
-        assertEquals(2, mapper.hosts[16].getAliases().size());
+        assertEquals("zzzz", mapper.hosts[19].name);
+        assertEquals("zzzz_alias1", mapper.hosts[20].name);
+        assertEquals("zzzz_alias2", mapper.hosts[21].name);
+        assertEquals(2, mapper.hosts[19].getAliases().size());
         assertSame(contextZ,
-                mapper.hosts[16].contextList.contexts[0].versions[0].object);
+                mapper.hosts[19].contextList.contexts[0].versions[0].object);
         assertSame(contextZ,
-                mapper.hosts[18].contextList.contexts[0].versions[0].object);
+                mapper.hosts[21].contextList.contexts[0].versions[0].object);
     }
 
     @Test
     public void testRemoveHost() {
-        assertEquals(16, mapper.hosts.length);
+        assertEquals(19, mapper.hosts.length);
         mapper.removeHostAlias("iowejoiejfoiew");
         mapper.removeHost("iowejoiejfoiew_alias");
-        assertEquals(16, mapper.hosts.length); // No change
+        assertEquals(19, mapper.hosts.length); // No change
         mapper.removeHostAlias("iowejoiejfoiew_alias");
-        assertEquals(15, mapper.hosts.length); // Removed
+        assertEquals(18, mapper.hosts.length); // Removed
 
         mapper.addHostAlias("iowejoiejfoiew", "iowejoiejfoiew_alias");
-        assertEquals(16, mapper.hosts.length);
+        assertEquals(19, mapper.hosts.length);
 
-        final int iowPos = 3;
+        final int iowPos = 4;
         Mapper.MappedHost hostMapping = mapper.hosts[iowPos];
         Mapper.MappedHost aliasMapping = mapper.hosts[iowPos + 1];
         assertEquals("iowejoiejfoiew_alias", aliasMapping.name);
@@ -229,7 +240,7 @@ public class TestMapper extends LoggingB
         assertSame(hostMapping, aliasMapping.getRealHost());
 
         mapper.removeHost("iowejoiejfoiew");
-        assertEquals(14, mapper.hosts.length); // Both host and alias removed
+        assertEquals(17, mapper.hosts.length); // Both host and alias removed
         for (Mapper.MappedHost host : mapper.hosts) {
             assertTrue(host.name, !host.name.startsWith("iowejoiejfoiew"));
         }
@@ -240,6 +251,8 @@ public class TestMapper extends LoggingB
         MappingData mappingData = new MappingData();
         MessageBytes host = MessageBytes.newInstance();
         host.setString("iowejoiejfoiew");
+        MessageBytes wildcard = MessageBytes.newInstance();
+        wildcard.setString("foo.net");
         MessageBytes alias = MessageBytes.newInstance();
         alias.setString("iowejoiejfoiew_alias");
         MessageBytes uri = MessageBytes.newInstance();
@@ -271,6 +284,20 @@ public class TestMapper extends LoggingB
         assertTrue(mappingData.redirectPath.isNull());
 
         mappingData.recycle();
+        uri.recycle();
+        uri.setString("/foo/bar/bla/bobou/foo");
+        uri.toChars();
+        uri.getCharChunk().setLimit(-1);
+        mapper.map(wildcard, uri, null, mappingData);
+        assertEquals("blah16", mappingData.host.getName());
+        assertEquals("context4", mappingData.context.getName());
+        assertEquals("context4-defaultWrapper", mappingData.wrapper.getName());
+        assertEquals("", mappingData.contextPath.toString());
+        assertEquals("/foo/bar/bla/bobou/foo", 
mappingData.wrapperPath.toString());
+        assertTrue(mappingData.pathInfo.isNull());
+        assertTrue(mappingData.redirectPath.isNull());
+
+        mappingData.recycle();
         uri.setString("/foo/bar/bla/bobou/foo");
         uri.toChars();
         uri.getCharChunk().setLimit(-1);
@@ -287,7 +314,7 @@ public class TestMapper extends LoggingB
     @Test
     public void testAddRemoveContextVersion() throws Exception {
         final String hostName = "iowejoiejfoiew";
-        final int iowPos = 3;
+        final int iowPos = 4;
         final String contextPath = "/foo/bar";
         final int contextPos = 2;
 
@@ -394,7 +421,7 @@ public class TestMapper extends LoggingB
     @Test
     public void testReloadContextVersion() throws Exception {
         final String hostName = "iowejoiejfoiew";
-        final int iowPos = 3;
+        final int iowPos = 4;
         final String contextPath = "/foo/bar";
         final int contextPos = 2;
 

Modified: 
tomcat/tc8.5.x/trunk/test/org/apache/catalina/mapper/TestMapperPerformance.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/test/org/apache/catalina/mapper/TestMapperPerformance.java?rev=1754718&r1=1754717&r2=1754718&view=diff
==============================================================================
--- 
tomcat/tc8.5.x/trunk/test/org/apache/catalina/mapper/TestMapperPerformance.java 
(original)
+++ 
tomcat/tc8.5.x/trunk/test/org/apache/catalina/mapper/TestMapperPerformance.java 
Mon Aug  1 09:53:57 2016
@@ -26,24 +26,42 @@ public class TestMapperPerformance exten
 
     @Test
     public void testPerformance() throws Exception {
+        String[] requestedHostNames = new String[] {
+                "xxxxxxxxxxx",
+                "iowejoiejfoiew",
+                "iowejoiejfoiex",
+                "owefojiwefoi",
+                "owefojiwefoix",
+                "qwerty.net",
+                "foo.net",
+                "zzz.com",
+                "abc.com"};
+
+        for (String requestedHostName : requestedHostNames) {
+            testPerformance(requestedHostName);
+        }
+    }
+
+    private void testPerformance(String requestedHostName) throws Exception {
         // Takes ~1s on markt's laptop. If this takes more than 5s something
         // probably needs looking at. If this fails repeatedly then we may need
         // to increase this limit.
         final long maxTime = 5000;
-        long time = testPerformanceImpl();
+        long time = testPerformanceImpl(requestedHostName);
+        log.info("Host [" + requestedHostName + "], Time [" + time + "]ms");
         if (time >= maxTime) {
             // Rerun to reject occasional failures, e.g. because of gc
             log.warn("testPerformance() test completed in " + time + " ms");
-            time = testPerformanceImpl();
+            time = testPerformanceImpl(requestedHostName);
             log.warn("testPerformance() test rerun completed in " + time + " 
ms");
         }
         assertTrue(String.valueOf(time), time < maxTime);
     }
 
-    private long testPerformanceImpl() throws Exception {
+    private long testPerformanceImpl(String requestedHostName) throws 
Exception {
         MappingData mappingData = new MappingData();
         MessageBytes host = MessageBytes.newInstance();
-        host.setString("iowejoiejfoiew");
+        host.setString(requestedHostName);
         MessageBytes uri = MessageBytes.newInstance();
         uri.setString("/foo/bar/blah/bobou/foo");
         uri.toChars();

Modified: tomcat/tc8.5.x/trunk/webapps/docs/changelog.xml
URL: 
http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/webapps/docs/changelog.xml?rev=1754718&r1=1754717&r2=1754718&view=diff
==============================================================================
--- tomcat/tc8.5.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc8.5.x/trunk/webapps/docs/changelog.xml Mon Aug  1 09:53:57 2016
@@ -48,6 +48,12 @@
   <subsection name="Catalina">
     <changelog>
       <fix>
+        <bug>18500</bug>: Add limited support for wildcard host names and host
+        aliases. Names of the form <code>*.domainname</code> are now permitted.
+        Note that an exact host name match takes precedence over a wild card
+        host name match. (markt)
+      </fix>
+      <fix>
         <bug>59813</bug>: Ensure that circular relations of the Class-Path
         attribute from JAR manifests will be processed correctly. (violetagg)
       </fix>

Modified: tomcat/tc8.5.x/trunk/webapps/docs/config/host.xml
URL: 
http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/webapps/docs/config/host.xml?rev=1754718&r1=1754717&r2=1754718&view=diff
==============================================================================
--- tomcat/tc8.5.x/trunk/webapps/docs/config/host.xml (original)
+++ tomcat/tc8.5.x/trunk/webapps/docs/config/host.xml Mon Aug  1 09:53:57 2016
@@ -192,7 +192,10 @@
         have a name that matches the <code>defaultHost</code> setting for that
         Engine.  See <a href="#Host_Name_Aliases">Host Name Aliases</a> for
         information on how to assign more than one network name to the same
-        virtual host.</p>
+        virtual host. If the name takes the form of <code>*.domainname</code>
+        (e.g. <code>*.apache.org</code>) then it will be treated as a match for
+        any host in that domain unless a host that has an exactly matching name
+        is found.</p>
       </attribute>
 
       <attribute name="startStopThreads" required="false">
@@ -476,6 +479,10 @@
     involved must be registered in your DNS server to resolve to the
     same computer that is running this instance of Catalina.</p>
 
+    <p>Aliases may also use the wildcard form (<code>*.domainname</code>)
+       permitted for the <strong>name</strong> attribute of a
+       <strong>Host</strong>.</p>
+
   </subsection>
 
 



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

Reply via email to