Bug 49343 - AbstractReplicatedMap is not removed from channel.
Summary: AbstractReplicatedMap is not removed from channel.
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 6
Classification: Unclassified
Component: Cluster (show other bugs)
Version: 6.0.26
Hardware: All All
: P2 normal (vote)
Target Milestone: default
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-26 07:47 UTC by Keiichi Fujino
Modified: 2010-07-22 22:36 UTC (History)
0 users



Attachments
AbstractReplicatedMap's patch (809 bytes, text/plain)
2010-05-26 07:50 UTC, Keiichi Fujino
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Keiichi Fujino 2010-05-26 07:47:12 UTC
AbstractReplicatedMap#init() is as follows.
=====
protected void init(....) {
    
    ...skip...
    this.rpcChannel = new RpcChannel(this.mapContextName, channel, this);
    //add this map as a message listener
    this.channel.addChannelListener(this);
    //listen for membership notifications
    this.channel.addMembershipListener(this);
    
    try {
        //broadcast our map, this just notifies other members of our existence
        broadcast(MapMessage.MSG_INIT, true);
        //transfer state from another map
        transferState();
        //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.