You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by hu...@apache.org on 2019/02/21 13:36:37 UTC

[incubator-dubbo] branch master updated: Fix context filter's bug (#3526)

This is an automated email from the ASF dual-hosted git repository.

huxing pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-dubbo.git


The following commit(s) were added to refs/heads/master by this push:
     new f71a95b  Fix context filter's bug (#3526)
f71a95b is described below

commit f71a95bc66ce35aaedb4f3403363327230582481
Author: 时无两丶 <44...@qq.com>
AuthorDate: Thu Feb 21 21:36:09 2019 +0800

    Fix context filter's bug (#3526)
---
 .../java/org/apache/dubbo/rpc/protocol/rest/RpcContextFilter.java   | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/dubbo-rpc/dubbo-rpc-rest/src/main/java/org/apache/dubbo/rpc/protocol/rest/RpcContextFilter.java b/dubbo-rpc/dubbo-rpc-rest/src/main/java/org/apache/dubbo/rpc/protocol/rest/RpcContextFilter.java
index b99bf1d..735c21b 100644
--- a/dubbo-rpc/dubbo-rpc-rest/src/main/java/org/apache/dubbo/rpc/protocol/rest/RpcContextFilter.java
+++ b/dubbo-rpc/dubbo-rpc-rest/src/main/java/org/apache/dubbo/rpc/protocol/rest/RpcContextFilter.java
@@ -18,7 +18,6 @@ package org.apache.dubbo.rpc.protocol.rest;
 
 import org.apache.dubbo.common.utils.StringUtils;
 import org.apache.dubbo.rpc.RpcContext;
-
 import org.jboss.resteasy.spi.ResteasyProviderFactory;
 
 import javax.annotation.Priority;
@@ -29,6 +28,7 @@ import javax.ws.rs.client.ClientRequestFilter;
 import javax.ws.rs.container.ContainerRequestContext;
 import javax.ws.rs.container.ContainerRequestFilter;
 import java.io.IOException;
+import java.nio.charset.StandardCharsets;
 import java.util.Map;
 
 @Priority(Integer.MIN_VALUE + 1)
@@ -71,14 +71,14 @@ public class RpcContextFilter implements ContainerRequestFilter, ClientRequestFi
         int size = 0;
         for (Map.Entry<String, String> entry : RpcContext.getContext().getAttachments().entrySet()) {
             String key = entry.getKey();
-            String value = entry.getKey();
+            String value = entry.getValue();
             if (illegalForRest(key) || illegalForRest(value)) {
                 throw new IllegalArgumentException("The attachments of " + RpcContext.class.getSimpleName() + " must not contain ',' or '=' when using rest protocol");
             }
 
             // TODO for now we don't consider the differences of encoding and server limit
             if (value != null) {
-                size += value.getBytes("UTF-8").length;
+                size += value.getBytes(StandardCharsets.UTF_8).length;
             }
             if (size > MAX_HEADER_SIZE) {
                 throw new IllegalArgumentException("The attachments of " + RpcContext.class.getSimpleName() + " is too big");