Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
None
-
None
-
None
Description
The protocol generator generates useless conditions when a field of type string is made nullable after the request has been converted to using optional fields.
As an example, we have make the field `ProtocolName` nullable in the `JoinGroupResponse`. The `JoinGroupResponse` supports optional fields since version 6 and the field is nullable since version 7. Under these conditions, the generator generates the following code:
if (protocolName == null) { if (_version >= 7) { if (_version >= 6) { _writable.writeUnsignedVarint(0); } else { _writable.writeShort((short) -1); } } else { throw new NullPointerException(); } }
spotbugs raises an `UC_USELESS_CONDITION` because `_version >= 6` is always true.
We could optimise the generator to handle this.
Attachments
Issue Links
- links to