Skip to content

Commit

Permalink
ISPN-6768 CommandAwareRpcDispatcher channel listener can cause classl…
Browse files Browse the repository at this point in the history
…oader leaks
  • Loading branch information
pferraro authored and tristantarrant committed Jun 21, 2016
1 parent 07d644a commit e75eba7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.jgroups.util.Rsp;
import org.jgroups.util.RspList;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CompletableFuture;
Expand Down Expand Up @@ -86,6 +87,14 @@ public CommandAwareRpcDispatcher(Channel channel, JGroupsTransport transport,
asyncDispatching(true);
}

@Override
public void close() {
// Ensure dispatcher is stopped
this.stop();
// We must unregister our listener, otherwise the channel will retain a reference to this dispatcher
this.channel.removeChannelListener(this);
}

@Override
protected RequestCorrelator createRequestCorrelator(Protocol transport, RequestHandler handler, Address local_addr) {
return new CustomRequestCorrelator(transport, handler, local_addr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ public void stop() {

if (dispatcher != null) {
log.stoppingRpcDispatcher(clusterName);
dispatcher.stop();
dispatcher.close();
if (channel != null) {
// Remove reference to up_handler
UpHandler handler = channel.getUpHandler();
Expand Down

0 comments on commit e75eba7

Please sign in to comment.