From 34a4e1ee1e5d50b19964383635db4713d2d35042 Mon Sep 17 00:00:00 2001 From: Dmitry Batkovich Date: Wed, 11 Dec 2019 16:46:31 +0300 Subject: [PATCH] prevent FileIndexDataInitialization leak: use static class instead of lambda GitOrigin-RevId: 604e0ae30d71262df405e93ae97beccc65317e46 --- .../intellij/util/indexing/FileBasedIndexImpl.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java index 3161c6d8576b..96d22ce0bdc7 100644 --- a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java +++ b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java @@ -2500,9 +2500,11 @@ public final class FileBasedIndexImpl extends FileBasedIndex { // 2) we dispose FileBasedIndex before PersistentFS disposing PersistentFSImpl fs = (PersistentFSImpl)ManagingFS.getInstance(); FileBasedIndexImpl fileBasedIndex = (FileBasedIndexImpl)FileBasedIndex.getInstance(); - Disposable disposable = () -> fileBasedIndex.performShutdown(false); + Disposable disposable = () -> new MyShutDownTask().run(); ApplicationManager.getApplication().addApplicationListener(new MyApplicationListener(fileBasedIndex), disposable); Disposer.register(fs, disposable); + myShutDownTask = new MyShutDownTask(); + ShutDownTracker.getInstance().registerShutdownTask(myShutDownTask); initAssociatedDataForExtensions(); @@ -2571,8 +2573,6 @@ public final class FileBasedIndexImpl extends FileBasedIndex { return state; } finally { - myShutDownTask = () -> FileBasedIndexImpl.this.performShutdown(false); - ShutDownTracker.getInstance().registerShutdownTask(myShutDownTask); myFlushingFuture = FlushingDaemon.everyFiveSeconds(new Runnable() { private final SerializationManagerEx mySerializationManager = SerializationManagerEx.getInstanceEx(); @@ -2596,6 +2596,13 @@ public final class FileBasedIndexImpl extends FileBasedIndex { } } + private static class MyShutDownTask implements Runnable { + @Override + public void run() { + ((FileBasedIndexImpl)FileBasedIndex.getInstance()).performShutdown(false); + } + } + private static class MyApplicationListener implements ApplicationListener { private final FileBasedIndexImpl myFileBasedIndex;