This is an automated email from the ASF dual-hosted git repository.

albumenj pushed a commit to branch 3.2
in repository https://gitbox.apache.org/repos/asf/dubbo.git


The following commit(s) were added to refs/heads/3.2 by this push:
     new 767eaa8ba7 Fix code style (#13092)
767eaa8ba7 is described below

commit 767eaa8ba707b1a62c30e671b9e70a12f74c202e
Author: Albumen Kevin <[email protected]>
AuthorDate: Thu Sep 21 11:31:51 2023 +0800

    Fix code style (#13092)
---
 .../threadpool/support/AbortPolicyWithReport.java  | 59 ++++++++++++----------
 1 file changed, 31 insertions(+), 28 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();
-
-            SimpleDateFormat sdf;
-
-            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);
-            }
-
-            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();
+        try {
+            pool.execute(() -> {
+                String dumpPath = getDumpPath();
+
+                SimpleDateFormat sdf;
+
+                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);
+                }
+
+                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();
+        }
 
     }
 

Reply via email to