This is an automated email from the ASF dual-hosted git repository.
aaronai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/rocketmq-clients.git
The following commit(s) were added to refs/heads/master by this push:
new 2c9b67d Revert "Add extraProperties for PublishingMessageImpl" (#271)
2c9b67d is described below
commit 2c9b67ddf74de9d31d1d16b5449e71a37c463b3c
Author: Aaron Ai <[email protected]>
AuthorDate: Mon Oct 31 19:14:11 2022 +0800
Revert "Add extraProperties for PublishingMessageImpl" (#271)
* Revert "Add extraProperties for PublishingMessageImpl"
This reverts commit 735a2ebb37332c8a6dfc6b8537f5ec966cf77858.
* Revert "Add unit test for PublishingMessageImpl#getExtraProperties"
This reverts commit 82a7eff42444b8e376bd74354d80582d7d70eaba.
---
.../client/java/message/PublishingMessageImpl.java | 16 +-------
.../java/message/PublishingMessageImplTest.java | 45 ----------------------
2 files changed, 1 insertion(+), 60 deletions(-)
diff --git
a/java/client/src/main/java/org/apache/rocketmq/client/java/message/PublishingMessageImpl.java
b/java/client/src/main/java/org/apache/rocketmq/client/java/message/PublishingMessageImpl.java
index 9dbfbe7..c1e2a85 100644
---
a/java/client/src/main/java/org/apache/rocketmq/client/java/message/PublishingMessageImpl.java
+++
b/java/client/src/main/java/org/apache/rocketmq/client/java/message/PublishingMessageImpl.java
@@ -22,8 +22,6 @@ import apache.rocketmq.v2.SystemProperties;
import com.google.protobuf.ByteString;
import com.google.protobuf.util.Timestamps;
import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
import java.util.Optional;
import org.apache.rocketmq.client.apis.message.Message;
import org.apache.rocketmq.client.apis.message.MessageId;
@@ -41,14 +39,10 @@ public class PublishingMessageImpl extends MessageImpl {
private final MessageType messageType;
private volatile String traceContext;
- // Allow to inject extra user properties in runtime.
- private final Map<String, String> extraProperties;
-
public PublishingMessageImpl(Message message, PublishingSettings
publishingSettings, boolean txEnabled)
throws IOException {
super(message);
this.traceContext = null;
- this.extraProperties = new HashMap<>();
final int length = message.getBody().remaining();
final int maxBodySizeBytes = publishingSettings.getMaxBodySizeBytes();
if (length > maxBodySizeBytes) {
@@ -98,10 +92,6 @@ public class PublishingMessageImpl extends MessageImpl {
return Optional.ofNullable(traceContext);
}
- public Map<String, String> getExtraProperties() {
- return extraProperties;
- }
-
/**
* Convert {@link PublishingMessageImpl} to protocol buffer.
*
@@ -136,10 +126,6 @@ public class PublishingMessageImpl extends MessageImpl {
this.getMessageGroup().ifPresent(systemPropertiesBuilder::setMessageGroup);
final SystemProperties systemProperties =
systemPropertiesBuilder.build();
Resource topicResource =
Resource.newBuilder().setName(getTopic()).build();
- Map<String, String> userProperties = new HashMap<>();
- userProperties.putAll(this.getProperties());
- // Extra properties has higher priority.
- userProperties.putAll(this.extraProperties);
return apache.rocketmq.v2.Message.newBuilder()
// Topic
.setTopic(topicResource)
@@ -148,7 +134,7 @@ public class PublishingMessageImpl extends MessageImpl {
// System properties
.setSystemProperties(systemProperties)
// User properties
- .putAllUserProperties(userProperties)
+ .putAllUserProperties(getProperties())
.build();
}
}
diff --git
a/java/client/src/test/java/org/apache/rocketmq/client/java/message/PublishingMessageImplTest.java
b/java/client/src/test/java/org/apache/rocketmq/client/java/message/PublishingMessageImplTest.java
deleted file mode 100644
index 703bba9..0000000
---
a/java/client/src/test/java/org/apache/rocketmq/client/java/message/PublishingMessageImplTest.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.rocketmq.client.java.message;
-
-import static org.junit.Assert.assertEquals;
-
-import java.io.IOException;
-import java.util.Map;
-import org.apache.rocketmq.client.apis.message.Message;
-import org.apache.rocketmq.client.java.impl.producer.PublishingSettings;
-import org.apache.rocketmq.client.java.tool.TestBase;
-import org.junit.Test;
-
-public class PublishingMessageImplTest extends TestBase {
-
- @Test
- public void testGetExtraProperties() throws IOException {
- final PublishingSettings publishingSettings = fakeProducerSettings();
- final String topic = FAKE_TOPIC_0;
- final Message message = fakeMessage(topic);
-
- final PublishingMessageImpl publishingMessage = new
PublishingMessageImpl(message, publishingSettings, true);
- final String propertyKey = "traceparent";
- final String propertyValue =
"00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01";
- publishingMessage.getExtraProperties().put(propertyKey, propertyValue);
- final apache.rocketmq.v2.Message pbMessage =
publishingMessage.toProtobuf(fakeMessageQueueImpl(topic));
- final Map<String, String> userPropertiesMap =
pbMessage.getUserPropertiesMap();
- assertEquals(propertyValue, userPropertiesMap.get(propertyKey));
- }
-}