Don't let server start if already shutting down

This commit is contained in:
Carl Mastrangelo 2015-09-14 11:39:28 -07:00
parent 45c75f2c96
commit 4b27e542e0
1 changed files with 3 additions and 3 deletions

View File

@ -31,6 +31,7 @@
package io.grpc.internal; package io.grpc.internal;
import static com.google.common.base.Preconditions.checkState;
import static io.grpc.internal.GrpcUtil.TIMEOUT_KEY; import static io.grpc.internal.GrpcUtil.TIMEOUT_KEY;
import static io.grpc.internal.GrpcUtil.TIMER_SERVICE; import static io.grpc.internal.GrpcUtil.TIMER_SERVICE;
@ -114,9 +115,8 @@ public final class ServerImpl extends io.grpc.Server {
@Override @Override
public ServerImpl start() throws IOException { public ServerImpl start() throws IOException {
synchronized (lock) { synchronized (lock) {
if (started) { checkState(!started, "Already started");
throw new IllegalStateException("Already started"); checkState(!shutdown, "Shutting down");
}
usingSharedExecutor = executor == null; usingSharedExecutor = executor == null;
if (usingSharedExecutor) { if (usingSharedExecutor) {
executor = SharedResourceHolder.get(GrpcUtil.SHARED_CHANNEL_EXECUTOR); executor = SharedResourceHolder.get(GrpcUtil.SHARED_CHANNEL_EXECUTOR);