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/19 19:16:15 UTC

[GitHub] [hadoop] virajjasani commented on a change in pull request #3683: HADOOP-18014. CallerContext should not include some characters.

virajjasani commented on a change in pull request #3683:
URL: https://github.com/apache/hadoop/pull/3683#discussion_r753453312



##########
File path: hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/CallerContext.java
##########
@@ -74,9 +82,24 @@ public String getContext() {
         null : Arrays.copyOf(signature, signature.length);
   }
 
+  /**
+   * Whether the context is valid.
+   * The context should not contain '\t', '\n', '='.
+   * Because the context could be written to audit log.
+   */
   @InterfaceAudience.Private
   public boolean isContextValid() {
-    return context != null && !context.isEmpty();
+    if (context == null || context.isEmpty()) {
+      return false;
+    }
+
+    for (String str: ILLEGAL_CHARACTERS) {
+      if (context.contains(str)) {
+        return false;
+      }
+    }
+
+    return true;

Review comment:
       nit: could be replaced with `return ILLEGAL_CHARACTERS.stream().noneMatch(context::contains)`.




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