-
Notifications
You must be signed in to change notification settings - Fork 5k
[Improvement-17311][RPC] Validate the args type in RPC method #17312
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
[Improvement-17311][RPC] Validate the args type in RPC method #17312
Conversation
| args = null; | ||
| } else { | ||
| args = new Object[standardRpcRequest.getArgs().length]; | ||
| if (!methodInvoker.isParameterTypeValidated(standardRpcRequest.getArgsTypes())) { |
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.
minor nit: this can happen 1 line earlier before the args assignment
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.
Done
| if (argType == null) { | ||
| continue; | ||
| } | ||
| if (parameterTypes.get(i) != argType) { |
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.
one option here is to use https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html#isAssignableFrom-java.lang.Class-
- this would allow subclasses to be accepted
- the current check only works if the classes are an exact match
The if would look something like:
if (parameterTypes.get(i).isAssignableFrom(argType)
This is worth testing because I have a habit of getting this check the wrong way around.
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.
Great suggestions, thank you!
SbloodyS
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.
LGTM
a465d27 to
4841a30
Compare
|



Purpose of the pull request
close #17311
Brief change log
Verify this pull request
This pull request is code cleanup without any test coverage.
(or)
This pull request is already covered by existing tests, such as (please describe tests).
(or)
This change added tests and can be verified as follows:
(or)
Pull Request Notice
Pull Request Notice
If your pull request contains incompatible change, you should also add it to
docs/docs/en/guide/upgrade/incompatible.md