Bug 44856

Summary: add host alias using jmx doesn't take affect until restart
Product: Tomcat 5 Reporter: Andrew Mottaz <andrew>
Component: Connector:AJPAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED DUPLICATE    
Severity: normal CC: andrew
Priority: P2    
Version: Unknown   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Bug Depends on: 42707    
Bug Blocks:    

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 ***