Return-Path: Mailing-List: contact tomcat-dev-help@jakarta.apache.org; run by ezmlm Delivered-To: mailing list tomcat-dev@jakarta.apache.org Received: (qmail 64544 invoked from network); 29 Jun 2000 18:59:19 -0000 Received: from adsl-63-198-47-229.dsl.snfc21.pacbell.net (HELO costin.dnt.ro) (63.198.47.229) by locus.apache.org with SMTP; 29 Jun 2000 18:59:19 -0000 Received: from eng.sun.com (costin [63.198.47.229]) by costin.dnt.ro (8.9.3+Sun/8.9.1) with ESMTP id LAA24516 for ; Thu, 29 Jun 2000 11:58:40 -0700 (PDT) Sender: costin@costin.dnt.ro Message-ID: <395B9DE5.63C5F538@eng.sun.com> Date: Thu, 29 Jun 2000 12:05:10 -0700 From: Costin Manolache X-Mailer: Mozilla 4.7 [en] (X11; I; Linux 2.2.12-20 i686) X-Accept-Language: en MIME-Version: 1.0 To: tomcat-dev@jakarta.apache.org Subject: Re: SimpleMapper2 References: <001501bfe1e3$3ae6e720$e900a8c0@oficina.com.ar> <395B7B79.EAA3478@eng.sun.com> <003201bfe1f0$fd018880$e900a8c0@oficina.com.ar> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Rating: locus.apache.org 1.6.2 0/1000/N > The web.xml reader calls addServletMapping in the Context that calls > addContainer in the CM that calls addContainer in SimpleMapper1 that calls > addMapping in PrefixMapper that adds a key context_path+servlet_path in the > hash. I can be wrong but I think you can have a /my/ctx context with a > /path/servlet/path servlet and a /my/ctx/path context with a /servlet/path > servlet in the same container. I can't find any code dealing with this but > from the following example I can figure out an algorithm to precompute that > context path / longest prefix path. As I said, the code may have bugs ( like not dealing with this case), but it can be fixed. The alghoritm is right ( I think ). > If you have this mappings: > > /A/B+/C --> servlet 1 > /A+/B/C --> servlet 2 > /A+/B/C/D --> servlet 3 > > as keys to the hash you will use only the first string, trivially discarding > the second one and discarding the third because a requestURI=/A/B/C/D would > first match /A+/B/C/D and be mapped to the servlet corresponding to /B/C/D > in the context /A instead of matching /A/B+/C and being mapped to the > servlet corresponding to /C in the context /A/B with the path info /D. So, > briefly, all keys prefixed with /A/B/C will be discarded if belonging to a > context with a path shorter than /A/B. A trivial fix is to do a check before adding a mapping: To add CPNew+SPNew: For each existing map CP+SP, if( (CP + SP)startsWith( CPNew )) remove CP+SP if( CPNew+ SPNew).startsWith( CP ) ) don't add the new mapping. > Have I understood you? Is the code really doing anything like this? No. It's a bug, but I would rather write a TreeMapper than fix SimpleMapper. Costin