leaks in debugger tests

This commit is contained in:
Alexey Kudravtsev
2011-06-09 14:50:39 +04:00
parent 2d42a21b31
commit 6dbc32828d
2 changed files with 24 additions and 0 deletions
@@ -29,6 +29,7 @@ import com.intellij.openapi.progress.util.ProgressWindowWithNotification;
import com.intellij.util.Alarm;
import com.sun.jdi.VMDisconnectedException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.TestOnly;
/**
* @author lex
@@ -43,6 +44,7 @@ public class DebuggerManagerThreadImpl extends InvokeAndWaitThread<DebuggerComma
super();
}
@TestOnly
public static DebuggerManagerThreadImpl createTestInstance() {
return new DebuggerManagerThreadImpl();
}
@@ -222,4 +224,10 @@ public class DebuggerManagerThreadImpl extends InvokeAndWaitThread<DebuggerComma
}
}
@TestOnly
public void clearQueue() {
myEvents.clearQueue();
}
}
@@ -17,6 +17,7 @@ package com.intellij.debugger.impl;
import com.intellij.openapi.diagnostic.Logger;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.TestOnly;
import java.util.LinkedList;
import java.util.concurrent.locks.Condition;
@@ -50,6 +51,7 @@ public class EventQueue<E> {
myLock.lock();
try {
assertOpen();
getEventsList(priority).addFirst(event);
myEventsAvailable.signalAll();
}
@@ -65,6 +67,7 @@ public class EventQueue<E> {
myLock.lock();
try {
assertOpen();
getEventsList(priority).offer(event);
myEventsAvailable.signalAll();
}
@@ -80,6 +83,7 @@ public class EventQueue<E> {
public void close(){
myLock.lock();
try {
assertOpen();
myIsClosed = true;
myEventsAvailable.signalAll();
}
@@ -88,6 +92,10 @@ public class EventQueue<E> {
}
}
private void assertOpen() {
if (myIsClosed) throw new AssertionError("Already closed");
}
private E getEvent() throws EventQueueClosedException {
myLock.lock();
try {
@@ -120,4 +128,12 @@ public class EventQueue<E> {
public E getCurrentEvent() {
return myCurrentEvent;
}
@TestOnly
public void clearQueue() {
myCurrentEvent = null;
for (LinkedList event : myEvents) {
event.clear();
}
}
}