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

Ayush Saxena commented on FLINK-15740:
--------------------------------------

Thnax Everyone for the discussion.
{quote}And once the exception can be thrown by this method {{hasTimeleft()}} 
becomes redundant in a lot of cases.
{quote}
But seems removal of {{hasTimeLeft()}} won't be feasible as such, if we remove 
{{hasTimeLeft()}} and rely on the exception thrown for {{timeLeftIfAny()}} 
there would be some unnecessary evaluations,( statements presently between 
{{hasTImeLeft()}} and {{timeLeft()}}), those evaluations wouldn't be done if 
{{hasTimeLeft()}} was false at start, now if we remove this check, the 
statements would be executed till {{timeLeftIfAny()}}, which would be more 
costlier then checking {{hasTimeLeft()}}

 

Thoughts??

> Remove Deadline#timeLeft()
> --------------------------
>
>                 Key: FLINK-15740
>                 URL: https://issues.apache.org/jira/browse/FLINK-15740
>             Project: Flink
>          Issue Type: Improvement
>          Components: API / DataStream, Tests
>            Reporter: Chesnay Schepler
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 1.11.0
>
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> As shown in FLINK-13662, {{Deadline#timeLeft()}} is conceptually broken since 
> there is no reliable way to call said method while ensuring that
>  a) the value is non-negative (desired since most time-based APIs reject 
> negative values)
>  b) the value sign (+,-) corresponds to preceding calls to {{#hasTimeLeft()}}
>  
> As a result any usage of the following form is unreliable and obfuscating 
> error messages.
> {code:java}
> while (deadline.hasTimeLeft()) {
>       doSomething(deadline.timeLeft());
> } {code}
>  
> All existing usage should be migrate to either
> {code:java}
> while (deadline.hasTimeLeft()) {
>       doSomething();
> } {code}
> or
> {code:java}
> while (true) {
>       doSomething(deadline.timeLeftIfAny());
> }
> {code}



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

Reply via email to