refactor: merge threadpool and json-common modules - #8132
Conversation
…ture Eliminate two top-level modules (threadpool, json-common) by distributing their code into existing modules based on dependency constraints, and create dedicated jdk17/jdk21 modules for version-specific extensions. threadpool refactoring: - Move SPI interface + platform impl (5 files) → common module - Move Factory + RuntimeEnvironment (2 files) → core module - Rename threadpool-loom → jdk21 (artifactId: seata-jdk21) - discovery-core/consul/etcd3/redis: use PlatformThreadPoolProvider directly to avoid core→discovery-core→core circular dependency json-common refactoring: - Move JsonSerializer SPI + 4 impl classes + AllowlistManager → common - Move JsonUtil (depends on ConfigurationFactory) → core module - Rename json-common-jackson3 → jdk17 (artifactId: seata-jdk17) - Remove json-common-core dependency from 5 downstream modules (available transitively through core) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR refactors the build/module layout by removing the top-level threadpool and json-common modules, relocating their code into common/core, and introducing jdk17/jdk21 extension modules to host JDK-specific SPI implementations.
Changes:
- Moves thread pool SPI + default platform implementation into
common, and factory/runtime selection intocore; updates discovery modules to avoid circular dependencies by usingPlatformThreadPoolProviderdirectly. - Moves JSON serializer SPI + implementations + allowlist manager into
common, movesJsonUtil(configuration-aware) intocore, and adds a JDK17-only Jackson3 serializer injdk17. - Renames the loom module to
jdk21(seata-jdk21), updates Maven modules/profiles, and trims downstream POM dependencies accordingly.
Reviewed changes
Copilot reviewed 45 out of 45 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| spring/seata-spring-autoconfigure/seata-spring-autoconfigure-client/pom.xml | Drops direct json-common-core dependency after refactor. |
| server/pom.xml | Switches JDK21 extension dependency from seata-threadpool-loom to seata-jdk21. |
| saga/pom.xml | Removes direct json-common-core dependency (now expected via core/common). |
| rm-datasource/pom.xml | Removes direct json-common-core dependency. |
| pom.xml | Removes threadpool/json-common modules and adds JDK17/JDK21 profile-driven modules. |
| jdk21/src/test/java/org/apache/seata/common/thread/VirtualThreadPoolProviderTest.java | Adds JDK21 virtual-thread provider tests. |
| jdk21/src/main/resources/META-INF/services/org.apache.seata.common.thread.ThreadPoolProvider | Registers the JDK21 ThreadPoolProvider SPI implementation. |
| jdk21/src/main/java/org/apache/seata/common/thread/VirtualThreadPoolProvider.java | Implements virtual-thread-backed ThreadPoolProvider for JDK21+. |
| jdk21/src/main/java/org/apache/seata/common/thread/VirtualThreadPoolExecutor.java | Adds virtual-thread-backed ThreadPoolExecutor implementation. |
| jdk21/src/main/java/org/apache/seata/common/thread/VirtualThreadFactoryHelper.java | Provides a virtual ThreadFactory helper enforcing daemon-only semantics. |
| jdk21/src/main/java/org/apache/seata/common/thread/VirtualScheduledThreadPoolExecutor.java | Adds virtual-thread-backed ScheduledThreadPoolExecutor implementation. |
| jdk21/pom.xml | Introduces the seata-jdk21 module/artifact and dependencies. |
| jdk17/src/test/java/org/apache/seata/common/json/Jackson3JsonSerializerTest.java | Adds tests for the Jackson3 JSON serializer SPI. |
| jdk17/src/test/java/org/apache/seata/common/json/Jackson3AllowlistTest.java | Adds allowlist/security behavior tests for Jackson3 auto-type handling. |
| jdk17/src/main/resources/META-INF/services/org.apache.seata.common.json.JsonSerializer | Registers the JDK17 Jackson3 JsonSerializer SPI implementation. |
| jdk17/src/main/java/org/apache/seata/common/json/impl/Jackson3JsonSerializer.java | Adds Jackson 3.x JsonSerializer implementation with allowlist validation. |
| jdk17/pom.xml | Introduces the seata-jdk17 module/artifact for JDK17+ extensions. |
| integration-tx-api/pom.xml | Drops direct json-common-core dependency. |
| discovery/seata-discovery-redis/src/main/java/org/apache/seata/discovery/registry/redis/RedisRegistryServiceImpl.java | Uses PlatformThreadPoolProvider directly to avoid dependency cycles. |
| discovery/seata-discovery-etcd3/src/main/java/org/apache/seata/discovery/registry/etcd3/EtcdRegistryServiceImpl.java | Uses PlatformThreadPoolProvider directly for executor construction. |
| discovery/seata-discovery-core/src/main/java/org/apache/seata/discovery/registry/RegistryHeartBeats.java | Uses PlatformThreadPoolProvider directly for heartbeat scheduler creation. |
| discovery/seata-discovery-core/pom.xml | Removes dependency on removed seata-threadpool module. |
| discovery/seata-discovery-consul/src/main/java/org/apache/seata/discovery/registry/consul/ConsulRegistryServiceImpl.java | Uses PlatformThreadPoolProvider directly for notifier executor construction. |
| core/src/test/java/org/apache/seata/common/thread/ThreadPoolExecutorFactoryTest.java | Adds tests for factory behavior and runtime selection logic. |
| core/src/main/java/org/apache/seata/common/thread/ThreadPoolRuntimeEnvironment.java | Adds runtime resolution for platform vs virtual thread pool modes. |
| core/src/main/java/org/apache/seata/common/thread/ThreadPoolExecutorFactory.java | Centralizes thread pool creation and provider selection in core. |
| core/src/main/java/org/apache/seata/common/json/JsonUtil.java | Adds configuration-aware JSON utility in core. |
| core/pom.xml | Removes dependency on removed seata-threadpool module. |
| compatible/pom.xml | Drops direct json-common-core dependency. |
| common/src/main/resources/META-INF/services/org.apache.seata.common.thread.ThreadPoolProvider | Registers the default platform thread pool provider SPI. |
| common/src/main/resources/META-INF/services/org.apache.seata.common.json.JsonSerializer | Registers built-in JSON serializer SPI implementations. |
| common/src/main/java/org/apache/seata/common/thread/ThreadPoolType.java | Adds enum for supported thread pool modes. |
| common/src/main/java/org/apache/seata/common/thread/ThreadPoolProviderOrders.java | Adds shared order constants for providers. |
| common/src/main/java/org/apache/seata/common/thread/ThreadPoolProvider.java | Introduces SPI interface for thread pool creation. |
| common/src/main/java/org/apache/seata/common/thread/PlatformThreadPoolProvider.java | Adds default platform-thread provider implementation. |
| common/src/main/java/org/apache/seata/common/thread/PlatformThreadPoolExecutor.java | Adds platform-thread-backed executor implementation wrapper. |
| common/src/main/java/org/apache/seata/common/json/JsonSerializerFactory.java | Adds central serializer factory with Jackson3 fallback behavior. |
| common/src/main/java/org/apache/seata/common/json/JsonSerializer.java | Adds unified JSON serializer SPI interface. |
| common/src/main/java/org/apache/seata/common/json/JsonAllowlistManager.java | Adds allowlist manager used by serializers to enforce safe polymorphic deserialization. |
| common/src/main/java/org/apache/seata/common/json/impl/JacksonJsonSerializer.java | Moves/hosts Jackson serializer implementation under common. |
| common/src/main/java/org/apache/seata/common/json/impl/GsonJsonSerializer.java | Moves/hosts Gson serializer implementation under common. |
| common/src/main/java/org/apache/seata/common/json/impl/FastjsonJsonSerializer.java | Moves/hosts Fastjson serializer implementation under common. |
| common/src/main/java/org/apache/seata/common/json/impl/Fastjson2JsonSerializer.java | Moves/hosts Fastjson2 serializer implementation under common. |
| common/pom.xml | Adds provided JSON library dependencies required by moved serializers. |
| bom/pom.xml | Replaces old threadpool artifacts with seata-jdk21 in dependency management. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 2.x #8132 +/- ##
============================================
- Coverage 73.04% 72.38% -0.66%
+ Complexity 1142 1141 -1
============================================
Files 1151 1151
Lines 42272 42275 +3
Branches 5045 5045
============================================
- Hits 30876 30600 -276
- Misses 8921 9201 +280
+ Partials 2475 2474 -1
🚀 New features to boost your workflow:
|
- Fix hardcoded module name in warn log: "seata-threadpool-virtual" → "seata-jdk21" to match the renamed artifact - Add seata-jdk17 to bom/pom.xml dependency management so downstream builds using seata-bom can consume the Jackson3 extension Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…modules - Rename directories jdk17 → spi-jdk17, jdk21 → spi-jdk21 - Rename artifactIds seata-jdk17 → seata-spi-jdk17, seata-jdk21 → seata-spi-jdk21 - Delete old modules: threadpool/, threadpool-loom/, json-common/ - Fix @deprecated javadoc references: "json-common-core module" → "seata-common module" - Update warn log module name to seata-spi-jdk21 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 44 out of 71 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
spi-jdk17/pom.xml:32
- PR description says the modules were renamed to artifacts
seata-jdk17/seata-jdk21, but the actual published artifactId here isseata-spi-jdk17(andseata-spi-jdk21elsewhere). Please align the PR description with the implemented artifactIds, or rename the artifacts consistently ifseata-jdk17/seata-jdk21is the intended public API.
| /** | ||
| * @deprecated use {@link org.apache.seata.common.json.JsonUtil} in json-common-core module instead. | ||
| * @deprecated use {@link org.apache.seata.common.json.JsonUtil} in seata-common module instead. | ||
| */ |
| private static final ScheduledExecutorService HEARTBEAT_SCHEDULED = new PlatformThreadPoolProvider() | ||
| .newScheduledThreadPoolExecutor("seata-discovery-heartbeat", 1, true, new ThreadPoolExecutor.AbortPolicy()); | ||
|
|
…olve # Conflicts: # pom.xml
funky-eyes
left a comment
There was a problem hiding this comment.
The overall module consolidation direction looks reasonable, but I think two issues should be addressed before merging:
The complete json-common-core test suite was deleted instead of being moved with the production code. This removes coverage for serializer SPI loading, Jackson 3 fallback, configuration resolution, and, more importantly, JSON deserialization allowlist security behavior. Please move serializer/factory/allowlist tests to seata-common, and move JsonUtilTest plus its configuration resources to seata-core.
The discovery implementations now instantiate PlatformThreadPoolProvider directly. This bypasses ThreadPoolExecutorFactory and therefore ignores the configured transport.threadpool mode for heartbeat, Consul notifier, Etcd watcher, and Redis subscription/update executors. Please introduce a shared provider resolver that does not create a core/discovery dependency cycle, or explicitly document and test that these executors are intentionally platform-thread-only.
Additional issues:
The deprecated integration-tx-api JsonUtil Javadoc says the replacement is in seata-common, while the class is now provided by seata-core.
The PR description refers to seata-jdk17 and seata-jdk21, but the actual artifacts are seata-spi-jdk17 and seata-spi-jdk21.
Please verify whether the removed Maven coordinates have ever been published. If so, compatibility bridge artifacts or an explicit migration strategy are needed.
Please add the corresponding change entries and run dependency:analyze for modules whose direct json-common-core dependency was removed.
Eliminate two top-level modules (threadpool, json-common) by distributing their code into existing modules based on dependency constraints, and create dedicated jdk17/jdk21 modules for version-specific extensions.
threadpool refactoring:
json-common refactoring:
Ⅰ. Describe what this PR did
Ⅱ. Does this pull request fix one issue?
Ⅲ. Why don't you add test cases (unit test/integration test)?
Ⅳ. Describe how to verify it
Ⅴ. Special notes for reviews