fix(jsonrpc): reject numeric request ids that are not long integers

0X
5d ago
+124-10

What does this PR do?

JsonRpcRequestValidator rejects numeric request ids that are not integer literals within the signed 64-bit range. Such a request is now answered with:

{"jsonrpc":"2.0","error":{"code":-32600,"message":"Invalid Request: numeric id must be an integer literal within the signed 64-bit range"},"id":9223372036854775808}

Why are these changes required?

jsonrpc4j's parseId() reads such ids with asInt() or asDouble(), so the call is executed but the response carries a truncated or rounded id that the client cannot match to its request. jsonrpc4j 1.7 is the latest release and master still has the same code; Rejecting is simpler than restoring the id outside jsonrpc4j, common clients send integer counters or string ids, and the JSON-RPC 2.0 specification says numeric ids SHOULD NOT contain fractional parts.

This PR has been tested by:

  • Unit Tests: JsonRpcServletTest and AdminJsonRpcRequestTest cover rejection with exact echo of out-of-range integers and fractional or exponent ids, in single and batch requests, and keep Long.MAX_VALUE, Long.MIN_VALUE and string ids accepted. The new assertions fail on the current release_v4.8.3 head.
  • Manual Testing

Follow up

None.

Extra details

Breaking change (release-note item): JSON-RPC requests whose numeric id is not an integer literal within [-9223372036854775808, 9223372036854775807] are now rejected with -32600 Invalid Request.