That was what I attempted to do initially. Unfortunately we cannot depend on 
initializers during object deserialization. When deserializing old versions, 
the new leader epoch field will be initialized to the default value for the 
corresponding type. So if we use `int leaderEpoch = 
RecordBatch.NO_PARTITION_LEADER_EPOCH`, then the value after deserialization 
will actually be 0. Since 0 is a valid value for this field, I couldn't think 
of a way to make it work. On the other hand, the default value for `Integer` is 
null, so it works. 

I really wish we hadn't made this class `Serializable`, but tough to take it 
away now. One possibility is to make this an exceptional case and to prefer the 
use of the `int` type for other classes.

[ Full content available at: https://github.com/apache/kafka/pull/5564 ]
This message was relayed via gitbox.apache.org for [email protected]

Reply via email to