goiri commented on a change in pull request #2327:
URL: https://github.com/apache/hadoop/pull/2327#discussion_r496102830



##########
File path: 
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/CallerContext.java
##########
@@ -123,6 +140,37 @@ public Builder setSignature(byte[] signature) {
       return this;
     }
 
+    /**
+     * Append new item to the context.
+     * @param item
+     * @return builder
+     */
+    public Builder append(String item) {
+      if (isValid(item)) {
+        if (sb.length() > 0) {
+          sb.append(separator);
+        }
+        sb.append(item);
+      }
+      return this;
+    }
+
+    /**
+     * Append new item which contains key and value to the context.
+     * @param key
+     * @param value
+     * @return builder
+     */
+    public Builder append(String key, String value) {
+      if (isValid(key) && isValid(value)) {
+        if (sb.length() > 0) {
+          sb.append(separator);
+        }
+        sb.append(key + ":" + value);

Review comment:
       Should we make the colon a constant or even configurable?

##########
File path: 
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/CallerContext.java
##########
@@ -54,7 +58,7 @@
   private final byte[] signature;
 
   private CallerContext(Builder builder) {
-    this.context = builder.context;
+    this.context = builder.sb.length() > 0 ? builder.sb.toString() : null;

Review comment:
       I think it is cleaner to make it a method: getContext() in the Builder 
so we do the checks there.




----------------------------------------------------------------
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]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to