Fix inconsistent prompt message when schema version is empty using AVRO. - #14626
Merged
Conversation
codelipenghui
approved these changes
Mar 10, 2022
gaoran10
reviewed
Mar 11, 2022
nodece
approved these changes
Mar 11, 2022
Nicklee007
pushed a commit
to Nicklee007/pulsar
that referenced
this pull request
Apr 20, 2022
4 tasks
Comment on lines
+2030
to
+2034
| if (commandGetSchema.getSchemaVersion().length == 0) { | ||
| commandSender.sendGetSchemaErrorResponse(requestId, ServerError.IncompatibleSchema, | ||
| "Empty schema version"); | ||
| return; | ||
| } |
Contributor
There was a problem hiding this comment.
When I debugged testAvroSchemaWithTcpLookup and testAvroSchemaWithHttpLookup, it never went here. Then I removed these lines, tests still passed.
4 tasks
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.
Motivation
When create a topic with schema - AVRO, if a producer sends bytes data directly to the topic, a consumer with HTTP and TCP lookup has different prompt message. See below test:
If the consumer is using TCP lookup, it will get the below message :
But with HTTP lookup, the error message change to :
The root cause is that : if producer produce with bytes data, the schema version is empty. When in TCP lookup, the server will throw unchecked exception here(line-244) :
pulsar/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/schema/BookkeeperSchemaStorage.java
Lines 236 to 245 in 7c1f17a
When in HTTP lookup, the error will throw by the client here(line-164):
pulsar/pulsar-client/src/main/java/org/apache/pulsar/client/impl/HttpLookupService.java
Lines 161 to 165 in 7c1f17a
So in order to keep the consistent prompt message, we will check the empty schema at the client-side and throw the same exception.
Modifications
Documentation
no-need-doc