mirror of https://github.com/apache/lucene.git
SOLR-14162 TestInjection can leak Timer objects (#1137)
This commit is contained in:
parent
24f7a28ac1
commit
eaa3dbe440
|
@ -257,8 +257,9 @@ public class TestInjection {
|
||||||
if (rand.nextBoolean()) {
|
if (rand.nextBoolean()) {
|
||||||
throw new TestShutdownFailError("Test exception for non graceful close");
|
throw new TestShutdownFailError("Test exception for non graceful close");
|
||||||
} else {
|
} else {
|
||||||
|
final Timer timer = new Timer();
|
||||||
final Thread cthread = Thread.currentThread();
|
final Thread cthread = Thread.currentThread();
|
||||||
|
|
||||||
TimerTask task = new TimerTask() {
|
TimerTask task = new TimerTask() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -275,11 +276,10 @@ public class TestInjection {
|
||||||
}
|
}
|
||||||
|
|
||||||
cthread.interrupt();
|
cthread.interrupt();
|
||||||
timers.remove(this);
|
timers.remove(timer);
|
||||||
cancel();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Timer timer = new Timer();
|
|
||||||
timers.add(timer);
|
timers.add(timer);
|
||||||
timer.schedule(task, rand.nextInt(500));
|
timer.schedule(task, rand.nextInt(500));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue