Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions core/src/main/java/io/grpc/internal/ServerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.MoreObjects;
import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.SettableFuture;
import io.grpc.Attributes;
Expand All @@ -53,7 +54,6 @@
import io.grpc.ServerServiceDefinition;
import io.grpc.ServerTransportFilter;
import io.grpc.Status;
import io.grpc.StatusException;
import io.perfmark.Link;
import io.perfmark.PerfMark;
import io.perfmark.Tag;
Expand Down Expand Up @@ -606,17 +606,11 @@ public void runInContext() {

private void runInternal() {
ServerStreamListener listener = NOOP_LISTENER;
ServerCallParameters<?,?> callParameters;
try {
if (future.isCancelled()) {
return;
}
if (!future.isDone() || (callParameters = future.get()) == null) {
Status status = Status.INTERNAL.withDescription(
"Unexpected failure retrieving server call parameters.");
throw new StatusException(status);
}
listener = startWrappedCall(methodName, callParameters, headers);
listener = startWrappedCall(methodName, Futures.getDone(future), headers);
} catch (Throwable ex) {
stream.close(Status.fromThrowable(ex), new Metadata());
context.cancel(null);
Expand Down
5 changes: 4 additions & 1 deletion core/src/test/java/io/grpc/internal/ServerImplTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
import io.grpc.ServerTransportFilter;
import io.grpc.ServiceDescriptor;
import io.grpc.Status;
import io.grpc.Status.Code;
import io.grpc.StringMarshaller;
import io.grpc.internal.ServerImpl.JumpToApplicationThreadServerStreamListener;
import io.grpc.internal.ServerImplBuilder.ClientTransportServersBuilder;
Expand Down Expand Up @@ -533,6 +534,7 @@ public ServerCall.Listener<String> startCall(
}

@Test
@SuppressWarnings("CheckReturnValue")
public void executorSupplierFutureNotSet() throws Exception {
builder.executorSupplier = new ServerCallExecutorSupplier() {
@Override
Expand Down Expand Up @@ -575,7 +577,8 @@ public ServerCall.Listener<String> startCall(
assertThat(callReference.get()).isNull();
verify(stream, times(2)).close(statusCaptor.capture(), any(Metadata.class));
Status status = statusCaptor.getAllValues().get(1);
assertEquals(Status.Code.INTERNAL, status.getCode());
assertEquals(Code.UNKNOWN, status.getCode());
assertThat(status.getCause() instanceof IllegalStateException);
}

@Test
Expand Down