Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@funky-eyes
Copy link
Contributor

@funky-eyes funky-eyes commented Jun 19, 2025

  • I have registered the PR changes.

Ⅰ. Describe what this PR did

Supports the HTTP/2 protocol and allows upgrading from HTTP/1 to HTTP/2, but only when the content-type is not grpc.
image

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

@codecov
Copy link

codecov bot commented Jun 19, 2025

Codecov Report

Attention: Patch coverage is 63.49206% with 69 lines in your changes missing coverage. Please review.

Project coverage is 60.37%. Comparing base (01a839f) to head (9b4ba82).
Report is 1 commits behind head on 2.x.

Files with missing lines Patch % Lines
...he/seata/core/rpc/netty/http/Http2HttpHandler.java 63.00% 27 Missing and 10 partials ⚠️
...he/seata/core/protocol/detector/Http2Detector.java 0.00% 12 Missing ⚠️
...che/seata/core/protocol/detector/HttpDetector.java 73.07% 7 Missing ⚠️
.../org/apache/seata/common/rpc/http/HttpContext.java 60.00% 6 Missing ⚠️
.../server/cluster/manager/ClusterWatcherManager.java 50.00% 3 Missing and 3 partials ⚠️
.../seata/core/rpc/netty/http/SimpleHttp2Request.java 90.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##                2.x    #7451      +/-   ##
============================================
+ Coverage     60.34%   60.37%   +0.03%     
  Complexity      658      658              
============================================
  Files          1281     1284       +3     
  Lines         48308    48465     +157     
  Branches       5676     5694      +18     
============================================
+ Hits          29150    29263     +113     
- Misses        16553    16585      +32     
- Partials       2605     2617      +12     
Files with missing lines Coverage Δ
...ta/core/rpc/netty/http/BaseHttpChannelHandler.java 100.00% <100.00%> (ø)
...seata/core/rpc/netty/http/HttpDispatchHandler.java 65.71% <100.00%> (-3.91%) ⬇️
.../seata/core/rpc/netty/http/SimpleHttp2Request.java 90.00% <90.00%> (ø)
.../org/apache/seata/common/rpc/http/HttpContext.java 48.27% <60.00%> (+9.38%) ⬆️
.../server/cluster/manager/ClusterWatcherManager.java 72.54% <50.00%> (-1.97%) ⬇️
...che/seata/core/protocol/detector/HttpDetector.java 81.57% <73.07%> (-3.04%) ⬇️
...he/seata/core/protocol/detector/Http2Detector.java 46.42% <0.00%> (+13.09%) ⬆️
...he/seata/core/rpc/netty/http/Http2HttpHandler.java 63.00% <63.00%> (ø)

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

@funky-eyes funky-eyes changed the title [wip]feature: support http2 feature: support http2 Jun 19, 2025
@funky-eyes funky-eyes requested a review from xjlgod June 19, 2025 13:06
@funky-eyes funky-eyes added this to the 2.5.0 milestone Jun 19, 2025
@funky-eyes funky-eyes added type: feature Category issues or prs related to feature request. module/core core module module/server server module labels Jun 19, 2025
@funky-eyes funky-eyes requested review from YongGoose and Copilot June 19, 2025 13:08

This comment was marked as outdated.

Copy link
Member

@YongGoose YongGoose left a comment

Choose a reason for hiding this comment

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

The code looks well written overall!

However, I noticed that there are quite a few comments written in Chinese in the test code. It would be great if you could update them to English :)

Also, for BaseHttpChannelHandler, it might be helpful to add some information about the role of this class, and which classes extend it.

Thank you for your work, always 👍🏻

Comment on lines +85 to +95
ChannelInboundHandlerAdapter finalExceptionHandler = new ChannelInboundHandlerAdapter() {
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
if (cause instanceof java.io.IOException) {
LOGGER.trace("Connection closed by client: {}", cause.getMessage());
} else {
LOGGER.error("Exception caught in HTTP pipeline: ", cause);
}
ctx.close();
}
};
Copy link
Member

Choose a reason for hiding this comment

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

Is it okay not to override methods like channelInactive and channelUnregistered?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is it okay not to override methods like channelInactive and channelUnregistered?

