This is an automated email from the ASF dual-hosted git repository.

crazyhzm 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 8c27837  Fix exception info (#8974)
8c27837 is described below

commit 8c278378fbc033b49b679e37f27fbfc35bcda43b
Author: huazhongming <[email protected]>
AuthorDate: Sat Oct 2 00:33:48 2021 +0800

    Fix exception info (#8974)
    
    * fix exception info
    
    * fix test
    
    * Restore classload
---
 .../java/org/apache/dubbo/config/ServiceConfigBase.java   |  2 +-
 .../java/org/apache/dubbo/config/ReferenceConfigTest.java | 15 ++++++++++++---
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git 
a/dubbo-common/src/main/java/org/apache/dubbo/config/ServiceConfigBase.java 
b/dubbo-common/src/main/java/org/apache/dubbo/config/ServiceConfigBase.java
index 0a292f7..41d3dc7 100644
--- a/dubbo-common/src/main/java/org/apache/dubbo/config/ServiceConfigBase.java
+++ b/dubbo-common/src/main/java/org/apache/dubbo/config/ServiceConfigBase.java
@@ -186,7 +186,7 @@ public abstract class ServiceConfigBase<T> extends 
AbstractServiceConfig {
         if (!interfaceClass.isInstance(ref)) {
             throw new IllegalStateException("The class "
                 + ref.getClass().getName() + 
getClassloaderDesc(ref.getClass()) + " unimplemented interface "
-                + interfaceClass + getClassloaderDesc(ref.getClass()) + "!");
+                + interfaceClass + getClassloaderDesc(interfaceClass) + "!");
         }
     }
 
diff --git 
a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/ReferenceConfigTest.java
 
b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/ReferenceConfigTest.java
index 5d7b42c..ab21b6b 100644
--- 
a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/ReferenceConfigTest.java
+++ 
b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/ReferenceConfigTest.java
@@ -67,6 +67,7 @@ import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.lang.reflect.Constructor;
+import java.net.URLDecoder;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -938,9 +939,10 @@ public class ReferenceConfigTest {
         serviceConfig.export();
 
         String basePath = 
DemoService.class.getProtectionDomain().getCodeSource().getLocation().getFile();
-        basePath = java.net.URLDecoder.decode(basePath, "UTF-8");
-        TestClassLoader classLoader1 = new 
TestClassLoader(Thread.currentThread().getContextClassLoader(), basePath);
-        TestClassLoader classLoader2 = new 
TestClassLoader(Thread.currentThread().getContextClassLoader(), basePath);
+        basePath = URLDecoder.decode(basePath, "UTF-8");
+        ClassLoader classLoader = 
Thread.currentThread().getContextClassLoader();
+        TestClassLoader classLoader1 = new TestClassLoader(classLoader, 
basePath);
+        TestClassLoader classLoader2 = new TestClassLoader(classLoader, 
basePath);
 
         Class<?> class1 = classLoader1.loadClass(DemoService.class.getName(), 
false);
         Class<?> class2 = classLoader2.loadClass(DemoService.class.getName(), 
false);
@@ -988,12 +990,16 @@ public class ReferenceConfigTest {
         Assertions.assertNotEquals(result1.getClass(), result2.getClass());
 
         applicationModel.destroy();
+        DubboBootstrap.getInstance().destroy();
+        Thread.currentThread().setContextClassLoader(classLoader);
+        
Thread.currentThread().getContextClassLoader().loadClass(DemoService.class.getName());
     }
 
     @Test
     public void testDifferentClassLoaderRequest() throws Exception {
         String basePath = 
DemoService.class.getProtectionDomain().getCodeSource().getLocation().getFile();
         basePath = java.net.URLDecoder.decode(basePath, "UTF-8");
+        ClassLoader classLoader = 
Thread.currentThread().getContextClassLoader();
         TestClassLoader1 classLoader1 = new TestClassLoader1(basePath);
         TestClassLoader1 classLoader2 = new TestClassLoader1(basePath);
         TestClassLoader2 classLoader3 = new TestClassLoader2(classLoader2, 
basePath);
@@ -1046,6 +1052,9 @@ public class ReferenceConfigTest {
         Assertions.assertEquals(classLoader1, 
innerRequestReference.get().getClass().getClassLoader());
 
         applicationModel.destroy();
+        DubboBootstrap.getInstance().destroy();
+        Thread.currentThread().setContextClassLoader(classLoader);
+        
Thread.currentThread().getContextClassLoader().loadClass(DemoService.class.getName());
     }
 
     private Class<?> compileCustomRequest(ClassLoader classLoader) throws 
NotFoundException, CannotCompileException {

Reply via email to