Skip to content

Conversation

@EvenLjj
Copy link
Collaborator

@EvenLjj EvenLjj commented Nov 12, 2025

fix triple pojo overload issue

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced validation to prevent invalid method overload configurations in streaming scenarios. The system now properly rejects duplicate method names with streaming types instead of silently overwriting them, providing clearer error messages to users when misconfiguration is detected.

@sofastack-cla sofastack-cla bot added bug Something isn't working cla:yes CLA is ok size/XS labels Nov 12, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 12, 2025

Walkthrough

A validation mechanism was added to prevent method overloads for streaming in the method call type cache. The change uses putIfAbsent to detect duplicate method names and throws a SofaRpcException when overloads are encountered.

Changes

Cohort / File(s) Summary
Streaming method validation
remoting/remoting-triple/src/main/java/com/alipay/sofa/rpc/utils/SofaProtoUtils.java
Added guard logic to prevent method overloads by using putIfAbsent when populating methodCallType. Throws SofaRpcException with UNKNOWN error type if a duplicate method name is detected, replacing silent overwrites with strict validation.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Single localized change with straightforward guard logic
  • Clear error handling with descriptive exception message
  • No complex interdependencies or multi-file impacts

Suggested labels

cla:yes, size/XS

Poem

🐰 No overloads allowed in these streaming lanes,
A guard stands firm to break the chains,
Duplicate methods? Off they go!
One path per name—that's how we flow.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix triple pojo overload issue' directly relates to the main change, which addresses method overload handling in triple POJO streaming by preventing overwrite of streaming method types.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/triple_pojo_overload_issue

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a073684 and aab1d68.

📒 Files selected for processing (1)
  • remoting/remoting-triple/src/main/java/com/alipay/sofa/rpc/utils/SofaProtoUtils.java (1 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: EvenLjj
Repo: sofastack/sofa-rpc PR: 1488
File: remoting/remoting-triple/src/main/java/com/alipay/sofa/rpc/interceptor/ServerReqHeaderInterceptor.java:105-120
Timestamp: 2025-05-08T06:59:23.963Z
Learning: In SOFA RPC, TripleTracerAdapter.serverReceived() sets the invocation type on the SofaRequest based on the gRPC method type (CLIENT_STREAMING, SERVER_STREAMING, BIDI_STREAMING), but the SofaRequest.isAsync() method does not directly recognize these streaming types as asynchronous. According to EvenLjj, some modification in TripleTracerAdapter.serverReceived makes sofaRequest.isAsync() return true for streaming requests.
📚 Learning: 2025-05-08T06:59:23.963Z
Learnt from: EvenLjj
Repo: sofastack/sofa-rpc PR: 1488
File: remoting/remoting-triple/src/main/java/com/alipay/sofa/rpc/interceptor/ServerReqHeaderInterceptor.java:105-120
Timestamp: 2025-05-08T06:59:23.963Z
Learning: In SOFA RPC, TripleTracerAdapter.serverReceived() sets the invocation type on the SofaRequest based on the gRPC method type (CLIENT_STREAMING, SERVER_STREAMING, BIDI_STREAMING), but the SofaRequest.isAsync() method does not directly recognize these streaming types as asynchronous. According to EvenLjj, some modification in TripleTracerAdapter.serverReceived makes sofaRequest.isAsync() return true for streaming requests.

Applied to files:

  • remoting/remoting-triple/src/main/java/com/alipay/sofa/rpc/utils/SofaProtoUtils.java
📚 Learning: 2025-05-08T06:34:38.670Z
Learnt from: EvenLjj
Repo: sofastack/sofa-rpc PR: 1488
File: remoting/remoting-triple/src/main/java/com/alipay/sofa/rpc/tracer/sofatracer/TripleTracerAdapter.java:290-303
Timestamp: 2025-05-08T06:34:38.670Z
Learning: In SOFA-RPC's Triple protocol adapter, the server detects invocation type (streaming/sync) from gRPC method descriptors but intentionally doesn't propagate this to request properties or headers. This is by design to maintain compatibility with clients of different versions, as the server should rely on client-provided values rather than overriding them.

Applied to files:

  • remoting/remoting-triple/src/main/java/com/alipay/sofa/rpc/utils/SofaProtoUtils.java
🧬 Code graph analysis (1)
remoting/remoting-triple/src/main/java/com/alipay/sofa/rpc/utils/SofaProtoUtils.java (1)
core/exception/src/main/java/com/alipay/sofa/rpc/core/exception/RpcErrorType.java (1)
  • RpcErrorType (24-110)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: build
  • GitHub Check: sca

Comment on lines +103 to +105
if (methodCallType.putIfAbsent(method.getName(), streamType) != null) {
throw new SofaRpcException(RpcErrorType.UNKNOWN, "triple pojo stream do not support method overload!!!");
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Use consistent error type and improve error message quality.

The validation logic correctly prevents method overloads, but there are two issues:

  1. Inconsistent error type: This validation uses RpcErrorType.UNKNOWN, while similar call-type validations elsewhere in this file (lines 92, 126, 134) use RpcErrorType.CLIENT_CALL_TYPE. For consistency, this should also use CLIENT_CALL_TYPE.

  2. Error message quality: The message has grammatical issues ("stream do not" → "streaming does not") and excessive exclamation marks. Consider a more professional message like: "Triple POJO streaming does not support method overloads"

Apply this diff to address both issues:

-                if (methodCallType.putIfAbsent(method.getName(), streamType) != null) {
-                    throw new SofaRpcException(RpcErrorType.UNKNOWN, "triple pojo stream do not support method overload!!!");
-                }
+                if (methodCallType.putIfAbsent(method.getName(), streamType) != null) {
+                    throw new SofaRpcException(RpcErrorType.CLIENT_CALL_TYPE, 
+                        "Triple POJO streaming does not support method overloads");
+                }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (methodCallType.putIfAbsent(method.getName(), streamType) != null) {
throw new SofaRpcException(RpcErrorType.UNKNOWN, "triple pojo stream do not support method overload!!!");
}
if (methodCallType.putIfAbsent(method.getName(), streamType) != null) {
throw new SofaRpcException(RpcErrorType.CLIENT_CALL_TYPE,
"Triple POJO streaming does not support method overloads");
}
🤖 Prompt for AI Agents
In
remoting/remoting-triple/src/main/java/com/alipay/sofa/rpc/utils/SofaProtoUtils.java
around lines 103 to 105, the exception uses RpcErrorType.UNKNOWN and an
unpolished message; change the error type to RpcErrorType.CLIENT_CALL_TYPE to
match other call-type validations and replace the message with a professional
sentence such as "Triple POJO streaming does not support method overloads"
(remove extra punctuation and fix grammar).

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

Labels

bug Something isn't working cla:yes CLA is ok size/XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants