Repository navigation
[Issue 304][Reader] fixed panic in CreateReader API using custom MessageID for ReaderOptions - #305
Merged
Conversation
Contributor
Author
|
@wolfstudy @sijie @Ghatage please have a look |
1 task
|
Great stuff @nitishv! Excited to have you involved in the Pulsar community! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #304
Motivation
User of the client's client's CreateReader API can use a custom type satisfying the MessageID interface, when using it as a value for
StartMessageIDin ReaderOptions argument for the mentioned API.The current reader creation does an untested type assertion here, when preparing the
consumerOptionsneeded for creating apartitionConsumer.https://github.com/apache/pulsar-client-go/blob/master/pulsar/reader_impl.go#L64
This assertion of
MessageIDas*messageIDwill fail unless an instance ofMessageIDis created from one of these exported APIs becausemessageIDis unexportedhttps://github.com/apache/pulsar-client-go/blob/master/pulsar/message.go#L114-#L126
Note:
newMessageIDreturns*messageIDwhich satisfiesMessageIDinterface as well.Modifications
Test the type assertion of
MessageIDas*messageID, if it fails, re-create a newMessageIDusing thispulsar-client-go/pulsar/impl_message.go
Line 97 in 975eb37
This will ensure that the custom type can be re-created as a
*messageIDwhich can be used bypartitionConsumerOptsVerifying this change
This change added tests and can be verified as follows:
Added unit test
TestReaderOnSpecificMessageWithCustomMessageIDingithub.com/apache/pulsar-client-go/pulsarpackage.Test uses a custom StartMessageID in ReaderOptions while creating a new reader to read from a specific message ID, rather than the pre-canned earliest/latest options.
CI script test result snippet below.
Does this pull request potentially affect one of the following parts:
Documentation