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

Matthias J. Sax updated KAFKA-5606:
-----------------------------------
    Fix Version/s:     (was: 2.2.0)

> Review consumer's RequestFuture usage pattern
> ---------------------------------------------
>
>                 Key: KAFKA-5606
>                 URL: https://issues.apache.org/jira/browse/KAFKA-5606
>             Project: Kafka
>          Issue Type: Bug
>            Reporter: Ismael Juma
>            Assignee: james chien
>            Priority: Major
>
> KAFKA-5556 shows that we can perhaps tighten the usage pattern of the 
> consumer's RequestFuture to avoid similar bugs in the future.
> Jason suggested:
> {quote}
> Another way to see this bug is a failure to ensure completion of the future. 
> Had we done so, then we could have skipped the failed check. This is why it 
> worked prior to the patch which added the timeout. The pattern should really 
> be something like this:
> {code}
> if (future.isDone()) {
>   if (future.succeeded()) {
>     // handle success
>   } else {
>     // handle failure
>   }
> }
> {code}
> I guess one benefit of the enum approach is that it forces you to ensure 
> completion prior to checking any of the possible results. That said, I'm a 
> bit more inclined to remove the isRetriable method and leave it to the caller 
> to determine what is and is not retriable. Then the request future only has 
> two completion states.
> {quote}
> An alternative is replacing succeeded and failed with a status method 
> returning an enum with 3 states: SUCCEEDED, FAILED, RETRY (the enum approach 
> mentioned above). This would make sense if we often have to handle these 3 
> states differently.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to