[ 
https://issues.apache.org/jira/browse/KAFKA-9514?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

David Jacot resolved KAFKA-9514.
--------------------------------
    Fix Version/s: 2.7.0
       Resolution: Fixed

> The protocol generator generated useless condition when a field is made 
> nullable and flexible version is used
> -------------------------------------------------------------------------------------------------------------
>
>                 Key: KAFKA-9514
>                 URL: https://issues.apache.org/jira/browse/KAFKA-9514
>             Project: Kafka
>          Issue Type: Bug
>            Reporter: David Jacot
>            Assignee: David Jacot
>            Priority: Major
>             Fix For: 2.7.0
>
>
> 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:
> {code:java}
> if (protocolName == null) {
>  if (_version >= 7) {
>    if (_version >= 6) {
>      _writable.writeUnsignedVarint(0);
>    } else {
>      _writable.writeShort((short) -1);
>   }
>  } else {
>    throw new NullPointerException();
>  }
> }
> {code}
> spotbugs raises an `UC_USELESS_CONDITION` because `_version >= 6` is always 
> true.  
> We could optimise the generator to handle this.
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to