Jean, First of all, thanks for looking into the unit tests and enhancing them! When deploying ServiceMix stand-alone, it will be running its own Jetty instance but when running in web container, it will use a plain Servlet in the web container to handle the HTTP requests. The ManagedContextManager is used there to keep track of the HTTP context paths that are being handled by the servlet.
This bit of code here is meant to normalize the context paths, making sure that all of them have the same leading/trailing slashes. My guess is that this a bug in the codebase and that the code should by trying to add a slash at the beginning if there isn't one yet (like what happens in the HttpConfiguration.setMapping() method). Regards, Gert Vanthienen ------------------------ Open Source SOA: http://fusesource.com Blog: http://gertvanthienen.blogspot.com/ 2009/5/12 Jean Jacobs <[email protected]>: > Hi, > > I'm in the process of adding unit tests for the servicemix-http > component. One of the classes in this component is called > ManagedContextManager. It has a method called createContext() to add a > context for a given URL and HTTP processor to the map of managed > contexts. There is some code in that method that is confusing. > Following is the implementation of the method: > > public synchronized Object createContext(String strUrl, > HttpProcessor processor) throws Exception { > URI uri = new URI(strUrl); > String path = uri.getPath(); > if (!path.startsWith("/")) { > path = path + "/"; > } > if (!path.endsWith("/")) { > path = path + "/"; > } > managedContexts.put(path, processor); > return path; > } > > Why would one append "/" if the path did not start with "/"? Couldn't > this possibly lead to a path with "//" at the end? Is this the intended > behavior? I searched all of the smx4 code to see where this class is > used and I could not find where it is used. Is it possible that this > class is not used? > > Thanks for your help, > > Jean > > *********************************************** > Jean Jacobs > Software QA Architect > Progress Software Corporation > 14 Oak Park Drive > Bedford, MA 01730 > [email protected] > *********************************************** > > >
