Bug 35769

Summary: Wrong implementation of javax.naming.Context.composeName
Product: Tomcat 4 Reporter: Laurent Simon <asfBugzilla.stratic>
Component: CatalinaAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: 4.1.31   
Target Milestone: ---   
Hardware: All   
OS: All   

Description Laurent Simon 2005-07-17 05:00:06 UTC
The implementation of javax.naming.Context.composeName( Name, Name) is wrong and
return erroneous results.

In following classes:
- org.apache.naming.NamingContext
- org.apache.naming.BaseDirContext
- org.apache.naming.ProxyDirContext
- org.apache.naming.SelectorContext

The current implementation is:

    public Name composeName(Name name, Name prefix)
    throws NamingException {
	prefix = (Name) name.clone();   // here is the error
	return prefix.addAll(name);
    }

So, on a Context ctx
A call like ctx.composeName("foo/bar", "example/prefix")	
might return a Name like "example/prefix/foo/bar"
but actually return "foo/bar/foo/bar" !

The correct implementation is:

    public Name composeName(Name name, Name prefix)
    throws NamingException {
	prefix = (Name) prefix.clone();
	return prefix.addAll(name);
    }
Comment 1 Mark Thomas 2005-07-20 23:28:42 UTC
I have applied to the fix to 4.1.x and 5.5.x

Many thanks for the patch.