Details
-
Improvement
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
-
None
Description
A couple of nagging things caught my eye with this class. The first thing:
BucketCodec.java
int statementId = options.getStatementId() >= 0 ? options.getStatementId() : 0; assert this.version >=0 && this.version <= MAX_VERSION : "Version out of range: " + version; if(!(options.getBucketId() >= 0 && options.getBucketId() <= MAX_BUCKET_ID)) { throw new IllegalArgumentException("bucketId out of range: " + options.getBucketId()); } if(!(statementId >= 0 && statementId <= MAX_STATEMENT_ID)) { throw new IllegalArgumentException("statementId out of range: " + statementId); }
statementId gets capped, if it's less than 0, then it gets rounded up to 0. However, it later checks that the statementId is greater,... which is will always be 'true' since it's getting rounded.
- Remove the rounding behavior.
- Make better error message
- Fail-fast in the constructor if the version is invalid