WangzJi commented on code in PR #8023:
URL: https://github.com/apache/incubator-seata/pull/8023#discussion_r3151884194


##########
pom.xml:
##########
@@ -130,6 +131,16 @@
     </dependencyManagement>
 
     <profiles>
+        <!-- profile: onlyBuildOnJDK21+ -->
+        <profile>
+            <id>JDK21Plus</id>
+            <activation>
+                <jdk>[21,)</jdk>
+            </activation>
+            <modules>
+                <module>threadpool-loom</module>

Review Comment:
   Compile-time JDK and runtime classpath are different things though — even if 
we publish starter jars built on JDK 25, the published 
seata-spring-boot-starter pom doesn't declare seata-threadpool-loom (because 
all/pom.xml doesn't), so when a user pulls the starter into their JDK 21+ app, 
Maven won't fetch the loom artifact and the SPI lookup returns null. End users 
running on whatever JDK they want still need the dependency wired in. Or am I 
missing something about how the release artifacts are assembled?



##########
threadpool-loom/src/main/java/org/apache/seata/common/thread/VirtualScheduledThreadPoolExecutor.java:
##########
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.common.thread;
+
+import java.util.concurrent.RejectedExecutionHandler;
+import java.util.concurrent.ScheduledThreadPoolExecutor;
+
+/**
+ * Virtual-thread-backed scheduled thread pool implementation.
+ */
+public class VirtualScheduledThreadPoolExecutor extends 
ScheduledThreadPoolExecutor {
+
+    public VirtualScheduledThreadPoolExecutor(
+            String threadPrefix, int corePoolSize, boolean daemon, 
RejectedExecutionHandler rejectedHandler) {
+        super(corePoolSize, 
VirtualThreadFactoryHelper.newThreadFactory(threadPrefix, daemon), 
rejectedHandler);

Review Comment:
   Fair point on JEP 491 — agreed my pinning argument was off, ReentrantLock + 
Condition.await in DelayedWorkQueue.take() goes through LockSupport.park and 
unmounts cleanly on JDK 21+ already, so this isn't a pinning bug. Withdrawing 
that part. The remaining question is whether wrapping 
ScheduledThreadPoolExecutor with a virtual ThreadFactory actually buys us 
anything — concurrency is still capped at corePoolSize because that's how STPE 
schedules tasks, so the unbounded-virtual-threads property doesn't really 
apply. Not a blocker, just curious whether you measured a difference vs the 
platform path.



##########
seata-spring-boot-starter/src/main/java/org/apache/seata/spring/boot/autoconfigure/SeataSagaAutoConfiguration.java:
##########
@@ -118,20 +118,13 @@ public ThreadPoolExecutor sagaAsyncThreadPoolExecutor(
                 SagaAsyncThreadPoolProperties properties,
                 @Qualifier(SAGA_REJECTED_EXECUTION_HANDLER_BEAN_NAME)
                         RejectedExecutionHandler rejectedExecutionHandler) {
-            ThreadPoolExecutorFactoryBean threadFactory = new 
ThreadPoolExecutorFactoryBean();
-            
threadFactory.setBeanName("sagaStateMachineThreadPoolExecutorFactory");
-            threadFactory.setThreadNamePrefix("sagaAsyncExecute-");
-            threadFactory.setCorePoolSize(properties.getCorePoolSize());
-            threadFactory.setMaxPoolSize(properties.getMaxPoolSize());
-            threadFactory.setKeepAliveSeconds(properties.getKeepAliveTime());
-
-            return new ThreadPoolExecutor(
+            return ThreadPoolExecutorFactory.newThreadPoolExecutor(
+                    "sagaAsyncExecute",
                     properties.getCorePoolSize(),
                     properties.getMaxPoolSize(),
                     properties.getKeepAliveTime(),
                     TimeUnit.SECONDS,
                     new LinkedBlockingQueue<>(),
-                    threadFactory,
                     rejectedExecutionHandler);

Review Comment:
   Right, Thread.ofVirtual() always produces daemon threads — so once saga uses 
the virtual provider, daemon=true is forced regardless. My concern is the 
change for the platform path: Spring's ThreadPoolExecutorFactoryBean defaulted 
to non-daemon, so saga state-machine async tasks used to keep the JVM alive on 
shutdown until they finished. With this PR they don't. If that's an intentional 
behavior change for saga, fine — just want to make sure it's a deliberate call 
rather than a side effect of the migration.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to