From 767eaa8ba707b1a62c30e671b9e70a12f74c202e Mon Sep 17 00:00:00 2001 From: Albumen Kevin Date: Thu, 21 Sep 2023 11:31:51 +0800 Subject: [PATCH] Fix code style (#13092) --- .../support/AbortPolicyWithReport.java | 51 ++++++++++--------- 1 file changed, 27 insertions(+), 24 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 8163b2b0b1..16c55331b5 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 @@ -151,34 +151,37 @@ public class AbortPolicyWithReport extends ThreadPoolExecutor.AbortPolicy { } ExecutorService pool = Executors.newSingleThreadExecutor(); - pool.execute(() -> { - String dumpPath = getDumpPath(); + try { + pool.execute(() -> { + String dumpPath = getDumpPath(); - SimpleDateFormat sdf; + SimpleDateFormat sdf; - String os = System.getProperty(OS_NAME_KEY).toLowerCase(); + String os = System.getProperty(OS_NAME_KEY).toLowerCase(); - // window system don't support ":" in file name - if (os.contains(OS_WIN_PREFIX)) { - sdf = new SimpleDateFormat(WIN_DATETIME_FORMAT); - } else { - sdf = new SimpleDateFormat(DEFAULT_DATETIME_FORMAT); - } + // window system don't support ":" in file name + if (os.contains(OS_WIN_PREFIX)) { + sdf = new SimpleDateFormat(WIN_DATETIME_FORMAT); + } else { + sdf = new SimpleDateFormat(DEFAULT_DATETIME_FORMAT); + } - String dateStr = sdf.format(new Date()); - //try-with-resources - try (FileOutputStream jStackStream = new FileOutputStream( - new File(dumpPath, "Dubbo_JStack.log" + "." + dateStr))) { - jstack(jStackStream); - } catch (Exception t) { - logger.error(COMMON_UNEXPECTED_CREATE_DUMP, "", "", "dump jStack error", t); - } finally { - lastPrintTime = System.currentTimeMillis(); - guard.release(); - } - }); - //must shutdown thread pool ,if not will lead to OOM - pool.shutdown(); + String dateStr = sdf.format(new Date()); + //try-with-resources + try (FileOutputStream jStackStream = new FileOutputStream( + new File(dumpPath, "Dubbo_JStack.log" + "." + dateStr))) { + jstack(jStackStream); + } catch (Exception t) { + logger.error(COMMON_UNEXPECTED_CREATE_DUMP, "", "", "dump jStack error", t); + } finally { + lastPrintTime = System.currentTimeMillis(); + guard.release(); + } + }); + } finally { + //must shutdown thread pool ,if not will lead to OOM + pool.shutdown(); + } }