Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 5 commits into from
Jul 24, 2024

Conversation

dfawley
Copy link
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
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
Member Author

Choose a reason for hiding this comment

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

Done

Copy link

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
13 checks passed
@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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Feature New features or improvements in behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants