Clear channel attributes on channel unregister to avoid project leaks (IDEA-158108)

This commit is contained in:
Eugene Zhuravlev
2016-07-04 13:56:19 +02:00
parent 65a5b0e437
commit 15bb7ce510
2 changed files with 9 additions and 2 deletions
@@ -71,7 +71,14 @@ class BuildMessageDispatcher extends SimpleChannelInboundHandlerAdapter<CmdlineR
public BuilderMessageHandler unregisterBuildMessageHandler(UUID sessionId) {
myCanceledSessions.remove(sessionId);
final SessionData data = mySessionDescriptors.remove(sessionId);
return data != null? data.handler : null;
if (data == null) {
return null;
}
final Channel channel = data.channel;
if (channel != null) {
channel.attr(SESSION_DATA).remove(); // cleanup the attribute so that session data is not leaked
}
return data.handler;
}
public void cancelSession(UUID sessionId) {
@@ -326,7 +326,7 @@ public class ExternalJavacManager {
private class CompilationRequestsHandler extends SimpleChannelInboundHandler<JavacRemoteProto.Message> {
@Override
public void channelUnregistered(ChannelHandlerContext ctx) throws Exception {
JavacProcessDescriptor descriptor = ctx.channel().attr(SESSION_DESCRIPTOR).get();
JavacProcessDescriptor descriptor = ctx.channel().attr(SESSION_DESCRIPTOR).getAndRemove();
if (descriptor != null) {
descriptor.setDone();
}