Bug 49343

Summary: AbstractReplicatedMap is not removed from channel.
Product: Tomcat 6 Reporter: Keiichi Fujino <kfujino>
Component: ClusterAssignee: Tomcat Developers Mailing List <dev>
Severity: normal    
Priority: P2    
Version: 6.0.26   
Target Milestone: default   
Hardware: All   
OS: All   
Attachments: AbstractReplicatedMap's patch

Description Keiichi Fujino 2010-05-26 07:47:12 UTC
AbstractReplicatedMap#init() is as follows.
protected void init(....) {
    this.rpcChannel = new RpcChannel(this.mapContextName, channel, this);
    //add this map as a message listener
    //listen for membership notifications
    try {
        //broadcast our map, this just notifies other members of our existence
        broadcast(MapMessage.MSG_INIT, true);
        //transfer state from another map
        //state is transferred, we are ready for messaging
        broadcast(MapMessage.MSG_START, true);
    } catch (ChannelException x) {
        log.warn("Unable to send map start message.");
        throw new RuntimeException("Unable to start replicated map.",x);

When ChannelException is thrown after this(AbstractReplicatedMap) is added to channel, 
RuntimeException is thrown.
And AbstractReplicatedMap#init() is called from the constructor of 
AbstractReplicatedMap(LazyReplicatedMap or ReplicatedMap). 

In a word, no one can remove this(AbstractReplicatedMap) added to channel.

As a result, trivial memory leak and IllegalArgumentException("Listener already exists:...) are caused. 

Best regards.
Comment 1 Keiichi Fujino 2010-05-26 07:50:26 UTC
Created attachment 25485 [details]
AbstractReplicatedMap's patch

I made a patch.
This patch contains the same fix about RpcChannel.
Comment 2 Keiichi Fujino 2010-05-26 08:08:53 UTC
Fixed in trunk and proposed for 6.0.x.
Comment 3 Keiichi Fujino 2010-07-22 22:36:18 UTC
This fix applied to 6.0, will be in 6.0.30 onwards.