From 72fea44b3d27d1533ba24ae7bea4714ff4d01138 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Tue, 5 Mar 2019 22:45:57 +0100 Subject: [PATCH] Cleanup (inlines single use method; adds exception logging) --- .../openapi/vfs/impl/local/FileWatcher.java | 26 ++++++++----------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/FileWatcher.java b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/FileWatcher.java index 2b5a24c1d726..cc786bf92f1f 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/FileWatcher.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/FileWatcher.java @@ -27,7 +27,6 @@ import java.util.List; import java.util.Set; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; -import java.util.concurrent.Future; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Consumer; @@ -76,7 +75,7 @@ public class FileWatcher { private volatile CanonicalPathMap myPathMap = new CanonicalPathMap(); private volatile List> myManualWatchRoots = Collections.emptyList(); - + private final ExecutorService myFileWatcherExecutor = Registry.is("vfs.filewatcher.works.in.async.way") ? AppExecutorUtil.createBoundedApplicationPoolExecutor("File Watcher", 1) : MoreExecutors.newDirectExecutorService(); @@ -95,11 +94,16 @@ public class FileWatcher { } public void dispose() { - waitForFuture(myFileWatcherExecutor.submit(() -> { - for (PluggableFileWatcher watcher : myWatchers) { - watcher.dispose(); - } - })); + try { + myFileWatcherExecutor.submit(() -> { + for (PluggableFileWatcher watcher : myWatchers) { + watcher.dispose(); + } + }).get(); + } + catch (InterruptedException | ExecutionException e) { + LOG.error(e); + } } public boolean isOperational() { @@ -119,14 +123,6 @@ public class FileWatcher { return false; } - private void waitForFuture(@NotNull Future future) { - try { - future.get(); - } - catch (InterruptedException | ExecutionException ignore) { - } - } - @NotNull DirtyPaths getDirtyPaths() { return myNotificationSink.getDirtyPaths();