Yeah, sorry about that. I was struggling to find a consistent pattern given the 
complication of `OffsetAndMetadata` and the apparently frowned-upon use of 
`Optional` in fields. It is helpful generally when argument types match return 
types since it makes composition easier, but I'm not sure how you can achieve 
that with the standard usage advice for `Optional`. I think our options are the 
following:

1. Use `Optional<Integer>` everywhere (including in fields) except within 
`OffsetAndMetadata`.
2. Use nullable integer internally, but expose `Optional<Integer>` from public 
APIs.
3. Use primitive int with a sentinel internally, but expose `Optional<Integer>` 
from public APIs.

I was trying hard to avoid the third option because unsafe use of sentinel 
values can cause significantly more damage than unsafe use of an optional or 
nullable value. At least in the latter case, you get a fairly clear exception 
which is raised from the point of usage. Improper use of a sentinel value can 
have a massive impact at a distance from the usage (as mentioned above).

My inclination at the moment is probably option 1, but I'd like to hear other 
opinions.

[ 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