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 2022/10/05 20:05:09 UTC

[GitHub] [pulsar] asafm commented on a diff in pull request #17256: [refactor][java] Improve docs and code quality about KeyValueSchema usages

asafm commented on code in PR #17256:
URL: https://github.com/apache/pulsar/pull/17256#discussion_r985803261


##########
pulsar-client/src/main/java/org/apache/pulsar/client/impl/TypedMessageBuilderImpl.java:
##########
@@ -105,14 +106,12 @@ public CompletableFuture<MessageId> sendAsync() {
 
     @Override
     public TypedMessageBuilder<T> key(String key) {
-        if (schema.getSchemaInfo().getType() == SchemaType.KEY_VALUE) {
-            KeyValueSchemaImpl kvSchema = (KeyValueSchemaImpl) schema;
-            checkArgument(kvSchema.getKeyValueEncodingType() != KeyValueEncodingType.SEPARATED,
-                    "This method is not allowed to set keys when in encoding type is SEPARATED");
-            if (key == null) {
-                msgMetadata.setNullPartitionKey(true);
-                return this;
-            }
+        getKeyValueSchema().ifPresent(keyValueSchema -> checkArgument(

Review Comment:
   While you're here, can you explain why when the schema is KeyValue, and the encoding is SEPARATED, it is forbidden to use this method to se the key of the message?



-- 
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: commits-unsubscribe@pulsar.apache.org

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