BewareMyPower commented on code in PR #19929:
URL: https://github.com/apache/pulsar/pull/19929#discussion_r1150267653
##########
pulsar-client/src/main/java/org/apache/pulsar/client/impl/ProducerImpl.java:
##########
@@ -733,24 +734,31 @@ boolean populateMessageSchema(MessageImpl msg,
SendCallback callback) {
completeCallbackAndReleaseSemaphore(msg.getUncompressedSize(),
callback, e);
return false;
}
- byte[] schemaVersion = schemaCache.get(msg.getSchemaHash());
- if (schemaVersion != null) {
- msgMetadataBuilder.setSchemaVersion(schemaVersion);
- msg.setSchemaState(MessageImpl.SchemaState.Ready);
- }
+
+ // do not use the return value to return the function call.
+ setMessageSchema(msg);
+
return true;
}
- private boolean rePopulateMessageSchema(MessageImpl msg) {
+ private boolean setMessageSchema(MessageImpl msg) {
byte[] schemaVersion = schemaCache.get(msg.getSchemaHash());
if (schemaVersion == null) {
return false;
}
- msg.getMessageBuilder().setSchemaVersion(schemaVersion);
+
+ if (schemaVersion != SchemaVersion.Empty.bytes()) {
+ msg.getMessageBuilder().setSchemaVersion(schemaVersion);
+ }
+
msg.setSchemaState(MessageImpl.SchemaState.Ready);
return true;
}
+ private boolean rePopulateMessageSchema(MessageImpl msg) {
+ return setMessageSchema(msg);
+ }
Review Comment:
I think we don't need to add another method (`setMessageSchema`) that is
completely the same with the existing method (`rePopuateMessageSchema`)
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]