You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2020/07/05 02:56:10 UTC

[GitHub] [pulsar] nitishv commented on issue #3180: Go client Reader panics when passing custom StartMessageID

nitishv commented on issue #3180:
URL: https://github.com/apache/pulsar/issues/3180#issuecomment-653834975


   Hey @wolfstudy @sijie 
   
   I'm new to this community, but would like to start contributing.
   I had a look at the reader code and the type assertion seems incorrect here and must be tested to avoid the panic.
   https://github.com/apache/pulsar/blob/master/pulsar-client-go/pulsar/c_reader.go#L118
   
   Value of options.StartMessageID which is of Go Type [MessageID](https://github.com/apache/pulsar/blob/master/pulsar-client-go/pulsar/message.go#L81), will fail to be used as type *[messageID](https://github.com/apache/pulsar/blob/master/pulsar-client-go/pulsar/c_message.go#L39) if the value passed to it is created by anything other than these 2 available defaults https://github.com/apache/pulsar/blob/35bb23520ca0518764952d0a780a50861ee5a0d7/pulsar-client-go/pulsar/message.go#L93
   
   The fix in my opinion would be to test the type assertion, and if it fails, recreate a messageID using its serialized data using this https://github.com/apache/pulsar/blob/35bb23520ca0518764952d0a780a50861ee5a0d7/pulsar-client-go/pulsar/message.go#L87
   This will ensure compatibility with *messageID when passing as argument to underlying cgo code.
   
   Let me know if this looks good.
   
   Also, on a separate note, is there any documentation to test go code?
   I tried unit testing locally from within the pulsar-client-go and got this error.
   Are there some prep steps for the C environment which I'm missing?
   
   ```bash
   $ go test github.com/apache/pulsar/pulsar-client-go/pulsar -run=TestReader
   # github.com/apache/pulsar/pulsar-client-go/pulsar
   In file included from pulsar/c_client.go:24:
   ./c_go_pulsar.h:22:10: fatal error: 'pulsar/c/client.h' file not found
   #include <pulsar/c/client.h>
            ^~~~~~~~~~~~~~~~~~~
   1 error generated.
   FAIL    github.com/apache/pulsar/pulsar-client-go/pulsar [build failed]
   ```
   
   
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org