Since most HTTP connections are short-lived, if you do not override the exceptionCaught method, a large number of unexpected connection closed exceptions will be output. For example, if you use the curl command to simulate a request, you will encounter such exceptions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

.\curl.exe -i -X POST 127.0.0.1:8091/health --http2

23:23:16.110 ERROR --- [tyServerNIOWorker_1_10_16] [protocol.detector.HttpDetector] [     exceptionCaught]  [] : Connection closed by client: 

@funky-eyes funky-eyes requested a review from Copilot June 20, 2025 03:12
Copy link
Contributor

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

Adds HTTP/2 protocol support to Seata server, enabling HTTP/1→HTTP/2 upgrade (excluding gRPC) and unified context handling.

  • Introduces Http2HttpHandler, BaseHttpChannelHandler, and enhanced protocol detectors (HttpDetector, Http2Detector).
  • Refactors HttpDispatchHandler to use generic HttpContext<T> and removes its custom thread-pool setup.
  • Updates cluster‐watch APIs to parameterize HttpContext and adjust notification logic.

Reviewed Changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
server/src/main/java/org/apache/seata/server/controller/ClusterController.java Parameterized HttpContext to HttpContext<?>
server/src/main/java/org/apache/seata/server/cluster/manager/ClusterWatcherManager.java Restricted watcher queues to Watcher<HttpContext> and refined response logic
namingserver/src/main/java/org/apache/seata/namingserver/manager/ClusterWatcherManager.java Reordered imports (no functional change)
core/src/test/java/org/apache/seata/core/rpc/netty/http/Http2HttpHandlerTest.java Added comprehensive HTTP/2 handler tests
core/src/main/java/org/apache/seata/core/rpc/netty/http/SimpleHttp2Request.java New DTO for encapsulating HTTP/2 requests
core/src/main/java/org/apache/seata/core/rpc/netty/http/HttpDispatchHandler.java Switched to BaseHttpChannelHandler and simplified error handling
core/src/main/java/org/apache/seata/core/rpc/netty/http/Http2HttpHandler.java New handler for HTTP/2 frames and request dispatching
core/src/main/java/org/apache/seata/core/rpc/netty/http/BaseHttpChannelHandler.java Extracted shared HTTP logic (mapper, thread pool)
core/src/main/java/org/apache/seata/core/protocol/detector/HttpDetector.java Enhanced detector to support HTTP/1→HTTP/2 upgrade
core/src/main/java/org/apache/seata/core/protocol/detector/Http2Detector.java Routes gRPC vs non-gRPC streams after HTTP/2 preface
common/src/main/java/org/apache/seata/common/rpc/http/HttpContext.java Refactored to generic HttpContext<T> with version info
changes/zh-cn/2.x.md & changes/en-us/2.x.md Updated changelogs to include the HTTP/2 feature
Comments suppressed due to low confidence (1)

core/src/main/java/org/apache/seata/core/protocol/detector/HttpDetector.java:104

  • The magic number 1048576 is repeated here and in the HttpObjectAggregator instantiation. Extract it into a named constant (e.g., MAX_CONTENT_LENGTH) to improve readability and maintainability.
        };

@funky-eyes funky-eyes requested review from YongGoose and xjlgod June 20, 2025 14:46
@funky-eyes funky-eyes requested a review from xjlgod June 23, 2025 01:53
}
}));
} else {
return null;
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

image
What returns null is not the factory class, but the return value of the newUpgradeCodec method.

@funky-eyes funky-eyes requested review from YongGoose and jsbxyyx June 28, 2025 13:02
@funky-eyes funky-eyes requested a review from slievrly July 1, 2025 13:55
Copy link
Member

@YongGoose YongGoose left a comment

Choose a reason for hiding this comment

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

LGTM

@funky-eyes funky-eyes merged commit bf6601f into apache:2.x Jul 2, 2025
12 of 14 checks passed
slievrly pushed a commit to slievrly/fescar that referenced this pull request Oct 21, 2025
YvCeung pushed a commit to YvCeung/incubator-seata that referenced this pull request Dec 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module/core core module module/server server module type: feature Category issues or prs related to feature request.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants