Bug 35769 - Wrong implementation of javax.naming.Context.composeName
Wrong implementation of javax.naming.Context.composeName
Status: RESOLVED FIXED
Product: Tomcat 4
Classification: Unclassified
Component: Catalina
4.1.31
All All
: P2 normal (vote)
: ---
Assigned To: Tomcat Developers Mailing List
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2005-07-17 05:00 UTC by Laurent Simon
Modified: 2005-07-20 15:28 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.