test: verify typed nil scalar pointers encode as null - #394
Merged
AlexStocks merged 1 commit intoApr 29, 2026
Conversation
Contributor
Author
|
For the dubbo-go protocol layer, current So from the current codebase, both sides of apache/dubbo-go#2517 are covered. I think this issue can be closed after the hessian2 verification PR is merged. @tiltwind |
AlexStocks
approved these changes
Apr 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Refs apache/dubbo-go#2517
Refs #376
Refs #384
Why
PR #376 and PR #384 both try to fix typed nil pointer encoding by adding a generic reflect-based nil pointer check at the beginning of
Encoder.Encode.After checking current
master, the specific hessian2 case reported in apache/dubbo-go#2517 is already handled:(*int32)(nil)is routed toencTypeInt32encTypeInt32already returns Hessian null (N) for nil pointersTestNullInt32Ptralready covers the exact(*int32)(nil)caseSo the right follow-up is not another production-code change. The useful missing piece is a focused boundary test proving that typed nil scalar pointers are already encoded as Hessian null on current
master.Root Cause:
The old issue report was correct at the time:
v == nilalone cannot detect typed nil pointers such as(*int32)(nil).However, current
masteralready handles the reported hessian2 path through the existing typed int32 encoder logic. The remaining confusion comes from the lack of an explicit boundary test covering typed nil scalar pointers together.PR Goal:
Add a verification-only test PR that proves typed nil scalar pointers encode as Hessian null.
Provide clear evidence that #376 and #384 are no longer needed as production-code fixes.
Avoid adding a broad generic reflect nil-pointer branch to
Encoder.Encodewhen the reported behavior is already covered by existing encoder paths.Success Criteria:
(*int32)(nil)encodes to Hessian null (N).Other typed nil scalar pointers covered by this test also encode to Hessian null (
N):(*bool)(nil)(*string)(nil)(*float64)(nil)No production code is changed.
go test ./...passes.Paths this PR should affect:
null_test.goRevise
Adding
TestNullTypedScalarPointers: proves typed nil scalar pointers are encoded as Hessian null on currentmaster.Keeping production code unchanged: avoids duplicating #376/#384's generic reflect check and keeps encoder behavior scoped to existing implementation paths.
Using
Refsinstead ofFixes: apache/dubbo-go#2517 also mentions dubbo-go protocol-layer error propagation, so this hessian2 PR should not claim to close the whole cross-repo issue by itself.Tests
go test ./...