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

funky-eyes pushed a commit to branch 2.x
in repository https://gitbox.apache.org/repos/asf/incubator-seata.git


The following commit(s) were added to refs/heads/2.x by this push:
     new b3d3eb6ae2 optimize: add checkstyle rules to enforce 
ThreadPoolExecutorFactory usage (#8092)
b3d3eb6ae2 is described below

commit b3d3eb6ae205f69de5d8797f5584d99111511d80
Author: 徐晓伟 <[email protected]>
AuthorDate: Thu May 7 14:32:39 2026 +0800

    optimize: add checkstyle rules to enforce ThreadPoolExecutorFactory usage 
(#8092)
---
 changes/en-us/2.x.md |  1 +
 changes/zh-cn/2.x.md |  1 +
 style/checkstyle.xml | 41 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 43 insertions(+)

diff --git a/changes/en-us/2.x.md b/changes/en-us/2.x.md
index ed6fb91621..f2af64baee 100644
--- a/changes/en-us/2.x.md
+++ b/changes/en-us/2.x.md
@@ -68,6 +68,7 @@ Add changes here for all PR submitted to the 2.x branch.
 - [[#8069](https://github.com/apache/incubator-seata/pull/8069)] bump 
org.assertj:assertj-core from 3.12.2 to 3.27.7
 - [[#8075](https://github.com/apache/incubator-seata/pull/8075)] bump 
at.yawk.lz4:lz4-java from 1.9.0 to 1.10.1
 - [[#8077](https://github.com/apache/incubator-seata/pull/8077)] removed the 
OkHttp3 dependency from the NamingServer
+- [[#8092](https://github.com/apache/incubator-seata/pull/8092)] add 
checkstyle rules to enforce ThreadPoolExecutorFactory usage
 
 ### security:
 
diff --git a/changes/zh-cn/2.x.md b/changes/zh-cn/2.x.md
index a12395def4..0b0f4d99a8 100644
--- a/changes/zh-cn/2.x.md
+++ b/changes/zh-cn/2.x.md
@@ -70,6 +70,7 @@
 - [[#8075](https://github.com/apache/incubator-seata/pull/8075)] 将 
at.yawk.lz4:lz4-java 从 1.9.0 版本升级到 1.10.1
 - [[#8077](https://github.com/apache/incubator-seata/pull/8077)] namingserver 
移除 okhttp3 依赖
 - [[#8086](https://github.com/apache/incubator-seata/pull/8086)] 
修改consoleRemotingFilter优先级
+- [[#8092](https://github.com/apache/incubator-seata/pull/8092)] 添加 checkstyle 
规则以强制使用 ThreadPoolExecutorFactory
 
 ### security:
 
diff --git a/style/checkstyle.xml b/style/checkstyle.xml
index 1e7a7167b2..1f40b6e859 100644
--- a/style/checkstyle.xml
+++ b/style/checkstyle.xml
@@ -61,6 +61,25 @@
         <property name="files" value="^(?!.*[\\/]test[\\/].*).*$"/>
     </module>
 
+    <module name="SuppressionSingleFilter">
+        <!-- new Thread() -->
+        <property name="id" value="DirectThreadCreation"/>
+        <property name="files"
+                  
value=".*[\\/]test[\\/].*|.*[\\/]org/apache/seata/config[\\/].*|.*[\\/]io/seata/config[\\/].*"/>
+    </module>
+    <module name="SuppressionSingleFilter">
+        <!-- Executors.new -->
+        <property name="id" value="ExecutorsUsage"/>
+        <property name="files"
+                  
value=".*[\\/]test[\\/].*|.*[\\/]org/apache/seata/config[\\/].*|.*[\\/]io/seata/config[\\/].*"/>
+    </module>
+    <module name="SuppressionSingleFilter">
+        <!-- new ThreadPoolExecutor -->
+        <property name="id" value="DirectThreadPoolExecutorCreation"/>
+        <property name="files"
+                  
value=".*[\\/]test[\\/].*|.*[\\/]org/apache/seata/config[\\/].*|.*[\\/]io/seata/config[\\/].*"/>
+    </module>
+
     <!-- Allow using @SuppressWarnings("checkstyle:...") in code -->
     <module name="SuppressWarningsFilter"/>
 
@@ -99,5 +118,27 @@
 
         <!-- Constant -->
         <module name="UpperEll"/>
+
+        <module name="RegexpSinglelineJava">
+            <property name="id" value="DirectThreadCreation"/>
+            <property name="format" value="new\s+Thread\s*\("/>
+            <property name="ignoreComments" value="true"/>
+            <property name="message"
+                      value="Direct thread creation is not allowed. Use 
ThreadPoolExecutorFactory instead."/>
+        </module>
+        <module name="RegexpSinglelineJava">
+            <property name="id" value="ExecutorsUsage"/>
+            <property name="format" value="Executors\s*\.\s*new"/>
+            <property name="ignoreComments" value="true"/>
+            <property name="message"
+                      value="Using Executors factory methods is not allowed. 
Use ThreadPoolExecutorFactory instead."/>
+        </module>
+        <module name="RegexpSinglelineJava">
+            <property name="id" value="DirectThreadPoolExecutorCreation"/>
+            <property name="format" value="new\s+ThreadPoolExecutor\s*\("/>
+            <property name="ignoreComments" value="true"/>
+            <property name="message"
+                      value="Direct ThreadPoolExecutor creation is not 
allowed. Use ThreadPoolExecutorFactory instead."/>
+        </module>
     </module>
 </module>


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to