costin 01/07/02 12:37:57
Modified: src/share/org/apache/tomcat/modules/mappers
SimpleMapper1.java
Log:
Fix removeContext, it had a number of big problems when the context was the
ROOT context.
Many thanks to Remus Jivcu for finding the bug and the cause.
Revision Changes Path
1.5 +13 -4
jakarta-tomcat/src/share/org/apache/tomcat/modules/mappers/SimpleMapper1.java
Index: SimpleMapper1.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/mappers/SimpleMapper1.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- SimpleMapper1.java 2001/06/08 03:08:23 1.4
+++ SimpleMapper1.java 2001/07/02 19:37:54 1.5
@@ -144,7 +144,7 @@
throws TomcatException
{
if(debug>0) log( "Removed from maps ");
- map.removeAllMappings( ctx.getHost(), ctx.getPath());
+ map.removeAllMappings( ctx.getHost(), ctx);
// extension mappings are local to ctx, no need to do something
// about that
}
@@ -435,6 +435,7 @@
* @author [EMAIL PROTECTED]
*/
class PrefixMapper {
+ private static int debug=1;
// host -> PrefixMapper for virtual hosts
// hosts are stored in lower case ( the "common" case )
SimpleHashtable vhostMaps=new SimpleHashtable();
@@ -473,7 +474,7 @@
/** Remove all mappings matching path
*/
- public void removeAllMappings( String host, String path ) {
+ public void removeAllMappings( String host, Context ctx ) {
PrefixMapper vmap=this;
if( host!=null ) {
host=host.toLowerCase();
@@ -484,15 +485,23 @@
Enumeration en=vmap.prefixMappedServlets.keys();
while( en.hasMoreElements() ) {
String s=(String)en.nextElement();
- if( s.startsWith( path ))
+ Container ct=(Container)vmap.prefixMappedServlets.get( s );
+ if( ct.getContext() == ctx ) {
+ if(debug > 0 )
+ ctx.log( "Remove mapping " + s );
vmap.prefixMappedServlets.remove( s );
+ }
}
en=vmap.exactMappedServlets.keys();
while( en.hasMoreElements() ) {
String s=(String)en.nextElement();
- if( s.startsWith( path ))
+ Container ct=(Container)vmap.exactMappedServlets.get( s );
+ if( ct.getContext() == ctx ) {
+ if(debug > 0 )
+ ctx.log( "Remove mapping " + s );
vmap.exactMappedServlets.remove( s );
+ }
}
// reset the cache
mapCache=new SimpleHashtable();