Add functionality for the omission of unused optional parameters in a JSON-RPC request#314
Add functionality for the omission of unused optional parameters in a JSON-RPC request#314liamgilligan wants to merge 1 commit intoConsensusJ:masterfrom
Conversation
JSON-RPC allows for unused optional parameters to be omitted from the `params` member of a Request object when `params` is represented by an Array. It only requires that required parameters are present and that the present parameters are in the order the server expects. For more details, see https://www.jsonrpc.org/specification\#parameter_structures
msgilligan
left a comment
There was a problem hiding this comment.
Looks good, but I have three minor requests.
| import java.util.Arrays; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.*; |
There was a problem hiding this comment.
Avoid using wildcard imports. Your IDE may be doing this automatically -- check your IDE settings.
When doing PR reviews it's important to see exactly which classes are imported and which imports have been added or removed.
| return paramsFromNet; | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
This looks good, but I would put the helper method below callMethod in the source file.
| CompletableFuture<RSLT> future; | ||
| final Method mh = getMethod(methodName); | ||
| if (mh != null) { | ||
| params = addNullParams(mh.getParameterCount(), params); |
There was a problem hiding this comment.
The params variable should not be mutated here. With rare exceptions we try to treat all local and parameter variables as "effectively final" (but without explicitly adding the final keyword) IDEs generally mark mutated variables with an underline or similar indication, so you can be made aware of when this happening.
So please create a new local variable here (maybe completeParams?) and pass it to the mh.invoke().
JSON-RPC allows for unused optional parameters to be omitted from the
paramsmember of a Request object.paramsis represented by an Array. It only requires that required parameters are present and that the present parameters are in the order the server expects. For more details, see https://www.jsonrpc.org/specification#parameter_structuresThis PR adds the server-side functionality to handle these omitted parameters when they are given by-position, as specified in the JSON-RPC spec.