diff --git a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/AbstractStream.java b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/AbstractStream.java index 8782cd09204..964d0cd2614 100644 --- a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/AbstractStream.java +++ b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/AbstractStream.java @@ -130,6 +130,9 @@ protected Map parseHeadersToMap(Http2Headers headers) { Map attachments = new HashMap<>(); for (Map.Entry header : headers) { String key = header.getKey().toString(); + if(Http2Headers.PseudoHeaderName.isPseudoHeader(key)){ + continue; + } if (ENABLE_ATTACHMENT_WRAP) { if (key.endsWith("-tw-bin") && key.length() > 7) { @@ -156,6 +159,9 @@ protected Map parseHeadersToMap(Http2Headers headers) { protected void convertAttachment(Http2Headers trailers, Map attachments) throws IOException { for (Map.Entry entry : attachments.entrySet()) { final String key = entry.getKey().toLowerCase(Locale.ROOT); + if(Http2Headers.PseudoHeaderName.isPseudoHeader(key)){ + continue; + } final Object v = entry.getValue(); if (!ENABLE_ATTACHMENT_WRAP) { if (v instanceof String) { diff --git a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/ServerStream.java b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/ServerStream.java index bd0bf8cee67..a001364700a 100644 --- a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/ServerStream.java +++ b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/ServerStream.java @@ -27,6 +27,7 @@ import org.apache.dubbo.rpc.Invocation; import org.apache.dubbo.rpc.Invoker; import org.apache.dubbo.rpc.Result; +import org.apache.dubbo.rpc.RpcContext; import org.apache.dubbo.rpc.RpcInvocation; import org.apache.dubbo.rpc.model.ApplicationModel; import org.apache.dubbo.rpc.model.MethodDescriptor; @@ -183,12 +184,12 @@ private void unaryInvoke() { ClassLoadUtil.switchContextLoader(tccl); } - final Http2Headers trailers = new DefaultHttp2Headers() - .setInt(TripleConstant.STATUS_KEY, GrpcStatus.Code.OK.code); + final Http2Headers trailers = new DefaultHttp2Headers(); final Map attachments = response.getObjectAttachments(); if (attachments != null) { convertAttachment(trailers, attachments); } + trailers.setInt(TripleConstant.STATUS_KEY, GrpcStatus.Code.OK.code); ctx.write(new DefaultHttp2HeadersFrame(http2Headers)); final DefaultHttp2DataFrame data = new DefaultHttp2DataFrame(buf); ctx.write(data); @@ -206,6 +207,7 @@ private void unaryInvoke() { }; future.whenComplete(onComplete); + RpcContext.removeContext(); } @@ -277,6 +279,15 @@ private Invocation buildInvocation() { inv.setParameterTypes(methodDescriptor.getParameterClasses()); inv.setReturnTypes(methodDescriptor.getReturnTypes()); final Map attachments = parseHeadersToMap(getHeaders()); + attachments.remove("content-type"); + attachments.remove("interface"); + attachments.remove("tri-service-version"); + attachments.remove("tri-service-group"); + attachments.remove("serialization"); + attachments.remove("te"); + attachments.remove("path"); + attachments.remove("grpc-status"); + attachments.remove("grpc-message"); inv.setObjectAttachments(attachments); return inv; }