-
Notifications
You must be signed in to change notification settings - Fork 8.9k
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
HDFS-17606. Do not require implementing CustomizedCallbackHandler. #7005
Conversation
💔 -1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
@@ -34,6 +36,24 @@ public void handleCallback(List<Callback> callbacks, String username, char[] pas | |||
} | |||
} | |||
|
|||
static CustomizedCallbackHandler delegate(Object delegated) { |
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.
As of last week, DynMethod exists in hadoop common to assist here. Have look to see if it would help or are your needs better. A key aspect is can extract IOEs from the invocation
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.
@steveloughran , thanks for the info! Since we need to back port this to some earlier versions, we won't use DynMethod
at the moment.
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.
optional feedback on production code...but do want those test changes
|
||
// without setting conf, expect UnsupportedCallbackException | ||
try { | ||
new SaslServerCallbackHandler(conf, String::toCharArray).handle(callbacks); |
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.
use LambdaTestUtils.intercept()
// set conf and expect success | ||
conf.setClass(HdfsClientConfigKeys.DFS_DATA_TRANSFER_SASL_CUSTOMIZEDCALLBACKHANDLER_CLASS_KEY, | ||
MyCallbackMethod.class, Object.class); | ||
new SaslServerCallbackHandler(conf, String::toCharArray).handle(callbacks); |
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.
add a static counter somewhere to verify the callback was actually invoked.
add another test to raise an exception in the callback to verify it gets reported.
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.
Sure, will add both.
🎊 +1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
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 once you add the javadoc and are confident the failure is unrelated
the assertj recommendations are hints, it's just time you embraced assertJ for its powerful comparators, especially on sets, lists etc.
I had a look to see if java functional APIs had an interface you could just probe for/cast to instead, but sadly there isn't. If there was there'd be no need for reflection at all
LAST_CALLBACKS.set(callbacks); | ||
} | ||
|
||
static void assertCallbacks(Callback[] expected) { |
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.
add a javadoc explaining what it does
|
||
static void assertCallbacks(Callback[] expected) { | ||
final List<Callback> computed = LAST_CALLBACKS.getAndSet(null); | ||
Assert.assertNotNull(computed); |
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.
I think you could do this in a single AssertJ assertion, especially lines 49-51, provides expected
was actually a list.
AssertJ.assertThat(computed)
.describedAs("computed callbacks")
.isNotNull()
.hasSameElementsAs(expected)
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.
Tried it but AssertJ
was not available for import. So I will keep the current code and avoid adding the dependency.
The failure of TestMover is unrelated to this. Let's retry. |
🎊 +1 overall
This message was automatically generated. |
@steveloughran , thanks a lots for reviewing this! |
Description of PR
HDFS-17576 added a
CustomizedCallbackHandler
interface which declares the following method:This Jira HDFS-17606 is to allow an implementation to define the handleCallback method without implementing the
CustomizedCallbackHandler
interface. It is to avoid a security provider depending on the HDFS project.How was this patch tested?
A new test.
For code changes:
LICENSE
,LICENSE-binary
,NOTICE-binary
files?