Bug 48049 - org.apache.naming.NamingContext's destroySubcontext() method doesn't invoke itself recursively, but invoke unbind() method
Summary: org.apache.naming.NamingContext's destroySubcontext() method doesn't invoke ...
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 5
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 5.5.28
Hardware: PC Linux
: P2 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-10-25 07:24 UTC by qingyang.xu
Modified: 2010-01-27 00:39 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description qingyang.xu 2009-10-25 07:24:55 UTC
Below is the original implementation of destroySubcontext(Name name) method:

public void destroySubcontext(Name name)
        throws NamingException {
        
        checkWritable();
        
        while ((!name.isEmpty()) && (name.get(0).length() == 0))
            name = name.getSuffix(1);
        if (name.isEmpty())
            throw new NamingException
                (sm.getString("namingContext.invalidName"));
        
        NamingEntry entry = (NamingEntry) bindings.get(name.get(0));
        
        if (entry == null) {
            throw new NameNotFoundException
                (sm.getString("namingContext.nameNotBound", name.get(0)));
        }
        
        if (name.size() > 1) {
            if (entry.type == NamingEntry.CONTEXT) {
                ((Context) entry.value).unbind(name.getSuffix(1));
            } else {
                throw new NamingException
                    (sm.getString("namingContext.contextExpected"));
            }
        } else {
            if (entry.type == NamingEntry.CONTEXT) {
                ((Context) entry.value).close();
                bindings.remove(name.get(0));
            } else {
                throw new NotContextException
                    (sm.getString("namingContext.contextExpected"));
            }
        }
        
    }


However, the method invokes 'unbind' method rather than invokes itself recursively. 

if (name.size() > 1) {
            if (entry.type == NamingEntry.CONTEXT) {
                ((Context) entry.value).unbind(name.getSuffix(1));
            } else {
                throw new NamingException
                    (sm.getString("namingContext.contextExpected"));
            }

should be: 

if (name.size() > 1) {
            if (entry.type == NamingEntry.CONTEXT) {
                ((Context) entry.value).destroySubcontext(name.getSuffix(1));
            } else {
                throw new NamingException
                    (sm.getString("namingContext.contextExpected"));
            }
Comment 1 Mark Thomas 2009-11-22 14:58:51 UTC
Thanks for the patch. It has been committed to trunk and proposed for 6.0.x and 5.5.x
Comment 2 Mark Thomas 2009-12-16 03:38:25 UTC
This has been fixed in 6.0.x and will be in 6.0.21 onwards.

Thanks again for the patch.
Comment 3 Konstantin Kolinko 2010-01-27 00:39:10 UTC
Fixed in 5.5, will be in 5.5.29 onwards. Thank you.