Merge remote-tracking branch 'origin/jetty-10.0.x' into jetty-11.0.x

This commit is contained in:
gregw 2023-06-21 11:19:22 +02:00
commit 8c59afd847
2 changed files with 42 additions and 0 deletions

View File

@ -400,6 +400,7 @@ public abstract class IteratingCallback implements Callback
break; break;
case PENDING: case PENDING:
{ {
_state = State.FAILED;
failure = true; failure = true;
break; break;
} }

View File

@ -15,6 +15,7 @@ package org.eclipse.jetty.util;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import org.eclipse.jetty.util.thread.ScheduledExecutorScheduler; import org.eclipse.jetty.util.thread.ScheduledExecutorScheduler;
import org.eclipse.jetty.util.thread.Scheduler; import org.eclipse.jetty.util.thread.Scheduler;
@ -322,4 +323,44 @@ public class IteratingCallbackTest
return isSucceeded(); return isSucceeded();
} }
} }
@Test
public void testMultipleFailures() throws Exception
{
AtomicInteger process = new AtomicInteger();
AtomicInteger failure = new AtomicInteger();
IteratingCallback icb = new IteratingCallback()
{
@Override
protected Action process() throws Throwable
{
process.incrementAndGet();
return Action.SCHEDULED;
}
@Override
protected void onCompleteFailure(Throwable cause)
{
super.onCompleteFailure(cause);
failure.incrementAndGet();
}
};
icb.iterate();
assertEquals(1, process.get());
assertEquals(0, failure.get());
icb.failed(new Throwable("test1"));
assertEquals(1, process.get());
assertEquals(1, failure.get());
icb.succeeded();
assertEquals(1, process.get());
assertEquals(1, failure.get());
icb.failed(new Throwable("test2"));
assertEquals(1, process.get());
assertEquals(1, failure.get());
}
} }