Github user ahgittin commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/816#discussion_r141620123
  
    --- Diff: 
utils/common/src/main/java/org/apache/brooklyn/util/repeat/Repeater.java ---
    @@ -269,6 +274,21 @@ public Boolean call() throws Exception {
             });
         }
     
    +    public <T> Repeater until(final Supplier<T> supplier, final 
Predicate<T> exitCondition) {
    +        Preconditions.checkNotNull(supplier, "supplier must not be null");
    +        Preconditions.checkNotNull(exitCondition, "exitCondition must not 
be null");
    +        return until(new Callable<Boolean>() {
    +            @Override
    +            public Boolean call() throws Exception {
    +                return exitCondition.apply(supplier.get());
    +            }
    +            @Override
    +            public String toString() {
    +                return supplier.get()+" "+exitCondition.toString();
    --- End diff --
    
    many suppliers don't have a nice `toString()` and often when used (in 
tests) what we're interested in is the value.  but i think you're right, this 
is potentially dangerous.  i've added a last value cache and we now
    
        return ""+(lastValue.isPresent() ? lastValue.get() : supplier) + " " + 
exitCondition;



---

Reply via email to