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 670f997eac fix AbortPolicyWithReport Semaphore lock not released
(#13609)
670f997eac is described below
commit 670f997eac5bc0727628762f59cd30417e0f6c58
Author: CycleMaker <[email protected]>
AuthorDate: Mon Jan 8 20:40:08 2024 +0800
fix AbortPolicyWithReport Semaphore lock not released (#13609)
Co-authored-by: wuzihan <[email protected]>
---
.../threadpool/support/AbortPolicyWithReport.java | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 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 223a72419d..1f2e82e77e 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
@@ -156,13 +156,13 @@ public class AbortPolicyWithReport extends
ThreadPoolExecutor.AbortPolicy {
if (!guard.tryAcquire()) {
return;
}
- // To avoid multiple dump, check again
- if (System.currentTimeMillis() - lastPrintTime < TEN_MINUTES_MILLS) {
- return;
- }
-
- ExecutorService pool = Executors.newSingleThreadExecutor();
+ ExecutorService pool = null;
try {
+ // To avoid multiple dump, check again
+ if (System.currentTimeMillis() - lastPrintTime <
TEN_MINUTES_MILLS) {
+ return;
+ }
+ pool = Executors.newSingleThreadExecutor();
pool.execute(() -> {
String dumpPath = getDumpPath();
@@ -186,12 +186,14 @@ public class AbortPolicyWithReport extends
ThreadPoolExecutor.AbortPolicy {
logger.error(COMMON_UNEXPECTED_CREATE_DUMP, "", "", "dump
jStack error", t);
} finally {
lastPrintTime = System.currentTimeMillis();
- guard.release();
}
});
} finally {
+ guard.release();
// must shutdown thread pool ,if not will lead to OOM
- pool.shutdown();
+ if (pool != null) {
+ pool.shutdown();
+ }
}
}