From a1d8086b2c59ce89e7bf6915d360aa8833c6419d Mon Sep 17 00:00:00 2001 From: lidongyao Date: Tue, 23 Jul 2024 20:33:09 +0800 Subject: [PATCH 1/7] fix AbortPolicyWithReport may repeatedly jstack when threadPool is exhausted --- .../support/AbortPolicyWithReport.java | 3 +- .../support/AbortPolicyWithReportTest.java | 49 +++++++++++++++++++ 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/threadpool/support/AbortPolicyWithReport.java b/dubbo-common/src/main/java/org/apache/dubbo/common/threadpool/support/AbortPolicyWithReport.java index d65211eff9d..77ba73d36ff 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/common/threadpool/support/AbortPolicyWithReport.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/common/threadpool/support/AbortPolicyWithReport.java @@ -184,10 +184,9 @@ private void dumpJStack() { jstack(jStackStream); } catch (Exception t) { logger.error(COMMON_UNEXPECTED_CREATE_DUMP, "", "", "dump jStack error", t); - } finally { - lastPrintTime = System.currentTimeMillis(); } }); + lastPrintTime = System.currentTimeMillis(); } finally { guard.release(); // must shut down thread pool ,if not will lead to OOM diff --git a/dubbo-common/src/test/java/org/apache/dubbo/common/threadpool/support/AbortPolicyWithReportTest.java b/dubbo-common/src/test/java/org/apache/dubbo/common/threadpool/support/AbortPolicyWithReportTest.java index 8179d42f0a0..eb7e464b8dc 100644 --- a/dubbo-common/src/test/java/org/apache/dubbo/common/threadpool/support/AbortPolicyWithReportTest.java +++ b/dubbo-common/src/test/java/org/apache/dubbo/common/threadpool/support/AbortPolicyWithReportTest.java @@ -16,7 +16,13 @@ */ package org.apache.dubbo.common.threadpool.support; +import java.util.LinkedList; +import java.util.List; +import java.util.concurrent.Future; +import java.util.concurrent.SynchronousQueue; +import java.util.concurrent.atomic.AtomicInteger; import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.threadlocal.NamedInternalThreadFactory; import org.apache.dubbo.common.threadpool.event.ThreadPoolExhaustedEvent; import org.apache.dubbo.common.threadpool.event.ThreadPoolExhaustedListener; @@ -27,6 +33,7 @@ import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.atomic.AtomicReference; +import java.util.concurrent.TimeUnit; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -60,6 +67,48 @@ protected void jstack(FileOutputStream jStackStream) { Assertions.assertNotNull(fileOutputStream.get()); } + @Test + void jStack_ConcurrencyDump_Active_10MinSilence() { + URL url = URL.valueOf("dubbo://admin:hello1234@10.20.130.230:20880/context/path?dump.directory=/tmp&version=1.0.0&application=morgan&noValue="); + AtomicInteger jStackCount = new AtomicInteger(0); + AtomicInteger finishedCount = new AtomicInteger(0); + AbortPolicyWithReport abortPolicyWithReport = new AbortPolicyWithReport("Test", url) { + @Override + protected void jstack(FileOutputStream jStackStream) { + jStackCount.incrementAndGet(); + try { + Thread.sleep(3000); + } catch (Exception e) { + } + } + }; + ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor( + 4, + 4, + 0, + TimeUnit.MILLISECONDS, + new SynchronousQueue<>(), + new NamedInternalThreadFactory("jStackRepeatFixedTest", false), + abortPolicyWithReport); + List> futureList = new LinkedList<>(); + for (int pos = 0; pos < 100; pos++) { + try { + futureList.add(threadPoolExecutor.submit(() -> { + finishedCount.incrementAndGet(); + })); + } catch (Exception ignored) { + } + } + futureList.stream().forEach(f -> { + try { + f.get(1000, TimeUnit.MILLISECONDS); + } catch (Exception ignored) { + } + }); + System.out.printf("finishedCount: %d, jStackCount: %d\n", finishedCount.get(), jStackCount.get()); + Assertions.assertEquals(jStackCount.get(), 1); + } + @Test void jStackDumpTest_dumpDirectoryNotExists_cannotBeCreatedTakeUserHome() { final String dumpDirectory = dumpDirectoryCannotBeCreated(); From 4b45b2c123a76b42aa79ceeb3960356eb567945f Mon Sep 17 00:00:00 2001 From: lidongyao Date: Tue, 23 Jul 2024 20:53:33 +0800 Subject: [PATCH 2/7] format code style --- .../support/AbortPolicyWithReportTest.java | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/dubbo-common/src/test/java/org/apache/dubbo/common/threadpool/support/AbortPolicyWithReportTest.java b/dubbo-common/src/test/java/org/apache/dubbo/common/threadpool/support/AbortPolicyWithReportTest.java index eb7e464b8dc..fd78e582385 100644 --- a/dubbo-common/src/test/java/org/apache/dubbo/common/threadpool/support/AbortPolicyWithReportTest.java +++ b/dubbo-common/src/test/java/org/apache/dubbo/common/threadpool/support/AbortPolicyWithReportTest.java @@ -16,24 +16,24 @@ */ package org.apache.dubbo.common.threadpool.support; -import java.util.LinkedList; -import java.util.List; -import java.util.concurrent.Future; -import java.util.concurrent.SynchronousQueue; -import java.util.concurrent.atomic.AtomicInteger; import org.apache.dubbo.common.URL; import org.apache.dubbo.common.threadlocal.NamedInternalThreadFactory; import org.apache.dubbo.common.threadpool.event.ThreadPoolExhaustedEvent; import org.apache.dubbo.common.threadpool.event.ThreadPoolExhaustedListener; import java.io.FileOutputStream; +import java.util.LinkedList; +import java.util.List; import java.util.UUID; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; +import java.util.concurrent.Future; import java.util.concurrent.RejectedExecutionException; +import java.util.concurrent.SynchronousQueue; import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicReference; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -44,6 +44,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; class AbortPolicyWithReportTest { + @Test void jStackDumpTest() { URL url = URL.valueOf( @@ -69,7 +70,8 @@ protected void jstack(FileOutputStream jStackStream) { @Test void jStack_ConcurrencyDump_Active_10MinSilence() { - URL url = URL.valueOf("dubbo://admin:hello1234@10.20.130.230:20880/context/path?dump.directory=/tmp&version=1.0.0&application=morgan&noValue="); + URL url = URL.valueOf( + "dubbo://admin:hello1234@10.20.130.230:20880/context/path?dump.directory=/tmp&version=1.0.0&application=morgan&noValue="); AtomicInteger jStackCount = new AtomicInteger(0); AtomicInteger finishedCount = new AtomicInteger(0); AbortPolicyWithReport abortPolicyWithReport = new AbortPolicyWithReport("Test", url) { @@ -83,18 +85,18 @@ protected void jstack(FileOutputStream jStackStream) { } }; ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor( - 4, - 4, - 0, - TimeUnit.MILLISECONDS, - new SynchronousQueue<>(), - new NamedInternalThreadFactory("jStackRepeatFixedTest", false), - abortPolicyWithReport); + 4, + 4, + 0, + TimeUnit.MILLISECONDS, + new SynchronousQueue<>(), + new NamedInternalThreadFactory("jStackRepeatFixedTest", false), + abortPolicyWithReport); List> futureList = new LinkedList<>(); for (int pos = 0; pos < 100; pos++) { try { futureList.add(threadPoolExecutor.submit(() -> { - finishedCount.incrementAndGet(); + finishedCount.incrementAndGet(); })); } catch (Exception ignored) { } From 80772d643d10756c493f0213042cf9d514aab4ab Mon Sep 17 00:00:00 2001 From: lidongyao Date: Wed, 24 Jul 2024 00:07:47 +0800 Subject: [PATCH 3/7] fix intentionality issue --- .../support/AbortPolicyWithReportTest.java | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/dubbo-common/src/test/java/org/apache/dubbo/common/threadpool/support/AbortPolicyWithReportTest.java b/dubbo-common/src/test/java/org/apache/dubbo/common/threadpool/support/AbortPolicyWithReportTest.java index fd78e582385..ce01201e58d 100644 --- a/dubbo-common/src/test/java/org/apache/dubbo/common/threadpool/support/AbortPolicyWithReportTest.java +++ b/dubbo-common/src/test/java/org/apache/dubbo/common/threadpool/support/AbortPolicyWithReportTest.java @@ -73,15 +73,16 @@ void jStack_ConcurrencyDump_Active_10MinSilence() { URL url = URL.valueOf( "dubbo://admin:hello1234@10.20.130.230:20880/context/path?dump.directory=/tmp&version=1.0.0&application=morgan&noValue="); AtomicInteger jStackCount = new AtomicInteger(0); + AtomicInteger failureCount = new AtomicInteger(0); AtomicInteger finishedCount = new AtomicInteger(0); + AtomicInteger timeoutCount = new AtomicInteger(0); + int runTimes = 100; AbortPolicyWithReport abortPolicyWithReport = new AbortPolicyWithReport("Test", url) { @Override protected void jstack(FileOutputStream jStackStream) { jStackCount.incrementAndGet(); - try { - Thread.sleep(3000); - } catch (Exception e) { - } + // try to simulate the jstack cost long time, so that AbortPolicyWithReport may jstack repeatedly. + await().atMost(3, TimeUnit.SECONDS); } }; ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor( @@ -90,25 +91,31 @@ protected void jstack(FileOutputStream jStackStream) { 0, TimeUnit.MILLISECONDS, new SynchronousQueue<>(), - new NamedInternalThreadFactory("jStackRepeatFixedTest", false), + new NamedInternalThreadFactory("jStack_ConcurrencyDump_Active_10MinSilence", true), abortPolicyWithReport); List> futureList = new LinkedList<>(); - for (int pos = 0; pos < 100; pos++) { + for (int i = 0; i < runTimes; i++) { try { futureList.add(threadPoolExecutor.submit(() -> { finishedCount.incrementAndGet(); })); } catch (Exception ignored) { + failureCount.incrementAndGet(); } } - futureList.stream().forEach(f -> { + futureList.forEach(f -> { try { - f.get(1000, TimeUnit.MILLISECONDS); + f.get(1, TimeUnit.SECONDS); } catch (Exception ignored) { + timeoutCount.incrementAndGet(); } }); - System.out.printf("finishedCount: %d, jStackCount: %d\n", finishedCount.get(), jStackCount.get()); - Assertions.assertEquals(jStackCount.get(), 1); + System.out.printf( + "jStackCount: %d, finishedCount: %d, failureCount: %d, timeoutCount: %d %n", + jStackCount.get(), finishedCount.get(), failureCount.get(), timeoutCount.get()); + Assertions.assertEquals( + runTimes, finishedCount.get() + failureCount.get(), "all the test thread should be run completely"); + Assertions.assertEquals(1, jStackCount.get(), "'jstack' should be called only once in 10 minutes"); } @Test From 7cf4771bd81e7be7b6d1324faa7cabdd9f7f5a50 Mon Sep 17 00:00:00 2001 From: lidongyao Date: Wed, 24 Jul 2024 10:13:21 +0800 Subject: [PATCH 4/7] fixed test case --- .../support/AbortPolicyWithReportTest.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/dubbo-common/src/test/java/org/apache/dubbo/common/threadpool/support/AbortPolicyWithReportTest.java b/dubbo-common/src/test/java/org/apache/dubbo/common/threadpool/support/AbortPolicyWithReportTest.java index ce01201e58d..f1ca9e5b9d7 100644 --- a/dubbo-common/src/test/java/org/apache/dubbo/common/threadpool/support/AbortPolicyWithReportTest.java +++ b/dubbo-common/src/test/java/org/apache/dubbo/common/threadpool/support/AbortPolicyWithReportTest.java @@ -69,7 +69,7 @@ protected void jstack(FileOutputStream jStackStream) { } @Test - void jStack_ConcurrencyDump_Active_10MinSilence() { + void jStack_ConcurrencyDump_Silence_10Min() { URL url = URL.valueOf( "dubbo://admin:hello1234@10.20.130.230:20880/context/path?dump.directory=/tmp&version=1.0.0&application=morgan&noValue="); AtomicInteger jStackCount = new AtomicInteger(0); @@ -82,7 +82,10 @@ void jStack_ConcurrencyDump_Active_10MinSilence() { protected void jstack(FileOutputStream jStackStream) { jStackCount.incrementAndGet(); // try to simulate the jstack cost long time, so that AbortPolicyWithReport may jstack repeatedly. - await().atMost(3, TimeUnit.SECONDS); + long startTime = System.currentTimeMillis(); + await().atLeast(200, TimeUnit.MILLISECONDS) + .atMost(400, TimeUnit.MILLISECONDS) + .until(() -> System.currentTimeMillis() - startTime >= 300); } }; ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor( @@ -91,13 +94,17 @@ protected void jstack(FileOutputStream jStackStream) { 0, TimeUnit.MILLISECONDS, new SynchronousQueue<>(), - new NamedInternalThreadFactory("jStack_ConcurrencyDump_Active_10MinSilence", true), + new NamedInternalThreadFactory("jStack_ConcurrencyDump_Silence_10Min", true), abortPolicyWithReport); List> futureList = new LinkedList<>(); for (int i = 0; i < runTimes; i++) { try { futureList.add(threadPoolExecutor.submit(() -> { finishedCount.incrementAndGet(); + long startTime = System.currentTimeMillis(); + await().atLeast(300, TimeUnit.MILLISECONDS) + .atMost(600, TimeUnit.MILLISECONDS) + .until(() -> System.currentTimeMillis() - startTime >= 400); })); } catch (Exception ignored) { failureCount.incrementAndGet(); @@ -105,7 +112,7 @@ protected void jstack(FileOutputStream jStackStream) { } futureList.forEach(f -> { try { - f.get(1, TimeUnit.SECONDS); + f.get(500, TimeUnit.MILLISECONDS); } catch (Exception ignored) { timeoutCount.incrementAndGet(); } From c5bfe57d56fe867acbc7151e4d78519f0aebe8f2 Mon Sep 17 00:00:00 2001 From: lidongyao Date: Wed, 24 Jul 2024 11:57:42 +0800 Subject: [PATCH 5/7] fixed test with await 1s --- .../support/AbortPolicyWithReportTest.java | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/dubbo-common/src/test/java/org/apache/dubbo/common/threadpool/support/AbortPolicyWithReportTest.java b/dubbo-common/src/test/java/org/apache/dubbo/common/threadpool/support/AbortPolicyWithReportTest.java index f1ca9e5b9d7..d87267edff3 100644 --- a/dubbo-common/src/test/java/org/apache/dubbo/common/threadpool/support/AbortPolicyWithReportTest.java +++ b/dubbo-common/src/test/java/org/apache/dubbo/common/threadpool/support/AbortPolicyWithReportTest.java @@ -37,7 +37,9 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; +import org.mockito.Mockito; +import static org.apache.dubbo.common.constants.CommonConstants.DUMP_DIRECTORY; import static org.apache.dubbo.common.constants.CommonConstants.OS_NAME_KEY; import static org.apache.dubbo.common.constants.CommonConstants.OS_WIN_PREFIX; import static org.awaitility.Awaitility.await; @@ -70,22 +72,20 @@ protected void jstack(FileOutputStream jStackStream) { @Test void jStack_ConcurrencyDump_Silence_10Min() { - URL url = URL.valueOf( - "dubbo://admin:hello1234@10.20.130.230:20880/context/path?dump.directory=/tmp&version=1.0.0&application=morgan&noValue="); + URL spyUrl = Mockito.spy( + URL.valueOf( + "dubbo://admin:hello1234@10.20.130.230:20880/context/path?dump.directory=/tmp&version=1.0.0&application=morgan&noValue=")); AtomicInteger jStackCount = new AtomicInteger(0); AtomicInteger failureCount = new AtomicInteger(0); AtomicInteger finishedCount = new AtomicInteger(0); AtomicInteger timeoutCount = new AtomicInteger(0); - int runTimes = 100; - AbortPolicyWithReport abortPolicyWithReport = new AbortPolicyWithReport("Test", url) { + AbortPolicyWithReport abortPolicyWithReport = new AbortPolicyWithReport("Test", spyUrl) { @Override protected void jstack(FileOutputStream jStackStream) { jStackCount.incrementAndGet(); // try to simulate the jstack cost long time, so that AbortPolicyWithReport may jstack repeatedly. long startTime = System.currentTimeMillis(); - await().atLeast(200, TimeUnit.MILLISECONDS) - .atMost(400, TimeUnit.MILLISECONDS) - .until(() -> System.currentTimeMillis() - startTime >= 300); + await().atLeast(200, TimeUnit.MILLISECONDS).until(() -> System.currentTimeMillis() - startTime >= 300); } }; ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor( @@ -94,17 +94,18 @@ protected void jstack(FileOutputStream jStackStream) { 0, TimeUnit.MILLISECONDS, new SynchronousQueue<>(), - new NamedInternalThreadFactory("jStack_ConcurrencyDump_Silence_10Min", true), + new NamedInternalThreadFactory("jStack_ConcurrencyDump_Silence_10Min", false), abortPolicyWithReport); + int runTimes = 100; List> futureList = new LinkedList<>(); for (int i = 0; i < runTimes; i++) { try { futureList.add(threadPoolExecutor.submit(() -> { finishedCount.incrementAndGet(); - long startTime = System.currentTimeMillis(); - await().atLeast(300, TimeUnit.MILLISECONDS) - .atMost(600, TimeUnit.MILLISECONDS) - .until(() -> System.currentTimeMillis() - startTime >= 400); + long start = System.currentTimeMillis(); + // try to await 1s to make sure jstack dump thread scheduled + await().atLeast(1000, TimeUnit.MILLISECONDS) + .until(() -> System.currentTimeMillis() - start >= 1000); })); } catch (Exception ignored) { failureCount.incrementAndGet(); @@ -112,14 +113,16 @@ protected void jstack(FileOutputStream jStackStream) { } futureList.forEach(f -> { try { - f.get(500, TimeUnit.MILLISECONDS); + f.get(2000, TimeUnit.MILLISECONDS); } catch (Exception ignored) { timeoutCount.incrementAndGet(); } }); + System.out.printf( "jStackCount: %d, finishedCount: %d, failureCount: %d, timeoutCount: %d %n", jStackCount.get(), finishedCount.get(), failureCount.get(), timeoutCount.get()); + Mockito.verify(spyUrl, Mockito.times(1)).getParameter(DUMP_DIRECTORY); Assertions.assertEquals( runTimes, finishedCount.get() + failureCount.get(), "all the test thread should be run completely"); Assertions.assertEquals(1, jStackCount.get(), "'jstack' should be called only once in 10 minutes"); From d716508e17981d76043cbb112dcf7dee0bec1f67 Mon Sep 17 00:00:00 2001 From: lidongyao Date: Wed, 24 Jul 2024 14:15:49 +0800 Subject: [PATCH 6/7] fixed test lastPrintTime conflict --- .../support/AbortPolicyWithReportTest.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/dubbo-common/src/test/java/org/apache/dubbo/common/threadpool/support/AbortPolicyWithReportTest.java b/dubbo-common/src/test/java/org/apache/dubbo/common/threadpool/support/AbortPolicyWithReportTest.java index d87267edff3..53b0520b5f8 100644 --- a/dubbo-common/src/test/java/org/apache/dubbo/common/threadpool/support/AbortPolicyWithReportTest.java +++ b/dubbo-common/src/test/java/org/apache/dubbo/common/threadpool/support/AbortPolicyWithReportTest.java @@ -36,16 +36,19 @@ import java.util.concurrent.atomic.AtomicReference; import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.mockito.Mockito; -import static org.apache.dubbo.common.constants.CommonConstants.DUMP_DIRECTORY; import static org.apache.dubbo.common.constants.CommonConstants.OS_NAME_KEY; import static org.apache.dubbo.common.constants.CommonConstants.OS_WIN_PREFIX; import static org.awaitility.Awaitility.await; import static org.junit.jupiter.api.Assertions.assertEquals; class AbortPolicyWithReportTest { + @BeforeEach + public void setUp() { + AbortPolicyWithReport.lastPrintTime = 0; + } @Test void jStackDumpTest() { @@ -72,9 +75,8 @@ protected void jstack(FileOutputStream jStackStream) { @Test void jStack_ConcurrencyDump_Silence_10Min() { - URL spyUrl = Mockito.spy( - URL.valueOf( - "dubbo://admin:hello1234@10.20.130.230:20880/context/path?dump.directory=/tmp&version=1.0.0&application=morgan&noValue=")); + URL spyUrl = URL.valueOf( + "dubbo://admin:hello1234@10.20.130.230:20880/context/path?dump.directory=/tmp&version=1.0.0&application=morgan&noValue="); AtomicInteger jStackCount = new AtomicInteger(0); AtomicInteger failureCount = new AtomicInteger(0); AtomicInteger finishedCount = new AtomicInteger(0); @@ -104,8 +106,7 @@ protected void jstack(FileOutputStream jStackStream) { finishedCount.incrementAndGet(); long start = System.currentTimeMillis(); // try to await 1s to make sure jstack dump thread scheduled - await().atLeast(1000, TimeUnit.MILLISECONDS) - .until(() -> System.currentTimeMillis() - start >= 1000); + await().atLeast(300, TimeUnit.MILLISECONDS).until(() -> System.currentTimeMillis() - start >= 300); })); } catch (Exception ignored) { failureCount.incrementAndGet(); @@ -113,7 +114,7 @@ protected void jstack(FileOutputStream jStackStream) { } futureList.forEach(f -> { try { - f.get(2000, TimeUnit.MILLISECONDS); + f.get(500, TimeUnit.MILLISECONDS); } catch (Exception ignored) { timeoutCount.incrementAndGet(); } @@ -122,7 +123,7 @@ protected void jstack(FileOutputStream jStackStream) { System.out.printf( "jStackCount: %d, finishedCount: %d, failureCount: %d, timeoutCount: %d %n", jStackCount.get(), finishedCount.get(), failureCount.get(), timeoutCount.get()); - Mockito.verify(spyUrl, Mockito.times(1)).getParameter(DUMP_DIRECTORY); + // Mockito.verify(spyUrl, Mockito.times(1)).getParameter(DUMP_DIRECTORY); Assertions.assertEquals( runTimes, finishedCount.get() + failureCount.get(), "all the test thread should be run completely"); Assertions.assertEquals(1, jStackCount.get(), "'jstack' should be called only once in 10 minutes"); From 20772139e27a448350861fd340dd781bf5a79e42 Mon Sep 17 00:00:00 2001 From: lidongyao Date: Wed, 24 Jul 2024 15:10:51 +0800 Subject: [PATCH 7/7] remove unused code --- .../common/threadpool/support/AbortPolicyWithReportTest.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/dubbo-common/src/test/java/org/apache/dubbo/common/threadpool/support/AbortPolicyWithReportTest.java b/dubbo-common/src/test/java/org/apache/dubbo/common/threadpool/support/AbortPolicyWithReportTest.java index 53b0520b5f8..06fd96893d8 100644 --- a/dubbo-common/src/test/java/org/apache/dubbo/common/threadpool/support/AbortPolicyWithReportTest.java +++ b/dubbo-common/src/test/java/org/apache/dubbo/common/threadpool/support/AbortPolicyWithReportTest.java @@ -75,13 +75,13 @@ protected void jstack(FileOutputStream jStackStream) { @Test void jStack_ConcurrencyDump_Silence_10Min() { - URL spyUrl = URL.valueOf( + URL url = URL.valueOf( "dubbo://admin:hello1234@10.20.130.230:20880/context/path?dump.directory=/tmp&version=1.0.0&application=morgan&noValue="); AtomicInteger jStackCount = new AtomicInteger(0); AtomicInteger failureCount = new AtomicInteger(0); AtomicInteger finishedCount = new AtomicInteger(0); AtomicInteger timeoutCount = new AtomicInteger(0); - AbortPolicyWithReport abortPolicyWithReport = new AbortPolicyWithReport("Test", spyUrl) { + AbortPolicyWithReport abortPolicyWithReport = new AbortPolicyWithReport("Test", url) { @Override protected void jstack(FileOutputStream jStackStream) { jStackCount.incrementAndGet(); @@ -123,7 +123,6 @@ protected void jstack(FileOutputStream jStackStream) { System.out.printf( "jStackCount: %d, finishedCount: %d, failureCount: %d, timeoutCount: %d %n", jStackCount.get(), finishedCount.get(), failureCount.get(), timeoutCount.get()); - // Mockito.verify(spyUrl, Mockito.times(1)).getParameter(DUMP_DIRECTORY); Assertions.assertEquals( runTimes, finishedCount.get() + failureCount.get(), "all the test thread should be run completely"); Assertions.assertEquals(1, jStackCount.get(), "'jstack' should be called only once in 10 minutes");