Skip to content

Commit f71a95b

Browse files
carryxyhralf0131
authored andcommitted
Fix context filter's bug (#3526)
1 parent 43e92d3 commit f71a95b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

dubbo-rpc/dubbo-rpc-rest/src/main/java/org/apache/dubbo/rpc/protocol/rest/RpcContextFilter.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
import org.apache.dubbo.common.utils.StringUtils;
2020
import org.apache.dubbo.rpc.RpcContext;
21-
2221
import org.jboss.resteasy.spi.ResteasyProviderFactory;
2322

2423
import javax.annotation.Priority;
@@ -29,6 +28,7 @@
2928
import javax.ws.rs.container.ContainerRequestContext;
3029
import javax.ws.rs.container.ContainerRequestFilter;
3130
import java.io.IOException;
31+
import java.nio.charset.StandardCharsets;
3232
import java.util.Map;
3333

3434
@Priority(Integer.MIN_VALUE + 1)
@@ -71,14 +71,14 @@ public void filter(ClientRequestContext requestContext) throws IOException {
7171
int size = 0;
7272
for (Map.Entry<String, String> entry : RpcContext.getContext().getAttachments().entrySet()) {
7373
String key = entry.getKey();
74-
String value = entry.getKey();
74+
String value = entry.getValue();
7575
if (illegalForRest(key) || illegalForRest(value)) {
7676
throw new IllegalArgumentException("The attachments of " + RpcContext.class.getSimpleName() + " must not contain ',' or '=' when using rest protocol");
7777
}
7878

7979
// TODO for now we don't consider the differences of encoding and server limit
8080
if (value != null) {
81-
size += value.getBytes("UTF-8").length;
81+
size += value.getBytes(StandardCharsets.UTF_8).length;
8282
}
8383
if (size > MAX_HEADER_SIZE) {
8484
throw new IllegalArgumentException("The attachments of " + RpcContext.class.getSimpleName() + " is too big");

0 commit comments

Comments
 (0)