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

Fixed nil pointer dereference error when the Message == nil #57

Merged
merged 2 commits into from
Oct 18, 2014

Conversation

tmatsuo
Copy link
Contributor

@tmatsuo tmatsuo commented Oct 15, 2014

No description provided.

@tmatsuo
Copy link
Contributor Author

tmatsuo commented Oct 17, 2014

I encountered a panic because of this. Can you take a look?

@rakyll
Copy link
Contributor

rakyll commented Oct 17, 2014

Why is there a resp.PubsubEvent with a nil message btw?

LGTM

@tmatsuo
Copy link
Contributor Author

tmatsuo commented Oct 18, 2014

Yeah, I don't know ;)

tmatsuo pushed a commit that referenced this pull request Oct 18, 2014
Fixed nil pointer dereference error when the Message == nil
@tmatsuo tmatsuo merged commit e702df4 into googleapis:master Oct 18, 2014
@tmatsuo
Copy link
Contributor Author

tmatsuo commented Oct 24, 2014

I figured it out why.

It happens when you publish an empty message which doesn't have data nor any labels.
Maybe we should do either of

  1. to forbid publishing such messages
    or
  2. return empty message when receiving such messages

@tmatsuo
Copy link
Contributor Author

tmatsuo commented Oct 24, 2014

No I was wrong. It also happens when you publish a message with nil data, even you provide a label.
I think the easiest fix is convert nil to []byte{} when publishing. What do you think?

@rakyll
Copy link
Contributor

rakyll commented Oct 24, 2014

I wouldn't touch the existing code, a nil message may represent a distinct case than a []byte{} message. It was unexpected for me to receive a nil message, because I didn't know you were able to publish them.

@tmatsuo
Copy link
Contributor Author

tmatsuo commented Oct 24, 2014

Yeah, the problem is that with this library, you actually can not receive the nil message because pull returns an error.

@tmatsuo
Copy link
Contributor Author

tmatsuo commented Oct 24, 2014

Maybe we can return a message with nil Data instead of returning an error?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants