Bug 44856 - add host alias using jmx doesn't take affect until restart
Summary: add host alias using jmx doesn't take affect until restart
Status: RESOLVED DUPLICATE of bug 42707
Alias: None
Product: Tomcat 5
Classification: Unclassified
Component: Connector:AJP (show other bugs)
Version: Unknown
Hardware: PC Linux
: P2 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on: 42707
Blocks:
  Show dependency tree
 
Reported: 2008-04-22 13:07 UTC by Andrew Mottaz
Modified: 2008-04-23 14:56 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Mottaz 2008-04-22 13:07:41 UTC
Part of the problem is that Mapper.java will not properly update aliases for a Host that already exists.  Potential fix in Mapper.java: (Note -- code originally posted by Luke Kirby, inelegantly re-written)

    public synchronized void addHost(String name, String[] aliases,
                                     Object host) {
        Host[] newHosts = new Host[hosts.length + 1];
        Host newHost = new Host();
        ContextList contextList = new ContextList();
        newHost.name = name;
        newHost.contextList = contextList;
        newHost.object = host;
        if (insertMap(hosts, newHosts, newHost)) {
            hosts = newHosts;
        
        for (int i = 0; i < aliases.length; i++) {
            newHosts = new Host[hosts.length + 1];
            newHost = new Host();
            newHost.name = aliases[i];
            newHost.contextList = contextList;
            newHost.object = host;
            if (insertMap(hosts, newHosts, newHost)) {
                hosts = newHosts;
            }
        }
        }
        else {
        	Host aliasedHost;
        	// insert failed because the host already exists; grab it
        	int hostPos = find(hosts, name);
        	if (hostPos >= 0) {
        		aliasedHost = hosts[hostPos];
                for (int i = 0; i < aliases.length; i++) {
                    newHosts = new Host[hosts.length + 1];
                    newHost = new Host();
                    newHost.name = aliases[i];
                    newHost.contextList = aliasedHost.contextList;
                    newHost.object = aliasedHost.object;
                    if (insertMap(hosts, newHosts, newHost)) {
                        hosts = newHosts;
                    }
                }
        	} else {
        		// I can't imagine why this would happen..
        		System.out.println("huh?");
        	}

        }
    }
Comment 1 Mark Thomas 2008-04-23 14:56:22 UTC
I'll add a note to 42707 to port the fix to TC5.

*** This bug has been marked as a duplicate of bug 42707 ***