On a system running tomcat 6.0.14 we encountered the problem, that the specified docBase of the default Host of an Engine is being overwritten, when an Alias with the same name (as the default Host) is defined on a different Host of the same Engine. The user should be warned if the docBase of the default Host is being changed to the one of an Alias. When using tomcat 6.0.13 this problem didn't occur; means that the docBase of the default Host remained the same for an equal configuration. Are there any future plans on providing such a warning? Best regards, Jan
There are so many ways to do bad things with the configuration files I am not sure we could reasonably catch them all or should even try. That said, if you want to provide a patch it will be considered. Keep in mind that the more invasive the patch, the less likely it is to be considered.
I guess this only thing needed is to utter a "SEVERE" warning when org.apache.tomcat.util.http.mapper.Mapper.Context.extensionWrappers are created that overwrite a pre-existing one...
No patch has been provided for consideration.
Reopening. From looking into this, I think messing up host and alias names can really be a surprise for a sloppy admin. In the Mapper class the hosts and aliases are in the same list. Duplicates are silently prevented by Mapper.insertMap() with the "first come, first served" behaviour. The results may be surprising. I have a patch for this. A test case: Configure the following hosts in server.xml: [[[ <Host name="localhost" appBase="webapps"> <!-- Alias equal to the name of its own Host is OK. --> <Alias>localhost</Alias> </Host> <Host name="second" appBase="secondwebapps"> <Alias>localhost</Alias> </Host> <Host name="third" appBase="thirdwebapps"> <Alias>fourth</Alias> </Host> <Host name="fourth" appBase="fourthwebapps"> <Alias>localhost</Alias> <Alias>second</Alias> </Host> ]]] There is also a bug in Mapper.removeHost(name): If host with such name is not registered in the mapper, it results in NPE at "if (newHosts[i].object == host)" line. (The find() method returns the closest match. To check that the correct item was found, one has to compare names).
Fixed in Tomcat 8 by r1604066 and will be in 8.0.10 onwards.
(In reply to Konstantin Kolinko from comment #4) > There is also a bug in Mapper.removeHost(name): > If host with such name is not registered in the mapper, it results in NPE > at "if (newHosts[i].object == host)" line. For a record: The bug in removeHost(), removeHostAlias() that was fixed here is more serious than just an NPE. The bug is that those methods may remove a wrong host. They remove whatever host is located at hosts[pos], but the find() method does not return the exact name match, but closest name.
Fixed in Tomcat 7 by r1604895 and will be in 7.0.55 onwards.
Created attachment 31744 [details] 2014-06-23_tc6_44312.patch Patch that will be proposed for Tomcat 6. TestMapper includes test case for bug 56653 (testContextListConcurrencyBug56653)
Tomcat 6 reached EOL without this patch being applied.