Bug 49343 - AbstractReplicatedMap is not removed from channel.
AbstractReplicatedMap is not removed from channel.
Product: Tomcat 6
Classification: Unclassified
Component: Cluster
All All
: P2 normal (vote)
: default
Assigned To: Tomcat Developers Mailing List
Depends on:
  Show dependency tree
Reported: 2010-05-26 07:47 UTC by Keiichi Fujino
Modified: 2010-07-22 22:36 UTC (History)
0 users

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

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(....) {
    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.