mirror of https://github.com/grpc/grpc-java.git
parent
89bc2cd3b2
commit
aa0391a427
|
|
@ -91,6 +91,10 @@ public final class ProtocolNegotiators {
|
|||
class PlaintextHandler extends ChannelHandlerAdapter implements Handler {
|
||||
@Override
|
||||
public void handlerAdded(ChannelHandlerContext ctx) throws Exception {
|
||||
// Set sttributes before replace to be sure we pass it before accepting any requests.
|
||||
handler.handleProtocolNegotiationCompleted(Attributes.newBuilder()
|
||||
.set(Grpc.TRANSPORT_ATTR_REMOTE_ADDR, ctx.channel().remoteAddress())
|
||||
.build());
|
||||
// Just replace this handler with the gRPC handler.
|
||||
ctx.pipeline().replace(this, null, handler);
|
||||
}
|
||||
|
|
@ -155,6 +159,7 @@ public final class ProtocolNegotiators {
|
|||
Attributes.newBuilder()
|
||||
.set(Grpc.TRANSPORT_ATTR_SSL_SESSION,
|
||||
sslHandler(ctx.pipeline()).engine().getSession())
|
||||
.set(Grpc.TRANSPORT_ATTR_REMOTE_ADDR, ctx.channel().remoteAddress())
|
||||
.build());
|
||||
// Replace this handler with the GRPC handler.
|
||||
ctx.pipeline().replace(this, null, grpcHandler);
|
||||
|
|
@ -509,6 +514,7 @@ public final class ProtocolNegotiators {
|
|||
grpcHandler.handleProtocolNegotiationCompleted(
|
||||
Attributes.newBuilder()
|
||||
.set(Grpc.TRANSPORT_ATTR_SSL_SESSION, handler.engine().getSession())
|
||||
.set(Grpc.TRANSPORT_ATTR_REMOTE_ADDR, ctx.channel().remoteAddress())
|
||||
.build());
|
||||
writeBufferedAndRemove(ctx);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -335,7 +335,7 @@ public class NettyClientTransportTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void clientStreamGetsSslSessionAttributes() throws Exception {
|
||||
public void clientStreamGetsAttributes() throws Exception {
|
||||
startServer();
|
||||
NettyClientTransport transport = newTransport(newNegotiator());
|
||||
transport.start(clientTransportListener);
|
||||
|
|
@ -343,6 +343,7 @@ public class NettyClientTransportTest {
|
|||
rpc.waitForResponse();
|
||||
|
||||
assertNotNull(rpc.stream.getAttributes().get(Grpc.TRANSPORT_ATTR_SSL_SESSION));
|
||||
assertEquals(address, rpc.stream.getAttributes().get(Grpc.TRANSPORT_ATTR_REMOTE_ADDR));
|
||||
}
|
||||
|
||||
private Throwable getRootCause(Throwable t) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue