You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-issues@hadoop.apache.org by GitBox <gi...@apache.org> on 2021/11/12 02:10:50 UTC

[GitHub] [hadoop] tasanuma commented on a change in pull request #3644: HADOOP-18003. Add a method appendIfAbsent for CallerContext

tasanuma commented on a change in pull request #3644:
URL: https://github.com/apache/hadoop/pull/3644#discussion_r747932879



##########
File path: hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestCallerContext.java
##########
@@ -42,6 +42,37 @@ public void testBuilderAppend() {
         builder.build().getContext());
   }
 
+  @Test
+  public void testBuilderAppendIfAbsent() {
+    Configuration conf = new Configuration();
+    conf.set(HADOOP_CALLER_CONTEXT_SEPARATOR_KEY, "$");
+    CallerContext.Builder builder = new CallerContext.Builder(null, conf);
+    CallerContext context = builder.append("key1", "value1").build();
+    Assert.assertEquals("key1:value1",
+        builder.build().getContext());
+
+    // Append an existed key.
+    builder.appendIfAbsent("key1", "value1");

Review comment:
       We might want to change the value to make sure that this entry does not overwrite an existing entry which has the same key.
   ```suggestion
       builder.appendIfAbsent("key1", "value2");
   ```




-- 
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: common-issues-unsubscribe@hadoop.apache.org

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



---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org