ADDITIONAL SYSTEM INFORMATION :
Independent of OS
A DESCRIPTION OF THE PROBLEM :
1) Documentation for StructuredConcurrency Joiner CancelAfterTwoFailures is wrong; it uses method all() but should use allUntil()
2) CancelAfterTwoFailures is not generic enough and forces results / subtask to produce the same results
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Copy paste documentation into editor => compile error, since all() is the wrong method name => alllUntil()
class CancelAfterTwoFailures<T> implements Predicate<Subtask<? extends T>>
{
private final AtomicInteger failedCount = new AtomicInteger();
@Override
public boolean test(Subtask<? extends T> subtask)
{
return subtask.state() == Subtask.State.FAILED
&& failedCount.incrementAndGet() >= 2;
}
}
var joiner = Joiner.all(new CancelAfterTwoFailures<String>());
´´´´
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
1) should compile, correct the documentation
2) use a more generic version like this:
class CancelAfterTwoFailures<T> implements Predicate<Subtask<?>>
{
private final AtomicInteger failedCount = new AtomicInteger();
@Override
public boolean test(Subtask<?> subtask)
{
return subtask.state() == Subtask.State.FAILED
&& failedCount.incrementAndGet() >= 2;
}
}
var joiner = Joiner.allUntil(new CancelAfterTwoFailures<String>());
---------- BEGIN SOURCE ----------
class CancelAfterTwoFailures<T> implements Predicate<Subtask<?>>
{
private final AtomicInteger failedCount = new AtomicInteger();
@Override
public boolean test(Subtask<?> subtask)
{
return subtask.state() == Subtask.State.FAILED
&& failedCount.incrementAndGet() >= 2;
}
}
var joiner = Joiner.allUntil(new CancelAfterTwoFailures<String>());
---------- END SOURCE ----------
Independent of OS
A DESCRIPTION OF THE PROBLEM :
1) Documentation for StructuredConcurrency Joiner CancelAfterTwoFailures is wrong; it uses method all() but should use allUntil()
2) CancelAfterTwoFailures is not generic enough and forces results / subtask to produce the same results
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Copy paste documentation into editor => compile error, since all() is the wrong method name => alllUntil()
class CancelAfterTwoFailures<T> implements Predicate<Subtask<? extends T>>
{
private final AtomicInteger failedCount = new AtomicInteger();
@Override
public boolean test(Subtask<? extends T> subtask)
{
return subtask.state() == Subtask.State.FAILED
&& failedCount.incrementAndGet() >= 2;
}
}
var joiner = Joiner.all(new CancelAfterTwoFailures<String>());
´´´´
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
1) should compile, correct the documentation
2) use a more generic version like this:
class CancelAfterTwoFailures<T> implements Predicate<Subtask<?>>
{
private final AtomicInteger failedCount = new AtomicInteger();
@Override
public boolean test(Subtask<?> subtask)
{
return subtask.state() == Subtask.State.FAILED
&& failedCount.incrementAndGet() >= 2;
}
}
var joiner = Joiner.allUntil(new CancelAfterTwoFailures<String>());
---------- BEGIN SOURCE ----------
class CancelAfterTwoFailures<T> implements Predicate<Subtask<?>>
{
private final AtomicInteger failedCount = new AtomicInteger();
@Override
public boolean test(Subtask<?> subtask)
{
return subtask.state() == Subtask.State.FAILED
&& failedCount.incrementAndGet() >= 2;
}
}
var joiner = Joiner.allUntil(new CancelAfterTwoFailures<String>());
---------- END SOURCE ----------