-
Notifications
You must be signed in to change notification settings - Fork 9.2k
HADOOP-18014. CallerContext should not include some characters. #3698
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
virajjasani
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left one minor nit. The core logic of using escapeJava() to parse the special chars seems the right choice here.
| MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).build(); | ||
| LogCapturer auditlog = LogCapturer.captureLogs(FSNamesystem.auditLog); | ||
|
|
||
| try { | ||
| cluster.waitClusterUp(); | ||
| final FileSystem fs = cluster.getFileSystem(); | ||
| final long time = System.currentTimeMillis(); | ||
| final Path p = new Path("/"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: how about using try-with-resources here?
try (MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).build()) {
LogCapturer auditlog = LogCapturer.captureLogs(FSNamesystem.auditLog);
cluster.waitClusterUp();
...
...
...
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your review. I updated. 4d1aa67
|
💔 -1 overall
This message was automatically generated. |
virajjasani
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems we might have to consider few things for test, else the core changes look good
| final long time = System.currentTimeMillis(); | ||
| final Path p = new Path("/"); | ||
|
|
||
| assertNull(CallerContext.getCurrent()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to be failing as per QA report:
Error Message
expected null, but was:<>
Stacktrace
java.lang.AssertionError: expected null, but was:<>
at org.junit.Assert.fail(Assert.java:89)
at org.junit.Assert.failNotNull(Assert.java:756)
at org.junit.Assert.assertNull(Assert.java:738)
at org.junit.Assert.assertNull(Assert.java:748)
at org.apache.hadoop.hdfs.server.namenode.TestAuditLogger.testCallerContextCharacterEscape(TestAuditLogger.java:617)
Maybe we can use separate thread here so that we can expect callerContext to be null (per ThreadLocal)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@virajjasani Thanks for your review. I fixed it to clear the caller context at the end of the unit test. ff11828
|
💔 -1 overall
This message was automatically generated. |
virajjasani
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 (non-binding), pending QA
|
🎊 +1 overall
This message was automatically generated. |
|
Merged it. Thanks for your reviews, @virajjasani, @liuml07, @ferhui! |
Reviewed-by: Viraj Jasani <[email protected]> Reviewed-by: Mingliang Liu <[email protected]> Reviewed-by: Hui Fei <[email protected]> Cherry-picked from 9c887e5 by Owen O'Malley
…he#3698) Reviewed-by: Viraj Jasani <[email protected]> Reviewed-by: Mingliang Liu <[email protected]> Reviewed-by: Hui Fei <[email protected]>
…he#3698) Reviewed-by: Viraj Jasani <[email protected]> Reviewed-by: Mingliang Liu <[email protected]> Reviewed-by: Hui Fei <[email protected]> Cherry-picked from 9c887e5 by Owen O'Malley
Description of PR
CallerContext should not include control characters.
This PR is a different approach from #3683.
How was this patch tested?
I created a unit test and confirmed that it succeeded.
For code changes: