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 e95e19e  Fix TimeoutCountDown#elapsedMillis method and add some unit 
tests (#9109)
e95e19e is described below

commit e95e19efbf434bf6aac426c4013243579f82770d
Author: 灼华 <[email protected]>
AuthorDate: Mon Oct 25 12:54:28 2021 +0800

    Fix TimeoutCountDown#elapsedMillis method and add some unit tests (#9109)
    
    * Add unit test for RpcStatusTest and fix TimeoutCountDown#elapsedMillis 
method
    
    * Add unit test for PenetrateAttachmentSelector
    
    * FIX UT
    
    * FIX UT
---
 .../main/java/org/apache/dubbo/rpc/RpcContext.java |   2 +-
 .../org/apache/dubbo/rpc/RpcContextAttachment.java |   4 +-
 .../java/org/apache/dubbo/rpc/RpcException.java    |   2 +-
 .../org/apache/dubbo/rpc/RpcServiceContext.java    |   4 +-
 .../org/apache/dubbo/rpc/TimeoutCountDown.java     | 108 ++++++++---------
 .../org/apache/dubbo/rpc/support/MockInvoker.java  |  10 +-
 .../dubbo/rpc/PenetrateAttachmentSelectorTest.java |  47 ++++++++
 .../java/org/apache/dubbo/rpc/RpcStatusTest.java   | 133 +++++++++++++++++++++
 .../org/apache/dubbo/rpc/TimeoutCountDownTest.java |   2 +
 .../PenetrateAttachmentSelectorMock.java}          |  27 ++---
 ...rg.apache.dubbo.rpc.PenetrateAttachmentSelector |   1 +
 11 files changed, 254 insertions(+), 86 deletions(-)

