From a76adc5de80485e26a04c97b256ea63d11c67f0e Mon Sep 17 00:00:00 2001 From: Dmitry Batrak Date: Mon, 14 Aug 2017 13:28:14 +0300 Subject: [PATCH] fix project leak in tests A link to project was captured in an alarm request lambda. --- .../src/com/intellij/codeInsight/AutoPopupController.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/AutoPopupController.java b/platform/lang-impl/src/com/intellij/codeInsight/AutoPopupController.java index 66a792ec59fe..b2a66b5c5574 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/AutoPopupController.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/AutoPopupController.java @@ -76,7 +76,7 @@ public class AutoPopupController implements Disposable { private final Project myProject; - private final Alarm myAlarm = new Alarm(); + private final Alarm myAlarm; public static AutoPopupController getInstance(Project project){ return ServiceManager.getService(project, AutoPopupController.class); @@ -84,6 +84,7 @@ public class AutoPopupController implements Disposable { public AutoPopupController(Project project) { myProject = project; + myAlarm = new Alarm(this); setupListeners(); } @@ -160,7 +161,9 @@ public class AutoPopupController implements Disposable { } private void addRequest(final Runnable request, final int delay) { - Runnable runnable = () -> myAlarm.addRequest(request, delay); + Runnable runnable = () -> { + if (!myAlarm.isDisposed()) myAlarm.addRequest(request, delay); + }; if (ApplicationManager.getApplication().isUnitTestMode()) { runnable.run(); } else {