SOLR-14162 TestInjection can leak Timer objects (#1137)

This commit is contained in:
Mike 2020-01-24 14:04:22 -06:00 committed by GitHub
parent 24f7a28ac1
commit eaa3dbe440
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -257,8 +257,9 @@ public class TestInjection {
if (rand.nextBoolean()) {
throw new TestShutdownFailError("Test exception for non graceful close");
} else {
final Timer timer = new Timer();
final Thread cthread = Thread.currentThread();
TimerTask task = new TimerTask() {
@Override
public void run() {
@ -275,11 +276,10 @@ public class TestInjection {
}
cthread.interrupt();
timers.remove(this);
cancel();
timers.remove(timer);
}
};
Timer timer = new Timer();
timers.add(timer);
timer.schedule(task, rand.nextInt(500));
}