From 74021d421da06ec57b9d362928e4edc2fd045a06 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Thu, 12 Mar 2020 13:39:00 +0300 Subject: [PATCH] capitalize known pool names, add weak assertion requirng capitalization GitOrigin-RevId: 22eecaae4db57409d444934820f3371c59ea24b9 --- .../src/com/intellij/idea/ApplicationLoader.kt | 2 +- .../src/com/intellij/util/concurrency/Invoker.java | 4 +--- .../openapi/application/impl/NonBlockingReadActionTest.java | 6 +++--- .../com/intellij/util/concurrency/BoundedTaskExecutor.java | 3 +++ .../openapi/vcs/changes/committed/RequestsMergerTest.java | 2 +- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/idea/ApplicationLoader.kt b/platform/platform-impl/src/com/intellij/idea/ApplicationLoader.kt index 447f84062dde..3fb16db3cae4 100644 --- a/platform/platform-impl/src/com/intellij/idea/ApplicationLoader.kt +++ b/platform/platform-impl/src/com/intellij/idea/ApplicationLoader.kt @@ -244,7 +244,7 @@ private fun startApp(app: ApplicationImpl, @ApiStatus.Internal fun createExecutorToPreloadServices(): Executor { - return AppExecutorUtil.createBoundedApplicationPoolExecutor("preload services", Runtime.getRuntime().availableProcessors(), false) + return AppExecutorUtil.createBoundedApplicationPoolExecutor("Preload Services", Runtime.getRuntime().availableProcessors(), false) } @ApiStatus.Internal diff --git a/platform/platform-impl/src/com/intellij/util/concurrency/Invoker.java b/platform/platform-impl/src/com/intellij/util/concurrency/Invoker.java index 6a84e8adbd7e..e4724dcd7c92 100644 --- a/platform/platform-impl/src/com/intellij/util/concurrency/Invoker.java +++ b/platform/platform-impl/src/com/intellij/util/concurrency/Invoker.java @@ -40,9 +40,7 @@ public abstract class Invoker implements Disposable { private volatile boolean disposed; private Invoker(@NotNull String prefix, @NotNull Disposable parent, @NotNull ThreeState useReadAction) { - StringBuilder sb = new StringBuilder().append(UID.getAndIncrement()).append(".Invoker.").append(prefix); - if (useReadAction != ThreeState.UNSURE) sb.append(".ReadAction=").append(useReadAction); - description = sb.append(": ").append(parent).toString(); + description = "Invoker." + UID.getAndIncrement()+"."+prefix + (useReadAction != ThreeState.UNSURE ? ".ReadAction="+useReadAction : "") + ": "+parent; this.useReadAction = useReadAction; register(parent, this); } diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/application/impl/NonBlockingReadActionTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/application/impl/NonBlockingReadActionTest.java index 6469fa2fefca..2f2d14fa4f89 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/application/impl/NonBlockingReadActionTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/application/impl/NonBlockingReadActionTest.java @@ -186,7 +186,7 @@ public class NonBlockingReadActionTest extends LightPlatformTestCase { } public void testDoNotBlockExecutorThreadDuringWriteAction() throws Exception { - ExecutorService executor = AppExecutorUtil.createBoundedApplicationPoolExecutor("a", 1); + ExecutorService executor = AppExecutorUtil.createBoundedApplicationPoolExecutor("TestDoNotBlockExecutorThreadDuringWriteAction", 1); Semaphore mayFinish = new Semaphore(); Promise promise = ReadAction.nonBlocking(() -> { while (!mayFinish.waitFor(1)) { @@ -215,7 +215,7 @@ public class NonBlockingReadActionTest extends LightPlatformTestCase { } public void testDoNotLeakSecondCancelledCoalescedAction() throws Exception { - Executor executor = AppExecutorUtil.createBoundedApplicationPoolExecutor(getName(), 10); + Executor executor = AppExecutorUtil.createBoundedApplicationPoolExecutor("TestDoNotLeakSecondCancelledCoalescedAction", 10); Object leak = new Object(){}; CancellablePromise p = ReadAction.nonBlocking(() -> "a").coalesceBy(leak).submit(executor); @@ -354,7 +354,7 @@ public class NonBlockingReadActionTest extends LightPlatformTestCase { } public void testExceptionInsideAsyncComputationIsLogged() throws Exception { - BoundedTaskExecutor executor = (BoundedTaskExecutor)AppExecutorUtil.createBoundedApplicationPoolExecutor(getName(), 10); + BoundedTaskExecutor executor = (BoundedTaskExecutor)AppExecutorUtil.createBoundedApplicationPoolExecutor("TestExceptionInsideAsyncComputationIsLogged", 10); AtomicReference loggedError = watchLoggedExceptions(); diff --git a/platform/util/src/com/intellij/util/concurrency/BoundedTaskExecutor.java b/platform/util/src/com/intellij/util/concurrency/BoundedTaskExecutor.java index acbf9c5a5204..14ce4a2e3922 100644 --- a/platform/util/src/com/intellij/util/concurrency/BoundedTaskExecutor.java +++ b/platform/util/src/com/intellij/util/concurrency/BoundedTaskExecutor.java @@ -42,6 +42,9 @@ public final class BoundedTaskExecutor extends AbstractExecutorService { BoundedTaskExecutor(@NotNull String name, @NotNull Executor backendExecutor, int maxThreads, boolean changeThreadName) { this(name, backendExecutor, maxThreads, changeThreadName, null); + if (name.isEmpty() || !Character.isUpperCase(name.charAt(0))) { + Logger.getInstance(getClass()).warn("Pool name must be capitalized but got: '" + name + "'", new IllegalArgumentException()); + } } public BoundedTaskExecutor(@NotNull String name, @NotNull Executor backendExecutor, int maxThreads, boolean changeThreadName, @Nullable Comparator comparator) { diff --git a/platform/vcs-tests/testSrc/com/intellij/openapi/vcs/changes/committed/RequestsMergerTest.java b/platform/vcs-tests/testSrc/com/intellij/openapi/vcs/changes/committed/RequestsMergerTest.java index 7dc506f2f1d9..c170dc25eaa0 100644 --- a/platform/vcs-tests/testSrc/com/intellij/openapi/vcs/changes/committed/RequestsMergerTest.java +++ b/platform/vcs-tests/testSrc/com/intellij/openapi/vcs/changes/committed/RequestsMergerTest.java @@ -153,7 +153,7 @@ public class RequestsMergerTest extends TestCase { } private static class SimpleExecutor implements Consumer { - private final ExecutorService myExecutor = SequentialTaskExecutor.createSequentialApplicationPoolExecutor("req merge test"); + private final ExecutorService myExecutor = SequentialTaskExecutor.createSequentialApplicationPoolExecutor("Req Merge Test"); @Override public void consume(Runnable runnable) {