From fceb66dda3c19be5f2ea5e5a9e2c37c200f58c7a Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Tue, 3 Nov 2015 14:26:05 +0300 Subject: [PATCH] do not leak threads, esp. anonymous --- .../ui/update/MergingUpdateQueueTest.java | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/platform/platform-tests/testSrc/com/intellij/util/ui/update/MergingUpdateQueueTest.java b/platform/platform-tests/testSrc/com/intellij/util/ui/update/MergingUpdateQueueTest.java index 0446d27e7149..fadd2d798708 100644 --- a/platform/platform-tests/testSrc/com/intellij/util/ui/update/MergingUpdateQueueTest.java +++ b/platform/platform-tests/testSrc/com/intellij/util/ui/update/MergingUpdateQueueTest.java @@ -1,10 +1,22 @@ /* - * Copyright (c) 2000-2004 by JetBrains s.r.o. All Rights Reserved. - * Use is subject to license terms. + * Copyright 2000-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.intellij.util.ui.update; import com.intellij.testFramework.UsefulTestCase; +import com.intellij.util.ConcurrencyUtil; import com.intellij.util.TimeoutUtil; import com.intellij.util.WaitFor; import com.intellij.util.containers.ContainerUtil; @@ -328,7 +340,7 @@ public class MergingUpdateQueueTest extends UsefulTestCase { queue.showNotify(); final AtomicInteger count = new AtomicInteger(); - ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(100); + ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(100, ConcurrencyUtil.newNamedThreadFactory("testMultiThreadedQueueing()")); List futures = ContainerUtil.newArrayList(); for (int i = 0; i < 10; i++) { ScheduledFuture future = executor.schedule(new Runnable() { @@ -355,6 +367,8 @@ public class MergingUpdateQueueTest extends UsefulTestCase { waitForExecution(queue); assertEquals(1000, count.get()); + executor.shutdown(); + assertTrue(executor.awaitTermination(100, TimeUnit.SECONDS)); } public void testSamePriorityQueriesAreExecutedInAdditionOrder() {