Skip to content

cmd/protoc-gen-go-grpc: test the embedded struct at registration time for proper usage#7438

Merged
dfawley merged 5 commits intogrpc:masterfrom
dfawley:unimpl3
Jul 24, 2024
Merged

cmd/protoc-gen-go-grpc: test the embedded struct at registration time for proper usage#7438
dfawley merged 5 commits intogrpc:masterfrom
dfawley:unimpl3

Conversation

@dfawley
Copy link
Copy Markdown
Member

@dfawley dfawley commented Jul 24, 2024

relnotes for cmd/protoc-gen-go-grpc:

  • The generated function Register<Service>Server now panics if the Unimplemented<Service>Server struct is embedded in a way that would lead to runtime panics if an unimplemented method was called. Users are advised to ensure they are properly embedding the Unimplemented struct for their service, and to regenerate their proto files to confirm.

RELEASE NOTES: none

@dfawley dfawley added the Type: Feature New features or improvements in behavior label Jul 24, 2024
@dfawley dfawley added this to the 1.66 Release milestone Jul 24, 2024
@dfawley dfawley requested a review from easwars July 24, 2024 21:35
Comment on lines +313 to +315
g.P("// If the following call pancis, it indicates Unimplemented", serverType, " was embedded by pointer")
g.P("// and is nil. This will cause panics if an unimplemented method is ever invoked, so we test this")
g.P("// at initialization time to prevent it from happening at runtime later due to I/O.")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: Could these comments also be wrapped at 80-cols. Thanks.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done

@codecov
Copy link
Copy Markdown

codecov bot commented Jul 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.33%. Comparing base (0231b0d) to head (2692295).
Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7438      +/-   ##
==========================================
- Coverage   81.44%   81.33%   -0.11%     
==========================================
  Files         352      352              
  Lines       26919    26919              
==========================================
- Hits        21924    21895      -29     
- Misses       3804     3822      +18     
- Partials     1191     1202      +11     

see 19 files with indirect coverage changes

@dfawley dfawley merged commit 9671c4a into grpc:master Jul 24, 2024
@dfawley dfawley deleted the unimpl3 branch July 24, 2024 21:52
printchard pushed a commit to printchard/grpc-go that referenced this pull request Jul 30, 2024
printchard pushed a commit to printchard/grpc-go that referenced this pull request Jul 30, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Type: Feature New features or improvements in behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants