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
(CDAP-9250) Using reflection to find out the number of arguments getOperationStat… #8490
(CDAP-9250) Using reflection to find out the number of arguments getOperationStat… #8490
Conversation
int i; | ||
// Find the getOperationStatus method so that we can check the number of arguments it expects. | ||
Method[] methods = cliService.getClass().getMethods(); | ||
for (i = 0; i < methods.length; i++) { |
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.
A little more concise and safe:
OperationStatus operationStatus;
Method getOperationStatus = null;
for (Method method : getCliService().getClass().getMethods()) {
if ("getOperationStatus".equals(method.getName())) {
getOperationStatus = method;
}
}
if (getOperationStatus == null) {
// throw exception
}
Also, you can move this part to the start of the service so it only needs to be done once.
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.
code looks good now, only minor comments from me.
@@ -53,6 +56,7 @@ | |||
*/ | |||
public class Hive14ExploreService extends BaseHiveExploreService { | |||
|
|||
private Method getOperationStatus; | |||
@Inject |
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 newline?
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.
and a comment what this is for?
} | ||
} | ||
if (getOperationStatus == null) { | ||
throw new RuntimeException("Failed to get the status of the Hive operation. Unable to find getOperationStatus " + |
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.
no need for the first sentence. You are not actually getting a status yet :)
…us takes and calling it accordingly.
9a754e2
to
f17e260
Compare
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.
LGTM
…us takes and calling it accordingly.