Skip to content

Commit

Permalink
Fix context filter's bug (#3526)
Browse files Browse the repository at this point in the history
  • Loading branch information
carryxyh authored and ralf0131 committed Feb 21, 2019
1 parent 43e92d3 commit f71a95b
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import org.apache.dubbo.common.utils.StringUtils;
import org.apache.dubbo.rpc.RpcContext;

import org.jboss.resteasy.spi.ResteasyProviderFactory;

import javax.annotation.Priority;
Expand All @@ -29,6 +28,7 @@
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)
Expand Down Expand Up @@ -71,14 +71,14 @@ public void filter(ClientRequestContext requestContext) throws IOException {
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");
Expand Down

0 comments on commit f71a95b

Please sign in to comment.