diff --git 
a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/RpcContext.java 
b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/RpcContext.java
index e39f421..13f108b 100644
--- a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/RpcContext.java
+++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/RpcContext.java
@@ -550,7 +550,7 @@ public class RpcContext {
      * @return context
      */
     public RpcContext setAttachment(String key, String value) {
-        return setObjectAttachment(key, (Object) value);
+        return setObjectAttachment(key, value);
     }
 
     public RpcContext setAttachment(String key, Object value) {
diff --git 
a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/RpcContextAttachment.java
 
b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/RpcContextAttachment.java
index 032493e..efcde29 100644
--- 
a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/RpcContextAttachment.java
+++ 
b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/RpcContextAttachment.java
@@ -17,13 +17,13 @@
 package org.apache.dubbo.rpc;
 
 import org.apache.dubbo.common.Experimental;
+import org.apache.dubbo.common.utils.CollectionUtils;
 
 import java.util.HashMap;
 import java.util.Map;
 
 public class RpcContextAttachment extends RpcContext{
     protected final Map<String, Object> attachments = new HashMap<>();
-    private final Map<String, Object> values = new HashMap<String, Object>();
 
     protected RpcContextAttachment() {
     }
@@ -142,7 +142,7 @@ public class RpcContextAttachment extends RpcContext{
     @Experimental("Experiment api for supporting Object transmission")
     public RpcContextAttachment setObjectAttachments(Map<String, Object> 
attachment) {
         this.attachments.clear();
-        if (attachment != null && attachment.size() > 0) {
+        if (CollectionUtils.isNotEmptyMap(attachment)) {
             this.attachments.putAll(attachment);
         }
         return this;
diff --git 
a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/RpcException.java 
b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/RpcException.java
index dd43be3..11bfe82 100644
--- 
a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/RpcException.java
+++ 
b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/RpcException.java
@@ -95,7 +95,7 @@ class RpcException extends RuntimeException {
         return code == BIZ_EXCEPTION;
     }
 
-    public boolean isForbidded() {
+    public boolean isForbidden() {
         return code == FORBIDDEN_EXCEPTION;
     }
 
diff --git 
a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/RpcServiceContext.java
 
b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/RpcServiceContext.java
index 8c2657c..ebec31f 100644
--- 
a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/RpcServiceContext.java
+++ 
b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/RpcServiceContext.java
@@ -70,8 +70,6 @@ public class RpcServiceContext extends RpcContext {
     private Object response;
     private AsyncContext asyncContext;
 
-    private boolean remove = true;
-
     /**
      * Get the request object of the underlying RPC protocol, e.g. 
HttpServletRequest
      *
@@ -180,7 +178,7 @@ public class RpcServiceContext extends RpcContext {
 
     @Override
     public List<URL> getUrls() {
-        return urls == null && url != null ? (List<URL>) Arrays.asList(url) : 
urls;
+        return urls == null && url != null ? Arrays.asList(url) : urls;
     }
 
     @Override
diff --git 
a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/TimeoutCountDown.java
 
b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/TimeoutCountDown.java
index 91b561d..0e4910f 100644
--- 
a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/TimeoutCountDown.java
+++ 
b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/TimeoutCountDown.java
@@ -20,71 +20,71 @@ import java.util.concurrent.TimeUnit;
 
 public final class TimeoutCountDown implements Comparable<TimeoutCountDown> {
 
-  public static TimeoutCountDown newCountDown(long timeout, TimeUnit unit) {
-    return new TimeoutCountDown(timeout, unit);
-  }
+    public static TimeoutCountDown newCountDown(long timeout, TimeUnit unit) {
+        return new TimeoutCountDown(timeout, unit);
+    }
 
-  private final long timeoutInMillis;
-  private final long deadlineInNanos;
-  private volatile boolean expired;
+    private final long timeoutInMillis;
+    private final long deadlineInNanos;
+    private volatile boolean expired;
 
-  private TimeoutCountDown(long timeout, TimeUnit unit) {
-    timeoutInMillis = TimeUnit.MILLISECONDS.convert(timeout, unit);
-    deadlineInNanos = System.nanoTime() + 
TimeUnit.NANOSECONDS.convert(timeout, unit);
-  }
+    private TimeoutCountDown(long timeout, TimeUnit unit) {
+        timeoutInMillis = TimeUnit.MILLISECONDS.convert(timeout, unit);
+        deadlineInNanos = System.nanoTime() + 
TimeUnit.NANOSECONDS.convert(timeout, unit);
+    }
 
-  public long getTimeoutInMilli() {
-    return timeoutInMillis;
-  }
+    public long getTimeoutInMilli() {
+        return timeoutInMillis;
+    }
 
-  public boolean isExpired() {
-    if (!expired) {
-      if (deadlineInNanos - System.nanoTime() <= 0) {
-        expired = true;
-      } else {
-        return false;
-      }
+    public boolean isExpired() {
+        if (!expired) {
+            if (deadlineInNanos - System.nanoTime() <= 0) {
+                expired = true;
+            } else {
+                return false;
+            }
+        }
+        return true;
     }
-    return true;
-  }
 
-  public long timeRemaining(TimeUnit unit) {
-    final long currentNanos = System.nanoTime();
-    if (!expired && deadlineInNanos - currentNanos <= 0) {
-      expired = true;
+    public long timeRemaining(TimeUnit unit) {
+        final long currentNanos = System.nanoTime();
+        if (!expired && deadlineInNanos - currentNanos <= 0) {
+            expired = true;
+        }
+        return unit.convert(deadlineInNanos - currentNanos, 
TimeUnit.NANOSECONDS);
     }
-    return unit.convert(deadlineInNanos - currentNanos, TimeUnit.NANOSECONDS);
-  }
 
-  public long elapsedMillis() {
-    if (isExpired()) {
-      return timeoutInMillis + TimeUnit.MILLISECONDS.convert(System.nanoTime() 
- deadlineInNanos, TimeUnit.NANOSECONDS);
-    } else {
-      return TimeUnit.MILLISECONDS.convert(deadlineInNanos - 
System.nanoTime(), TimeUnit.NANOSECONDS);
+    public long elapsedMillis() {
+        if (isExpired()) {
+            return timeoutInMillis + 
TimeUnit.MILLISECONDS.convert(System.nanoTime() - deadlineInNanos, 
TimeUnit.NANOSECONDS);
+        } else {
+            return timeoutInMillis - 
TimeUnit.MILLISECONDS.convert(deadlineInNanos - System.nanoTime(), 
TimeUnit.NANOSECONDS);
+        }
     }
-  }
 
-  @Override
-  public String toString() {
-    long timeoutMillis = TimeUnit.MILLISECONDS.convert(deadlineInNanos, 
TimeUnit.NANOSECONDS);
-    long remainingMillis = timeRemaining(TimeUnit.MILLISECONDS);
+    @Override
+    public String toString() {
+        long timeoutMillis = TimeUnit.MILLISECONDS.convert(deadlineInNanos, 
TimeUnit.NANOSECONDS);
+        long remainingMillis = timeRemaining(TimeUnit.MILLISECONDS);
 
-    StringBuilder buf = new StringBuilder();
-    buf.append("Total timeout value - ");
-    buf.append(timeoutMillis);
-    buf.append(", times remaining - ");
-    buf.append(remainingMillis);
-    return buf.toString();
-  }
+        StringBuilder buf = new StringBuilder();
+        buf.append("Total timeout value - ");
+        buf.append(timeoutMillis);
+        buf.append(", times remaining - ");
+        buf.append(remainingMillis);
+        return buf.toString();
+    }
 
-  @Override
-  public int compareTo(TimeoutCountDown another) {
-    long delta = this.deadlineInNanos - another.deadlineInNanos;
-    if (delta < 0) {
-      return -1;
-    } else if (delta > 0) {
-      return 1;
+    @Override
+    public int compareTo(TimeoutCountDown another) {
+        long delta = this.deadlineInNanos - another.deadlineInNanos;
+        if (delta < 0) {
+            return -1;
+        } else if (delta > 0) {
+            return 1;
+        }
+        return 0;
     }
-    return 0;
-  }
 }
diff --git 
a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/support/MockInvoker.java
 
b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/support/MockInvoker.java
index cb824ac..74ee049 100644
--- 
a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/support/MockInvoker.java
+++ 
b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/support/MockInvoker.java
@@ -65,7 +65,7 @@ final public class MockInvoker<T> implements Invoker<T> {
     }
 
     public static Object parseMockValue(String mock, Type[] returnTypes) 
throws Exception {
-        Object value = null;
+        Object value;
         if ("empty".equals(mock)) {
             value = ReflectUtils.getEmptyObject(returnTypes != null && 
returnTypes.length > 0 ? (Class<?>) returnTypes[0] : null);
         } else if ("null".equals(mock)) {
@@ -99,13 +99,7 @@ final public class MockInvoker<T> implements Invoker<T> {
         if (invocation instanceof RpcInvocation) {
             ((RpcInvocation) invocation).setInvoker(this);
         }
-        String mock = null;
-        if (getUrl().hasMethodParameter(invocation.getMethodName())) {
-            mock = getUrl().getParameter(invocation.getMethodName() + "." + 
MOCK_KEY);
-        }
-        if (StringUtils.isBlank(mock)) {
-            mock = getUrl().getParameter(MOCK_KEY);
-        }
+        String mock = getUrl().getMethodParameter(invocation.getMethodName(), 
MOCK_KEY);
 
         if (StringUtils.isBlank(mock)) {
             throw new RpcException(new IllegalAccessException("mock can not be 
null. url :" + url));
diff --git 
a/dubbo-rpc/dubbo-rpc-api/src/test/java/org/apache/dubbo/rpc/PenetrateAttachmentSelectorTest.java
 
b/dubbo-rpc/dubbo-rpc-api/src/test/java/org/apache/dubbo/rpc/PenetrateAttachmentSelectorTest.java
new file mode 100644
index 0000000..2be163f
--- /dev/null
+++ 
b/dubbo-rpc/dubbo-rpc-api/src/test/java/org/apache/dubbo/rpc/PenetrateAttachmentSelectorTest.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dubbo.rpc;
+
+import org.apache.dubbo.common.extension.ExtensionLoader;
+import org.apache.dubbo.common.utils.CollectionUtils;
+import org.apache.dubbo.rpc.model.ApplicationModel;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * {@link PenetrateAttachmentSelector}
+ */
+public class PenetrateAttachmentSelectorTest {
+
+    @Test
+    public void test() {
+        ExtensionLoader<PenetrateAttachmentSelector> selectorExtensionLoader = 
ApplicationModel.defaultModel().getExtensionLoader(PenetrateAttachmentSelector.class);
+        Set<String> supportedSelectors = 
selectorExtensionLoader.getSupportedExtensions();
+        Map<String, Object> allSelected = new HashMap<>();
+        if (CollectionUtils.isNotEmpty(supportedSelectors)) {
+            for (String supportedSelector : supportedSelectors) {
+                Map<String, Object> selected = 
selectorExtensionLoader.getExtension(supportedSelector).select();
+                allSelected.putAll(selected);
+            }
+        }
+        Assertions.assertEquals(allSelected.get("testKey"), "testVal");
+    }
+}
diff --git 
a/dubbo-rpc/dubbo-rpc-api/src/test/java/org/apache/dubbo/rpc/RpcStatusTest.java 
b/dubbo-rpc/dubbo-rpc-api/src/test/java/org/apache/dubbo/rpc/RpcStatusTest.java
new file mode 100644
index 0000000..f69a4de
--- /dev/null
+++ 
b/dubbo-rpc/dubbo-rpc-api/src/test/java/org/apache/dubbo/rpc/RpcStatusTest.java
@@ -0,0 +1,133 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dubbo.rpc;
+
+import org.apache.dubbo.common.URL;
+import org.apache.dubbo.common.url.component.ServiceConfigURL;
+import org.apache.dubbo.rpc.support.DemoService;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * {@link RpcStatus}
+ */
+public class RpcStatusTest {
+
+    @Test
+    public void testBeginCountEndCount() {
+        URL url = new ServiceConfigURL("dubbo", "127.0.0.1", 91031, 
DemoService.class.getName());
+        String methodName = "testBeginCountEndCount";
+        int max = 2;
+        boolean flag = RpcStatus.beginCount(url, methodName, max);
+        RpcStatus urlRpcStatus = RpcStatus.getStatus(url);
+        RpcStatus methodRpcStatus = RpcStatus.getStatus(url, methodName);
+
+        Assertions.assertTrue(flag);
+        Assertions.assertNotNull(urlRpcStatus);
+        Assertions.assertNotNull(methodRpcStatus);
+        Assertions.assertEquals(urlRpcStatus.getActive(), 1);
+        Assertions.assertEquals(methodRpcStatus.getActive(), 1);
+
+        RpcStatus.endCount(url, methodName, 1000, true);
+        Assertions.assertEquals(urlRpcStatus.getActive(), 0);
+        Assertions.assertEquals(methodRpcStatus.getActive(), 0);
+
+        flag = RpcStatus.beginCount(url, methodName, max);
+        Assertions.assertTrue(flag);
+        flag = RpcStatus.beginCount(url, methodName, max);
+        Assertions.assertTrue(flag);
+        flag = RpcStatus.beginCount(url, methodName, max);
+        Assertions.assertFalse(flag);
+
+    }
+
+    @Test
+    public void testBeginCountEndCountInMultiThread() throws Exception {
+        URL url = new ServiceConfigURL("dubbo", "127.0.0.1", 91032, 
DemoService.class.getName());
+        String methodName = "testBeginCountEndCountInMultiThread";
+        int max = 50;
+        int threadNum = 10;
+        AtomicInteger successCount = new AtomicInteger();
+        CountDownLatch startLatch = new CountDownLatch(1);
+        CountDownLatch endLatch = new CountDownLatch(threadNum);
+        List<Thread> threadList = new ArrayList<>(threadNum);
+        for (int i = 0; i < threadNum; i++) {
+            Thread thread = new Thread(() -> {
+                try {
+                    startLatch.await();
+                    for (int j = 0; j < 100; j++) {
+                        boolean flag = RpcStatus.beginCount(url, methodName, 
max);
+                        if (flag) {
+                            successCount.incrementAndGet();
+                        }
+                    }
+                    endLatch.countDown();
+                } catch (Exception e) {
+                    // ignore
+                }
+            });
+            threadList.add(thread);
+        }
+        threadList.forEach(Thread::start);
+        startLatch.countDown();
+        endLatch.await();
+        Assertions.assertEquals(successCount.get(), max);
+
+    }
+
+    @Test
+    public void testStatistics() {
+        URL url = new ServiceConfigURL("dubbo", "127.0.0.1", 91033, 
DemoService.class.getName());
+        String methodName = "testStatistics";
+        int max = 0;
+        RpcStatus.beginCount(url, methodName, max);
+        RpcStatus.beginCount(url, methodName, max);
+        RpcStatus.beginCount(url, methodName, max);
+        RpcStatus.beginCount(url, methodName, max);
+        RpcStatus.endCount(url, methodName, 1000, true);
+        RpcStatus.endCount(url, methodName, 2000, true);
+        RpcStatus.endCount(url, methodName, 3000, false);
+        RpcStatus.endCount(url, methodName, 4000, false);
+
+        RpcStatus urlRpcStatus = RpcStatus.getStatus(url);
+        RpcStatus methodRpcStatus = RpcStatus.getStatus(url, methodName);
+        for (RpcStatus rpcStatus : Arrays.asList(urlRpcStatus, 
methodRpcStatus)) {
+            Assertions.assertEquals(rpcStatus.getActive(), 0);
+            Assertions.assertEquals(rpcStatus.getTotal(), 4);
+            Assertions.assertEquals(rpcStatus.getTotalElapsed(), 10000);
+            Assertions.assertEquals(rpcStatus.getMaxElapsed(), 4000);
+            Assertions.assertEquals(rpcStatus.getAverageElapsed(), 2500);
+            Assertions.assertEquals(rpcStatus.getAverageTps(), 0);
+
+            Assertions.assertEquals(rpcStatus.getSucceeded(), 2);
+            Assertions.assertEquals(rpcStatus.getSucceededElapsed(), 3000);
+            Assertions.assertEquals(rpcStatus.getSucceededMaxElapsed(), 2000);
+            Assertions.assertEquals(rpcStatus.getSucceededAverageElapsed(), 
1500);
+
+            Assertions.assertEquals(rpcStatus.getFailed(), 2);
+            Assertions.assertEquals(rpcStatus.getFailedElapsed(), 7000);
+            Assertions.assertEquals(rpcStatus.getFailedMaxElapsed(), 4000);
+            Assertions.assertEquals(rpcStatus.getFailedAverageElapsed(), 3500);
+        }
+    }
+}
diff --git 
a/dubbo-rpc/dubbo-rpc-api/src/test/java/org/apache/dubbo/rpc/TimeoutCountDownTest.java
 
b/dubbo-rpc/dubbo-rpc-api/src/test/java/org/apache/dubbo/rpc/TimeoutCountDownTest.java
index c83ab01..cfb7162 100644
--- 
a/dubbo-rpc/dubbo-rpc-api/src/test/java/org/apache/dubbo/rpc/TimeoutCountDownTest.java
+++ 
b/dubbo-rpc/dubbo-rpc-api/src/test/java/org/apache/dubbo/rpc/TimeoutCountDownTest.java
@@ -30,10 +30,12 @@ public class TimeoutCountDownTest {
         Assertions.assertEquals(5 * 1000, 
timeoutCountDown.getTimeoutInMilli());
         Assertions.assertFalse(timeoutCountDown.isExpired());
         Assertions.assertTrue(timeoutCountDown.timeRemaining(TimeUnit.SECONDS) 
> 0);
+        Assertions.assertTrue(timeoutCountDown.elapsedMillis() < 
TimeUnit.MILLISECONDS.convert(5, TimeUnit.SECONDS));
 
         Thread.sleep(6 * 1000);
 
         Assertions.assertTrue(timeoutCountDown.isExpired());
         Assertions.assertTrue(timeoutCountDown.timeRemaining(TimeUnit.SECONDS) 
<= 0);
+        Assertions.assertTrue(timeoutCountDown.elapsedMillis() > 
TimeUnit.MILLISECONDS.convert(5, TimeUnit.SECONDS));
     }
 }
diff --git 
a/dubbo-rpc/dubbo-rpc-api/src/test/java/org/apache/dubbo/rpc/TimeoutCountDownTest.java
 
b/dubbo-rpc/dubbo-rpc-api/src/test/java/org/apache/dubbo/rpc/support/PenetrateAttachmentSelectorMock.java
similarity index 51%
copy from 
dubbo-rpc/dubbo-rpc-api/src/test/java/org/apache/dubbo/rpc/TimeoutCountDownTest.java
copy to 
dubbo-rpc/dubbo-rpc-api/src/test/java/org/apache/dubbo/rpc/support/PenetrateAttachmentSelectorMock.java
index c83ab01..f40eb0f 100644
--- 
a/dubbo-rpc/dubbo-rpc-api/src/test/java/org/apache/dubbo/rpc/TimeoutCountDownTest.java
+++ 
b/dubbo-rpc/dubbo-rpc-api/src/test/java/org/apache/dubbo/rpc/support/PenetrateAttachmentSelectorMock.java
@@ -14,26 +14,19 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+package org.apache.dubbo.rpc.support;
 
-package org.apache.dubbo.rpc;
+import org.apache.dubbo.rpc.PenetrateAttachmentSelector;
+import org.apache.dubbo.rpc.RpcContext;
 
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
+import java.util.Map;
 
-import java.util.concurrent.TimeUnit;
+public class PenetrateAttachmentSelectorMock implements 
PenetrateAttachmentSelector {
 
-public class TimeoutCountDownTest {
-
-    @Test
-    public void testTimeoutCountDown() throws InterruptedException {
-        TimeoutCountDown timeoutCountDown = TimeoutCountDown.newCountDown(5, 
TimeUnit.SECONDS);
-        Assertions.assertEquals(5 * 1000, 
timeoutCountDown.getTimeoutInMilli());
-        Assertions.assertFalse(timeoutCountDown.isExpired());
-        Assertions.assertTrue(timeoutCountDown.timeRemaining(TimeUnit.SECONDS) 
> 0);
-
-        Thread.sleep(6 * 1000);
-
-        Assertions.assertTrue(timeoutCountDown.isExpired());
-        Assertions.assertTrue(timeoutCountDown.timeRemaining(TimeUnit.SECONDS) 
<= 0);
+    @Override
+    public Map<String, Object> select() {
+        Map<String, Object> objectAttachments = 
RpcContext.getServerAttachment().getObjectAttachments();
+        objectAttachments.put("testKey", "testVal");
+        return objectAttachments;
     }
 }
diff --git 
a/dubbo-rpc/dubbo-rpc-api/src/test/resources/META-INF/dubbo/internal/org.apache.dubbo.rpc.PenetrateAttachmentSelector
 
b/dubbo-rpc/dubbo-rpc-api/src/test/resources/META-INF/dubbo/internal/org.apache.dubbo.rpc.PenetrateAttachmentSelector
new file mode 100644
index 0000000..c6dfb20
--- /dev/null
+++ 
b/dubbo-rpc/dubbo-rpc-api/src/test/resources/META-INF/dubbo/internal/org.apache.dubbo.rpc.PenetrateAttachmentSelector
@@ -0,0 +1 @@
+mock=org.apache.dubbo.rpc.support.PenetrateAttachmentSelectorMock

Reply via email to