Fix NPE when stopping with no resesrved threads (#1939)

Signed-off-by: Greg Wilkins <gregw@webtide.com>
This commit is contained in:
Greg Wilkins 2017-11-03 23:58:00 +11:00 committed by GitHub
parent 969c2d8e6a
commit 0ef51b67dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 11 deletions

View File

@ -212,8 +212,9 @@ public class ReservedThreadExecutor extends AbstractLifeCycle implements Executo
return false;
ReservedThread thread = _stack.pop();
if (thread==null && task!=STOP)
if (thread==null)
{
if (task!=STOP)
startReservedThread();
return false;
}

View File

@ -18,29 +18,24 @@
package org.eclipse.jetty.util.thread;
import java.security.SecureRandom;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Random;
import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.StreamSupport;
import org.eclipse.jetty.toolchain.test.annotation.Stress;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
public class ReservedThreadExecutorTest
{
private static final int SIZE = 2;