You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by al...@apache.org on 2021/09/28 03:07:44 UTC
[dubbo] branch 3.0 updated: Revert LinkedHashMap in Invocation to
HashMap (#8941)
This is an automated email from the ASF dual-hosted git repository.
albumenj pushed a commit to branch 3.0
in repository https://gitbox.apache.org/repos/asf/dubbo.git
The following commit(s) were added to refs/heads/3.0 by this push:
new 7051c43 Revert LinkedHashMap in Invocation to HashMap (#8941)
7051c43 is described below
commit 7051c43ea63677dd67aa0a78d2806d5af06dba70
Author: Albumen Kevin <jh...@gmail.com>
AuthorDate: Tue Sep 28 11:07:34 2021 +0800
Revert LinkedHashMap in Invocation to HashMap (#8941)
* Revert LinkedHashMap in Invocation to HashMap
* fix import
---
.../java/org/apache/dubbo/rpc/RpcInvocation.java | 22 +++++++++++-----------
.../org/apache/dubbo/rpc/filter/ContextFilter.java | 2 +-
.../protocol/dubbo/DecodeableRpcInvocation.java | 4 ++--
.../dubbo/rpc/protocol/tri/AbstractStream.java | 4 ++--
4 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/RpcInvocation.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/RpcInvocation.java
index 05cfa00..56ccb61 100644
--- a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/RpcInvocation.java
+++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/RpcInvocation.java
@@ -30,7 +30,7 @@ import java.io.Serializable;
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;
@@ -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;
@@ -101,7 +101,7 @@ public class RpcInvocation implements Invocation, Serializable {
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();
@@ -185,8 +185,8 @@ public class RpcInvocation implements Invocation, Serializable {
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();
}
@@ -325,7 +325,7 @@ public class RpcInvocation implements Invocation, Serializable {
}
public void setObjectAttachments(Map<String, Object> attachments) {
- this.attachments = attachments == null ? new LinkedHashMap<>() : attachments;
+ this.attachments = attachments == null ? new HashMap<>() : attachments;
}
@Override
@@ -341,7 +341,7 @@ public class RpcInvocation implements Invocation, Serializable {
@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
@@ -352,7 +352,7 @@ public class RpcInvocation implements Invocation, Serializable {
@Override
public void setObjectAttachment(String key, Object value) {
if (attachments == null) {
- attachments = new LinkedHashMap<>();
+ attachments = new HashMap<>();
}
attachments.put(key, value);
}
@@ -370,7 +370,7 @@ public class RpcInvocation implements Invocation, Serializable {
@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);
@@ -383,7 +383,7 @@ public class RpcInvocation implements Invocation, Serializable {
return;
}
if (this.attachments == null) {
- this.attachments = new LinkedHashMap<>();
+ this.attachments = new HashMap<>();
}
this.attachments.putAll(attachments);
}
@@ -393,7 +393,7 @@ public class RpcInvocation implements Invocation, Serializable {
return;
}
if (this.attachments == null) {
- this.attachments = new LinkedHashMap<>();
+ this.attachments = new HashMap<>();
}
this.attachments.putAll(attachments);
}
diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/ContextFilter.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/ContextFilter.java
index fd39c22..c813384 100644
--- a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/ContextFilter.java
+++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/ContextFilter.java
@@ -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);
diff --git a/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/DecodeableRpcInvocation.java b/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/DecodeableRpcInvocation.java
index 0ed252f..3f7c90a 100644
--- a/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/DecodeableRpcInvocation.java
+++ b/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/DecodeableRpcInvocation.java
@@ -43,7 +43,7 @@ import org.apache.dubbo.rpc.support.RpcUtils;
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;
@@ -225,7 +225,7 @@ public class DecodeableRpcInvocation extends RpcInvocation implements Codec, Dec
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);
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 cbd5413..ebb48e9 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
@@ -37,7 +37,7 @@ import io.netty.handler.codec.http2.Http2Error;
import io.netty.handler.codec.http2.Http2Headers;
import java.util.ArrayList;
-import java.util.LinkedHashMap;
+import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@@ -291,7 +291,7 @@ public abstract class AbstractStream implements Stream {
}
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)) {