Skip to content

refactor: merge threadpool and json-common modules#8132

Open
slievrly wants to merge 5 commits into
apache:2.xfrom
slievrly:2.x_26_06_06
Open

refactor: merge threadpool and json-common modules#8132
slievrly wants to merge 5 commits into
apache:2.xfrom
slievrly:2.x_26_06_06

Conversation

@slievrly

@slievrly slievrly commented Jun 7, 2026

Copy link
Copy Markdown
Member

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)

Ⅰ. 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

…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>
Copilot AI review requested due to automatic review settings June 7, 2026 14:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 into core; updates discovery modules to avoid circular dependencies by using PlatformThreadPoolProvider directly.
  • Moves JSON serializer SPI + implementations + allowlist manager into common, moves JsonUtil (configuration-aware) into core, and adds a JDK17-only Jackson3 serializer in jdk17.
  • 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.

Comment thread core/src/main/java/org/apache/seata/common/thread/ThreadPoolExecutorFactory.java Outdated
Comment thread bom/pom.xml
@codecov

codecov Bot commented Jun 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.20%. Comparing base (cb9c092) to head (ddd5458).
⚠️ Report is 2 commits behind head on 2.x.

Additional details and impacted files
@@             Coverage Diff              @@
##                2.x    #8132      +/-   ##
============================================
- Coverage     72.69%   72.20%   -0.50%     
  Complexity      879      879              
============================================
  Files          1327     1327              
  Lines         50852    50855       +3     
  Branches       6071     6071              
============================================
- Hits          36969    36718     -251     
- Misses        10888    11148     +260     
+ Partials       2995     2989       -6     
Files with missing lines Coverage Δ
...apache/seata/common/json/JsonAllowlistManager.java 0.00% <ø> (ø)
...pache/seata/common/json/JsonSerializerFactory.java 50.00% <ø> (ø)
...eata/common/json/impl/Fastjson2JsonSerializer.java 12.06% <ø> (ø)
...seata/common/json/impl/FastjsonJsonSerializer.java 25.86% <ø> (ø)
...che/seata/common/json/impl/GsonJsonSerializer.java 0.00% <ø> (ø)
.../seata/common/json/impl/JacksonJsonSerializer.java 44.30% <ø> (ø)
...eata/common/thread/PlatformThreadPoolExecutor.java 100.00% <ø> (ø)
...eata/common/thread/PlatformThreadPoolProvider.java 100.00% <ø> (ø)
...org/apache/seata/common/thread/ThreadPoolType.java 71.42% <ø> (ø)
...in/java/org/apache/seata/common/json/JsonUtil.java 57.89% <ø> (ø)
... and 15 more

... and 9 files with indirect coverage changes

Impacted file tree graph

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

slievrly and others added 3 commits June 7, 2026 23:29
- 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>
@funky-eyes funky-eyes added this to the 2.8.0 milestone Jun 23, 2026
@funky-eyes funky-eyes added the type: refactor refactor module label Jun 23, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 is seata-spi-jdk17 (and seata-spi-jdk21 elsewhere). Please align the PR description with the implemented artifactIds, or rename the artifacts consistently if seata-jdk17/seata-jdk21 is the intended public API.

Comment on lines 27 to 29
/**
* @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.
*/
Comment on lines +46 to 48
private static final ScheduledExecutorService HEARTBEAT_SCHEDULED = new PlatformThreadPoolProvider()
.newScheduledThreadPoolExecutor("seata-discovery-heartbeat", 1, true, new ThreadPoolExecutor.AbortPolicy());

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: refactor refactor module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants