Skip to content

Commit 6a87dc5

Browse files
carryxyhchickenlj
authored andcommitted
Merge pull request #3017, fixes #2981, refresh invocation's attachments in each invoke.
Fixes #2981.
1 parent 4fbdc4f commit 6a87dc5

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/AbstractClusterInvoker.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -109,18 +109,18 @@ public void destroy() {
109109
* @param invokers invoker candidates
110110
* @param selected exclude selected invokers or not
111111
* @return the invoker which will final to do invoke.
112-
* @throws RpcException
112+
* @throws RpcException exception
113113
*/
114114
protected Invoker<T> select(LoadBalance loadbalance, Invocation invocation,
115-
List<Invoker<T>> invokers, List<Invoker<T>> selected) throws RpcException {
115+
List<Invoker<T>> invokers, List<Invoker<T>> selected) throws RpcException {
116116

117117
if (CollectionUtils.isEmpty(invokers)) {
118118
return null;
119119
}
120120
String methodName = invocation == null ? StringUtils.EMPTY : invocation.getMethodName();
121121

122122
boolean sticky = invokers.get(0).getUrl()
123-
.getMethodParameter(methodName, Constants.CLUSTER_STICKY_KEY, Constants.DEFAULT_CLUSTER_STICKY);
123+
.getMethodParameter(methodName, Constants.CLUSTER_STICKY_KEY, Constants.DEFAULT_CLUSTER_STICKY);
124124

125125
//ignore overloaded method
126126
if (stickyInvoker != null && !invokers.contains(stickyInvoker)) {
@@ -142,7 +142,7 @@ protected Invoker<T> select(LoadBalance loadbalance, Invocation invocation,
142142
}
143143

144144
private Invoker<T> doSelect(LoadBalance loadbalance, Invocation invocation,
145-
List<Invoker<T>> invokers, List<Invoker<T>> selected) throws RpcException {
145+
List<Invoker<T>> invokers, List<Invoker<T>> selected) throws RpcException {
146146

147147
if (CollectionUtils.isEmpty(invokers)) {
148148
return null;
@@ -180,19 +180,20 @@ private Invoker<T> doSelect(LoadBalance loadbalance, Invocation invocation,
180180
* Reselect, use invokers not in `selected` first, if all invokers are in `selected`,
181181
* just pick an available one using loadbalance policy.
182182
*
183-
* @param loadbalance
184-
* @param invocation
185-
* @param invokers
186-
* @param selected
187-
* @return
188-
* @throws RpcException
183+
* @param loadbalance load balance policy
184+
* @param invocation invocation
185+
* @param invokers invoker candidates
186+
* @param selected exclude selected invokers or not
187+
* @param availablecheck check invoker available if true
188+
* @return the reselect result to do invoke
189+
* @throws RpcException exception
189190
*/
190191
private Invoker<T> reselect(LoadBalance loadbalance, Invocation invocation,
191-
List<Invoker<T>> invokers, List<Invoker<T>> selected, boolean availablecheck) throws RpcException {
192+
List<Invoker<T>> invokers, List<Invoker<T>> selected, boolean availablecheck) throws RpcException {
192193

193194
//Allocating one in advance, this list is certain to be used.
194195
List<Invoker<T>> reselectInvokers = new ArrayList<>(
195-
invokers.size() > 1 ? (invokers.size() - 1) : invokers.size());
196+
invokers.size() > 1 ? (invokers.size() - 1) : invokers.size());
196197

197198
// First, try picking a invoker not in `selected`.
198199
for (Invoker<T> invoker : invokers) {
@@ -242,7 +243,6 @@ public Result invoke(final Invocation invocation) throws RpcException {
242243
}
243244

244245
protected void checkWhetherDestroyed() {
245-
246246
if (destroyed.get()) {
247247
throw new RpcException("Rpc cluster invoker for " + getInterface() + " on consumer " + NetUtils.getLocalHost()
248248
+ " use dubbo version " + Version.getVersion()

dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/ContextFilter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ public class ContextFilter implements Filter {
4242
public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
4343
Map<String, String> attachments = invocation.getAttachments();
4444
if (attachments != null) {
45-
attachments = new HashMap<String, String>(attachments);
45+
attachments = new HashMap<>(attachments);
4646
attachments.remove(Constants.PATH_KEY);
47+
attachments.remove(Constants.INTERFACE_KEY);
4748
attachments.remove(Constants.GROUP_KEY);
4849
attachments.remove(Constants.VERSION_KEY);
4950
attachments.remove(Constants.DUBBO_VERSION_KEY);

dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/protocol/AbstractInvoker.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ public Result invoke(Invocation inv) throws RpcException {
152152
}
153153
RpcUtils.attachInvocationIdIfAsync(getUrl(), invocation);
154154

155-
156155
try {
157156
return doInvoke(invocation);
158157
} catch (InvocationTargetException e) { // biz exception

0 commit comments

Comments
 (0)