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

Change status package to deal with concrete types instead of interfaces #1171

Merged
merged 5 commits into from
Apr 6, 2017

Conversation

dfawley
Copy link
Member

@dfawley dfawley commented Apr 5, 2017

No description provided.

@dfawley dfawley added the Type: API Change Breaking API changes (experimental APIs only!) label Apr 5, 2017
status/status.go Outdated
if s.Code() == codes.OK {
return nil
}
return (*statusError)(proto.Clone(s.s).(*spb.Status))
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we still make a clone here?

Copy link
Member Author

Choose a reason for hiding this comment

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

To make it impossible to mutate the statusError and change the Code into OK.

Without this, but the rest of the code as-is, one could do:

status := status.New(codes.Internal, "blah")
p := status.Proto()
err := status.Err()
p.Code = int32(codes.OK)

Maybe status.Proto() and FromProto() should do the clone instead, making Status immutable, which is how I had it initially.

@@ -335,7 +335,7 @@ func (s *Stream) Read(p []byte) (n int, err error) {

// finish sets the stream's state and status, and closes the done channel.
// s.mu must be held by the caller.
func (s *Stream) finish(st status.Status) {
func (s *Stream) finish(st *status.Status) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Comment this should never be called with nil?

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
Contributor

@menghanl menghanl left a comment

Choose a reason for hiding this comment

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

LGTM

@dfawley dfawley merged commit 1d27587 into grpc:master Apr 6, 2017
@dfawley dfawley deleted the status2 branch April 6, 2017 18:41
@menghanl menghanl added the 1.3 label Apr 8, 2017
@lock lock bot locked as resolved and limited conversation to collaborators Jan 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Type: API Change Breaking API changes (experimental APIs only!) Type: Bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants