Skip to content

Conversation

@YvCeung
Copy link
Contributor

@YvCeung YvCeung commented Oct 27, 2025

Ⅰ. Describe what this PR did

  1. 优化并统一了 HTTP 客户端工具类,实现对 h2c 协议的兼容与支持。
  2. 在服务端补充了 watch 逻辑中对 HTTP/2 协议响应发送的支持。
  3. 修复了 Http2HttpHandler 在解析 application/x-www-form-urlencoded 请求时可能导致解析失败的问题。

1.Enhanced and unified the HTTP client utility to support the h2c protocol.
2.Added support for sending responses over HTTP/2 within the server-side watch logic.
3.Fixed an issue in Http2HttpHandler where parsing requests with the application/x-www-form-urlencoded content type could fail.

Ⅱ. Does this pull request fix one issue?

fix #7732
fix #7712
fix #7685

Ⅲ. Why don't you add test cases (unit test/integration test)?

Ⅳ. Describe how to verify it

It can be verified by observing the test cases of the integrated test case ClusterControllerTest

Ⅴ. Special notes for reviews

@YvCeung YvCeung marked this pull request as ready for review October 27, 2025 14:54
@YvCeung
Copy link
Contributor Author

YvCeung commented Oct 27, 2025

@funky-eyes @YongGoose PTAL

@YvCeung YvCeung added module/server server module module/common common module labels Oct 27, 2025
@codecov
Copy link

codecov bot commented Oct 27, 2025

Codecov Report

❌ Patch coverage is 45.83333% with 65 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.66%. Comparing base (df7172d) to head (bb9db10).
⚠️ Report is 1 commits behind head on 2.x.

Files with missing lines Patch % Lines
...a/org/apache/seata/common/util/HttpClientUtil.java 42.50% 38 Missing and 8 partials ⚠️
.../server/cluster/manager/ClusterWatcherManager.java 39.13% 11 Missing and 3 partials ⚠️
...he/seata/core/rpc/netty/http/Http2HttpHandler.java 66.66% 3 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##                2.x    #7736      +/-   ##
============================================
+ Coverage     63.64%   63.66%   +0.02%     
  Complexity      990      990              
============================================
  Files          1324     1323       -1     
  Lines         50125    50155      +30     
  Branches       5920     5928       +8     
============================================
+ Hits          31901    31932      +31     
+ Misses        15386    15376      -10     
- Partials       2838     2847       +9     
Files with missing lines Coverage Δ
...he/seata/core/protocol/detector/Http2Detector.java 82.14% <ø> (+35.71%) ⬆️
...rpc/netty/http/filter/HttpRequestParamWrapper.java 77.98% <100.00%> (+24.27%) ⬆️
...initializer/db/SqlServerResourceIdInitializer.java 78.57% <ø> (ø)
...he/seata/core/rpc/netty/http/Http2HttpHandler.java 67.79% <66.66%> (+3.64%) ⬆️
.../server/cluster/manager/ClusterWatcherManager.java 68.18% <39.13%> (-4.37%) ⬇️
...a/org/apache/seata/common/util/HttpClientUtil.java 43.18% <42.50%> (+1.27%) ⬆️

... and 10 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.

Copy link

Copilot AI left a comment

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 enhances HTTP/2 protocol support across both client and server components of the Seata system. The changes include unifying the HTTP client utility to support h2c (HTTP/2 cleartext) protocol, adding HTTP/2 response handling in the server-side watch logic, and fixing a parsing issue for form-urlencoded requests in the HTTP/2 handler.

Key Changes:

  • Unified HTTP client utilities by consolidating Http5ClientUtil functionality into HttpClientUtil with HTTP/2 support
  • Added HTTP/2 response handling in ClusterWatcherManager for watch operations
  • Fixed Http2HttpHandler to properly parse application/x-www-form-urlencoded request bodies

Reviewed Changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
common/src/main/java/org/apache/seata/common/util/HttpClientUtil.java Added HTTP/2 client methods using OkHttp with h2c protocol support
common/src/main/java/org/apache/seata/common/util/Http5ClientUtil.java Removed (functionality merged into HttpClientUtil)
core/src/main/java/org/apache/seata/core/rpc/netty/http/Http2HttpHandler.java Enhanced to parse both JSON and form-urlencoded request bodies
server/src/main/java/org/apache/seata/server/cluster/manager/ClusterWatcherManager.java Added HTTP/2 response sending logic for watch operations
server/src/test/java/org/apache/seata/server/controller/ClusterControllerTest.java Added HTTP/2-specific test cases for watch and XSS filter functionality
common/pom.xml Changed okhttp dependency scope to provided
Multiple pom.xml files Added okhttp dependencies where needed
Comments suppressed due to low confidence (1)

server/src/main/java/org/apache/seata/server/cluster/manager/ClusterWatcherManager.java:1

  • The HTTP/1.1 response handling duplicates ctx.writeAndFlush(response) in both the if and else branches. Consider simplifying by removing the conditional logic since the only difference is setting the keep-alive header, which doesn't affect the flush operation.
/*

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +125 to +131
String[] pairs = request.getBody().split("&");
for (String pair : pairs) {
String[] kv = pair.split("=", 2);
if (kv.length == 2) {
formParams.put(kv[0], kv[1]);
}
}
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

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

Form parameter values are not URL-decoded. When parsing 'application/x-www-form-urlencoded' data, values must be decoded using URLDecoder.decode() to properly handle special characters and encoded spaces.

Copilot uses AI. Check for mistakes.
@funky-eyes funky-eyes added this to the 2.6.0 milestone Oct 28, 2025
@YvCeung YvCeung changed the title optimize:Enhance the support for http2 on both the client and server sides 【Don't merge . It will be split into multiple PRS】Enhance the support for http2 on both the client and server sides Oct 28, 2025
@YongGoose YongGoose added the Do Not Merge Do not merge into develop label Oct 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Do Not Merge Do not merge into develop module/common common module module/server server module

Projects

None yet

3 participants