@Override
    public void rejectedExecution(Runnable r, ThreadPoolExecutor e) {
        String msg = String.format(
                "Thread pool is EXHAUSTED!"
                        + " Thread Name: %s, Pool Size: %d (active: %d, core: %d, max: %d, largest: %d),"
                        + " Task: %d (completed: %d),"
                        + " Executor status:(isShutdown:%s, isTerminated:%s, isTerminating:%s), in %s://%s:%d!",
                threadName,
                e.getPoolSize(),
                e.getActiveCount(),
                e.getCorePoolSize(),
                e.getMaximumPoolSize(),
                e.getLargestPoolSize(),
                e.getTaskCount(),
                e.getCompletedTaskCount(),
                e.isShutdown(),
                e.isTerminated(),
                e.isTerminating(),
                url.getProtocol(),
                url.getIp(),
                url.getPort());

        // 0-1 - Thread pool is EXHAUSTED!
        logger.warn(COMMON_THREAD_POOL_EXHAUSTED, "too much client requesting provider", "", msg);

        if (Boolean.parseBoolean(url.getParameter(DUMP_ENABLE, Boolean.TRUE.toString()))) {
            dumpJStack();
        }

        dispatchThreadPoolExhaustedEvent(msg);

        throw new RejectedExecutionException(msg);
    }
@Test
    void jStackDumpTest() {
        URL url = URL.valueOf(
                "dubbo://admin:hello1234@10.20.130.230:20880/context/path?dump.directory=/tmp&version=1.0.0&application=morgan&noValue=");
        AtomicReference<FileOutputStream> fileOutputStream = new AtomicReference<>();

        AbortPolicyWithReport abortPolicyWithReport = new AbortPolicyWithReport("Test", url) {
            @Override
            protected void jstack(FileOutputStream jStackStream) {
                fileOutputStream.set(jStackStream);
            }
        };
        ExecutorService executorService = Executors.newFixedThreadPool(1);
        AbortPolicyWithReport.lastPrintTime = 0;
        Assertions.assertThrows(RejectedExecutionException.class, () -> {
            abortPolicyWithReport.rejectedExecution(
                    () -> System.out.println("hello"), (ThreadPoolExecutor) executorService);
        });

        await().until(() -> AbortPolicyWithReport.guard.availablePermits() == 1);
        Assertions.assertNotNull(fileOutputStream.get());
    }