Skip to content
Closed
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
6 changes: 5 additions & 1 deletion core/src/main/java/io/grpc/internal/ServerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@
* server stops servicing new requests and waits for all connections to terminate.
*/
public final class ServerImpl extends io.grpc.Server implements WithLogId {
public static final Attributes.Key<String> ATTR_AUTHORITY = Attributes.Key.of("io.grpc.authority");

private static final ServerStreamListener NOOP_LISTENER = new NoopListener();

private final LogId logId = LogId.allocate(getClass().getName());
Expand Down Expand Up @@ -418,7 +420,9 @@ public void runInContext() {
try {
ServerMethodDefinition<?, ?> method = registry.lookupMethod(methodName);
if (method == null) {
method = fallbackRegistry.lookupMethod(methodName);
String authority = stream.getAttributes()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Attributes.newBuilder(Attributes)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this comment. Can you elaborate?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, that should be in NettyServerHandler.java line 197

.get(ATTR_AUTHORITY);
method = fallbackRegistry.lookupMethod(methodName, authority);
}
if (method == null) {
Status status = Status.UNIMPLEMENTED.withDescription(
Expand Down
8 changes: 7 additions & 1 deletion netty/src/main/java/io/grpc/netty/NettyServerHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import io.grpc.Metadata;
import io.grpc.Status;
import io.grpc.internal.GrpcUtil;
import io.grpc.internal.ServerImpl;
import io.grpc.internal.ServerTransportListener;
import io.grpc.internal.StatsTraceContext;
import io.grpc.netty.GrpcHttp2HeadersDecoder.GrpcHttp2ServerHeadersDecoder;
Expand Down Expand Up @@ -195,8 +196,13 @@ private void onHeadersRead(ChannelHandlerContext ctx, int streamId, Http2Headers
checkNotNull(transportListener.methodDetermined(method, metadata), "statsTraceCtx");
NettyServerStream.TransportState state = new NettyServerStream.TransportState(
this, http2Stream, maxMessageSize, statsTraceCtx);
NettyServerStream stream = new NettyServerStream(ctx.channel(), state, attributes,
Attributes attributesWithAuthority = Attributes
.newBuilder(attributes)
.set(ServerImpl.ATTR_AUTHORITY, headers.authority().toString())
.build();
NettyServerStream stream = new NettyServerStream(ctx.channel(), state, attributesWithAuthority,
statsTraceCtx);

transportListener.streamCreated(stream, method, metadata);
state.onStreamAllocated();
http2Stream.setProperty(streamKey, state);
Expand Down