From a5062c09550ba7fa33d6cf62f82a7b8ac6431efe Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Tue, 20 Dec 2011 18:50:25 +0400 Subject: [PATCH] leaks in debugger tests --- .../src/com/intellij/debugger/impl/InvokeThread.java | 9 +++++---- .../com/intellij/debugger/ui/impl/DebuggerTreeBase.java | 4 ++-- .../plugins/groovy/compiler/GroovyDebuggerTest.groovy | 5 ++++- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/java/debugger/impl/src/com/intellij/debugger/impl/InvokeThread.java b/java/debugger/impl/src/com/intellij/debugger/impl/InvokeThread.java index d06d0febaed8..b3ddf3a90ed2 100644 --- a/java/debugger/impl/src/com/intellij/debugger/impl/InvokeThread.java +++ b/java/debugger/impl/src/com/intellij/debugger/impl/InvokeThread.java @@ -18,6 +18,7 @@ package com.intellij.debugger.impl; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; import com.sun.jdi.VMDisconnectedException; +import org.jetbrains.annotations.NotNull; import java.util.List; import java.util.concurrent.*; @@ -65,14 +66,14 @@ public abstract class InvokeThread { public boolean isInterrupted() { assert myRequestFuture != null; - return myRequestFuture.isCancelled(); + return myRequestFuture.isCancelled() || myRequestFuture.isDone(); } public void join() throws InterruptedException, ExecutionException { assert myRequestFuture != null; try { myRequestFuture.get(); - } + } catch(CancellationException ignored) { } } @@ -101,7 +102,7 @@ public abstract class InvokeThread { public boolean isDone() { assert myRequestFuture != null; - return myRequestFuture.isDone(); + return myRequestFuture.isDone() && ourWorkerRequest.get() == null; } } @@ -122,7 +123,7 @@ public abstract class InvokeThread { workerRequest.setRequestFuture( ApplicationManager.getApplication().executeOnPooledThread(workerRequest) ); } - public void run(WorkerThreadRequest threadRequest) { + private void run(@NotNull WorkerThreadRequest threadRequest) { while(true) { try { if(threadRequest.isInterrupted()) { diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/impl/DebuggerTreeBase.java b/java/debugger/impl/src/com/intellij/debugger/ui/impl/DebuggerTreeBase.java index 7e81ee69ff54..3c2f626eb0df 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/impl/DebuggerTreeBase.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/impl/DebuggerTreeBase.java @@ -75,6 +75,8 @@ public class DebuggerTreeBase extends DnDAwareTree implements Disposable { } }); + Disposer.register(this, myTipManager); + UIUtil.setLineStyleAngled(this); setRootVisible(false); setShowsRootHandles(true); @@ -388,7 +390,5 @@ public class DebuggerTreeBase extends DnDAwareTree implements Disposable { } myCurrentTooltip = null; myCurrentTooltipNode = null; - Disposer.dispose(myTipManager); } - } diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/compiler/GroovyDebuggerTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/compiler/GroovyDebuggerTest.groovy index 186e7c9b77d4..094be1d8d787 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/compiler/GroovyDebuggerTest.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/compiler/GroovyDebuggerTest.groovy @@ -39,6 +39,7 @@ import com.intellij.openapi.Disposable import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.fileEditor.FileDocumentManager import com.intellij.openapi.roots.ModuleRootManager +import com.intellij.openapi.util.Computable import com.intellij.openapi.util.io.FileUtil import com.intellij.openapi.util.text.StringUtil import com.intellij.openapi.vfs.VirtualFile @@ -205,7 +206,9 @@ cl.parseClass('''$mcText''', 'MyClass.groovy').foo(2) waitForBreakpoint() SourcePosition position = managed { EvaluationContextImpl context = evaluationContext() - ContextUtil.getSourcePosition(context) + Computable a = { ContextUtil.getSourcePosition(context) } as Computable + SourcePosition pos = ApplicationManager.getApplication().runReadAction (a) + pos } assert myClass == position.file.virtualFile eval 'a', '2'