Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert LinkedHashMap in Invocation to HashMap #8941

Merged
merged 2 commits into from
Sep 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;
Expand Down Expand Up @@ -76,7 +76,7 @@ public class RpcInvocation implements Invocation, Serializable {
/**
* Only used on the caller side, will not appear on the wire.
*/
private transient Map<Object, Object> attributes = new LinkedHashMap<Object, Object>();
private transient Map<Object, Object> attributes = new HashMap<Object, Object>();

private transient Invoker<?> invoker;

Expand All @@ -91,7 +91,7 @@ public RpcInvocation() {

public RpcInvocation(Invocation invocation, Invoker<?> invoker) {
this(invocation.getServiceModel(), invocation.getMethodName(), invocation.getServiceName(), invocation.getProtocolServiceKey(),
invocation.getParameterTypes(), invocation.getArguments(), new LinkedHashMap<>(invocation.getObjectAttachments()),
invocation.getParameterTypes(), invocation.getArguments(), new HashMap<>(invocation.getObjectAttachments()),
invocation.getInvoker(), invocation.getAttributes());
if (invoker != null) {
URL url = invoker.getUrl();
Expand Down Expand Up @@ -175,8 +175,8 @@ public RpcInvocation(ServiceModel serviceModel, String methodName, String servic
this.protocolServiceKey = protocolServiceKey;
this.parameterTypes = parameterTypes == null ? new Class<?>[0] : parameterTypes;
this.arguments = arguments == null ? new Object[0] : arguments;
this.attachments = attachments == null ? new LinkedHashMap<>() : attachments;
this.attributes = attributes == null ? new LinkedHashMap<>() : attributes;
this.attachments = attachments == null ? new HashMap<>() : attachments;
this.attributes = attributes == null ? new HashMap<>() : attributes;
this.invoker = invoker;
initParameterDesc();
}
Expand Down Expand Up @@ -315,7 +315,7 @@ public Map<String, Object> getObjectAttachments() {
}

public void setObjectAttachments(Map<String, Object> attachments) {
this.attachments = attachments == null ? new LinkedHashMap<>() : attachments;
this.attachments = attachments == null ? new HashMap<>() : attachments;
}

@Override
Expand All @@ -331,7 +331,7 @@ public Map<String, String> getAttachments() {

@Deprecated
public void setAttachments(Map<String, String> attachments) {
this.attachments = attachments == null ? new LinkedHashMap<>() : new LinkedHashMap<>(attachments);
this.attachments = attachments == null ? new HashMap<>() : new HashMap<>(attachments);
}

@Override
Expand All @@ -342,7 +342,7 @@ public void setAttachment(String key, Object value) {
@Override
public void setObjectAttachment(String key, Object value) {
if (attachments == null) {
attachments = new LinkedHashMap<>();
attachments = new HashMap<>();
}
attachments.put(key, value);
}
Expand All @@ -360,7 +360,7 @@ public void setAttachmentIfAbsent(String key, Object value) {
@Override
public void setObjectAttachmentIfAbsent(String key, Object value) {
if (attachments == null) {
attachments = new LinkedHashMap<>();
attachments = new HashMap<>();
}
if (!attachments.containsKey(key)) {
attachments.put(key, value);
Expand All @@ -373,7 +373,7 @@ public void addAttachments(Map<String, String> attachments) {
return;
}
if (this.attachments == null) {
this.attachments = new LinkedHashMap<>();
this.attachments = new HashMap<>();
}
this.attachments.putAll(attachments);
}
Expand All @@ -383,7 +383,7 @@ public void addObjectAttachments(Map<String, Object> attachments) {
return;
}
if (this.attachments == null) {
this.attachments = new LinkedHashMap<>();
this.attachments = new HashMap<>();
}
this.attachments.putAll(attachments);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public class ContextFilter implements Filter, Filter.Listener {
private static final Set<String> UNLOADING_KEYS;

static {
UNLOADING_KEYS = new HashSet<>(128);
UNLOADING_KEYS = new HashSet<>(16);
UNLOADING_KEYS.add(PATH_KEY);
UNLOADING_KEYS.add(INTERFACE_KEY);
UNLOADING_KEYS.add(GROUP_KEY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.LinkedHashMap;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -225,7 +225,7 @@ public Object decode(Channel channel, InputStream input) throws IOException {
if (map != null && map.size() > 0) {
Map<String, Object> attachment = getObjectAttachments();
if (attachment == null) {
attachment = new LinkedHashMap<>();
attachment = new HashMap<>();
}
attachment.putAll(map);
setObjectAttachments(attachment);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import org.apache.dubbo.rpc.protocol.tri.GrpcStatus.Code;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
Expand Down Expand Up @@ -252,7 +252,7 @@ private Metadata getTrailers(GrpcStatus grpcStatus) {
}

protected Map<String, Object> parseMetadataToAttachmentMap(Metadata metadata) {
Map<String, Object> attachments = new LinkedHashMap<>();
Map<String, Object> attachments = new HashMap<>();
for (Map.Entry<CharSequence, CharSequence> header : metadata) {
String key = header.getKey().toString();
if (Http2Headers.PseudoHeaderName.isPseudoHeader(key)) {
Expand Down