You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "james chien (JIRA)" <ji...@apache.org> on 2017/07/21 03:27:00 UTC

[jira] [Commented] (KAFKA-5606) Review consumer's RequestFuture usage pattern

    [ https://issues.apache.org/jira/browse/KAFKA-5606?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16095715#comment-16095715 ] 

james chien commented on KAFKA-5606:
------------------------------------

I am interest with this :D

> 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
>             Fix For: 0.11.1.0
>
>
> 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
(v6.4.14#64029)