[ISSUE #10724] Avoid raw gRPC response logs - #10725
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #10725 +/- ##
=============================================
- Coverage 48.31% 48.24% -0.08%
+ Complexity 13511 13486 -25
=============================================
Files 1380 1380
Lines 101091 101117 +26
Branches 13101 13109 +8
=============================================
- Hits 48844 48780 -64
- Misses 46285 46347 +62
- Partials 5962 5990 +28 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
RockteMQ-AI
left a comment
There was a problem hiding this comment.
Review by github-manager-bot
Summary
Replaces full gRPC response object logging in ResponseWriter with a compact summary that extracts only the protobuf type name and status code via reflection, preventing message payload bytes from appearing in logs.
Findings
- [Info] The protobuf reflection approach (
getDescriptorForType().getFullName()+ status/code field introspection) is elegant and generic — works for any RocketMQ protobuf response type without hardcoding field names per type. - [Info] Wrapping the
log.debugcall withisDebugEnabled()guard avoids unnecessarysummarizeResponse()computation when debug is off. Good optimization. - [Info] The fallback to
getClass().getSimpleName()for non-protobuf objects is safe and informative.
Suggestions
- [Warning]
appendStatusCodedoes multiple reflection lookups on every call. For a hot path like response writing, consider caching theFieldDescriptorlookups (e.g., as a staticConcurrentHashMap<Class<?>, FieldDescriptor[]>). This is a minor optimization and can be deferred. - [Info] The
instanceof MessageOrBuildercheck is correct since all RocketMQ gRPC responses implement this interface. - Tests are well-structured —
testSummarizeResponseDoesNotExposeMessagePayloadexplicitly verifies thatsecret-payloadandbodyare absent, andtestSummarizeResponseIncludesStatusCodeverifies the status code extraction.
Automated review by github-manager-bot
RockteMQ-AI
left a comment
There was a problem hiding this comment.
Review by github-manager-bot
Summary
Replaces raw protobuf response objects in gRPC ResponseWriter logs with a summarizeResponse() that extracts message type and status code. Also adds log.isDebugEnabled() guard for the debug-level write log.
Findings
- [Info] ResponseWriter.java:57 — Adding
log.isDebugEnabled()guard avoids unnecessarysummarizeResponse()computation when debug is disabled. Good optimization. - [Info] ResponseWriter.java:76-88 —
summarizeResponse()uses protobuf reflection (MessageOrBuilder.getDescriptorForType()) to extract the full message type name. This is a clean approach that works for any protobuf response type. - [Info] ResponseWriter.java:90-100 —
appendStatusCode()safely handles cases where the response doesn't have astatusfield by checking for nullFieldDescriptor. - [Info] Test coverage validates both protobuf and non-protobuf response types.
Suggestions
The protobuf reflection approach is elegant and generic. Well done.
Automated review by github-manager-bot
Summary
Fixes #10724
Tests