dmsolr opened a new pull request, #7940: URL: https://github.com/apache/shenyu/pull/7940
## What this PR does Adds an opt-in bound to the gRPC plugin's aggregated response so that SERVER_STREAMING / BIDI_STREAMING calls can no longer retain an unbounded number of results before the RPC terminates. Two configurable budgets (item count and payload bytes) are introduced; on exhaustion the underlying RPC is cancelled, retained results are released, and the call future completes exceptionally so a documented error is returned instead of a success-shaped partial aggregate. ## Related Issue Fixes #7928 ## Type of change - [x] Bug fix - [x] New feature / enhancement ## Details - `GrpcRegisterConfig` gains `maxAggregatedResultCount` and `maxAggregatedResultBytes`. `null`/non-positive means unlimited, preserving the historical behavior (opt-in bounding, backward compatible). - `MessageWriter` tracks the retained item count and accumulated UTF-8 payload bytes. When a budget is crossed it clears the retained results, ignores further `onNext`, and cancels the bound `ClientCall` with a descriptive reason. Cancellation propagates through gRPC to `CompleteObserver.onError`, completing the result future exceptionally, which `GrpcPlugin` maps to a `ShenyuException`. - `ShenyuGrpcClient` resolves the budgets from the plugin config singleton and binds the `ClientCall` to the writer; `invoke` now creates the call once and reuses it across all method types. - The byte budget measures serialized payload bytes, not an exact JVM heap bound (documented in code). Each call owns its own writer/response, so concurrent RPCs are isolated. Note: this bounds aggregation only; it does not introduce end-to-end streaming backpressure or change the aggregated JSON output shape for calls within the configured limits. ## How was this tested - [x] Unit tests added / updated (`MessageWriterTest`: below/at/above count and byte budgets, overflow releases results and cancels once, post-overflow messages ignored, unlimited default, writer isolation; `GrpcRegisterConfigTest`: new fields + equals/hashCode) - [x] `./mvnw test -pl shenyu-plugin/.../shenyu-plugin-grpc` passed (24 tests) - [x] `./mvnw test -pl shenyu-common -Dtest=GrpcRegisterConfigTest` passed (3 tests) - [x] Checkstyle passed on both modules ## Checklist - [x] Apache 2.0 license header present on source files - [x] No breaking changes to public API / config / DB schema (new config fields are optional and default to unlimited) -- 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]
