@Test public void transportHandshakeTimeout_expired() throws Exception { class ShutdownRecordingTransport extends SimpleServerTransport { Status shutdownNowStatus; @Override public void shutdownNow(Status status) { shutdownNowStatus = status; super.shutdownNow(status); } } builder.handshakeTimeout(60, TimeUnit.SECONDS); createAndStartServer(); ShutdownRecordingTransport serverTransport = new ShutdownRecordingTransport(); transportServer.registerNewServerTransport(serverTransport); timer.forwardTime(59, TimeUnit.SECONDS); assertNull("shutdownNow status", serverTransport.shutdownNowStatus); timer.forwardTime(2, TimeUnit.SECONDS); assertNotNull("shutdownNow status", serverTransport.shutdownNowStatus); }
@Override public ServerImpl shutdownNow() { shutdown(); Collection<ServerTransport> transportsCopy; Status nowStatus = Status.UNAVAILABLE.withDescription("Server shutdownNow invoked"); boolean savedServerShutdownCallbackInvoked; synchronized (lock) { if (shutdownNowStatus != null) { return this; } shutdownNowStatus = nowStatus; transportsCopy = new ArrayList<>(transports); savedServerShutdownCallbackInvoked = serverShutdownCallbackInvoked; } if (savedServerShutdownCallbackInvoked) { for (ServerTransport transport : transportsCopy) { transport.shutdownNow(nowStatus); } } return this; }
ServerImpl extends io.grpc.Server implements InternalInstrumented<ServerStats> { @Override public ServerImpl shutdownNow() { shutdown(); Collection<ServerTransport> transportsCopy; Status nowStatus = Status.UNAVAILABLE.withDescription("Server shutdownNow invoked"); boolean savedServerShutdownCallbackInvoked; synchronized (lock) { if (shutdownNowStatus != null) { return this; } shutdownNowStatus = nowStatus; transportsCopy = new ArrayList<>(transports); savedServerShutdownCallbackInvoked = serverShutdownCallbackInvoked; } if (savedServerShutdownCallbackInvoked) { for (ServerTransport transport : transportsCopy) { transport.shutdownNow(nowStatus); } } return this; } }
ServerImpl extends io.grpc.Server implements InternalInstrumented<ServerStats> { @Override public ServerImpl shutdownNow() { shutdown(); Collection<ServerTransport> transportsCopy; Status nowStatus = Status.UNAVAILABLE.withDescription("Server shutdownNow invoked"); boolean savedServerShutdownCallbackInvoked; synchronized (lock) { if (shutdownNowStatus != null) { return this; } shutdownNowStatus = nowStatus; transportsCopy = new ArrayList<>(transports); savedServerShutdownCallbackInvoked = serverShutdownCallbackInvoked; } if (savedServerShutdownCallbackInvoked) { for (ServerTransport transport : transportsCopy) { transport.shutdownNow(nowStatus); } } return this; } ServerImpl(
      AbstractServerImplBuilder<?> builder,
      InternalServer transportServer,
      Context rootContext); }
ServerImpl extends io.grpc.Server implements InternalInstrumented<ServerStats> { @Override public ServerImpl shutdownNow() { shutdown(); Collection<ServerTransport> transportsCopy; Status nowStatus = Status.UNAVAILABLE.withDescription("Server shutdownNow invoked"); boolean savedServerShutdownCallbackInvoked; synchronized (lock) { if (shutdownNowStatus != null) { return this; } shutdownNowStatus = nowStatus; transportsCopy = new ArrayList<>(transports); savedServerShutdownCallbackInvoked = serverShutdownCallbackInvoked; } if (savedServerShutdownCallbackInvoked) { for (ServerTransport transport : transportsCopy) { transport.shutdownNow(nowStatus); } } return this; } ServerImpl(
      AbstractServerImplBuilder<?> builder,
      InternalServer transportServer,
      Context rootContext); @Override ServerImpl start(); @Override int getPort(); @Override List<ServerServiceDefinition> getServices(); @Override List<ServerServiceDefinition> getImmutableServices(); @Override List<ServerServiceDefinition> getMutableServices(); @Override ServerImpl shutdown(); @Override ServerImpl shutdownNow(); @Override boolean isShutdown(); @Override boolean awaitTermination(long timeout, TimeUnit unit); @Override void awaitTermination(); @Override boolean isTerminated(); @Override InternalLogId getLogId(); @Override ListenableFuture<ServerStats> getStats(); @Override HandlerRegistry getRegistry(); @Override String toString(); }
ServerImpl extends io.grpc.Server implements InternalInstrumented<ServerStats> { @Override public ServerImpl shutdownNow() { shutdown(); Collection<ServerTransport> transportsCopy; Status nowStatus = Status.UNAVAILABLE.withDescription("Server shutdownNow invoked"); boolean savedServerShutdownCallbackInvoked; synchronized (lock) { if (shutdownNowStatus != null) { return this; } shutdownNowStatus = nowStatus; transportsCopy = new ArrayList<>(transports); savedServerShutdownCallbackInvoked = serverShutdownCallbackInvoked; } if (savedServerShutdownCallbackInvoked) { for (ServerTransport transport : transportsCopy) { transport.shutdownNow(nowStatus); } } return this; } ServerImpl(
      AbstractServerImplBuilder<?> builder,
      InternalServer transportServer,
      Context rootContext); @Override ServerImpl start(); @Override int getPort(); @Override List<ServerServiceDefinition> getServices(); @Override List<ServerServiceDefinition> getImmutableServices(); @Override List<ServerServiceDefinition> getMutableServices(); @Override ServerImpl shutdown(); @Override ServerImpl shutdownNow(); @Override boolean isShutdown(); @Override boolean awaitTermination(long timeout, TimeUnit unit); @Override void awaitTermination(); @Override boolean isTerminated(); @Override InternalLogId getLogId(); @Override ListenableFuture<ServerStats> getStats(); @Override HandlerRegistry getRegistry(); @Override String toString();  }