liudezhi2098 opened a new pull request #6390: fix duplicate key to send 
propertys
URL: https://github.com/apache/pulsar/pull/6390
 
 
   **Motivation**
   Fix when sending a message, set duplicate key to properties, can't pull the 
message while concumer #6388 
   ```javascript
   //org.apache.pulsar.client.impl.MessageImpl
   if (msgMetadata.getPropertiesCount() > 0) {
               this.properties = 
Collections.unmodifiableMap(msgMetadataBuilder.getPropertiesList().stream()
                       .collect(Collectors.toMap(KeyValue::getKey, 
KeyValue::getValue)));
           } else {
               properties = Collections.emptyMap();
           }
           this.schema = schema;
   ```
   Collectors.toMap can not allowed duplicate key
   
   **Changes**
   Replace old value with new value
   ```javascript
   if (msgMetadata.getPropertiesCount() > 0) {
               this.properties = 
Collections.unmodifiableMap(msgMetadataBuilder.getPropertiesList().stream()
                       .collect(Collectors.toMap(KeyValue::getKey, 
KeyValue::getValue,
                               (oldValue,newValue) -> newValue)));
           } else {
               properties = Collections.emptyMap();
           }
           this.schema = schema;
   ```

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to