File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed
dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster
dubbo-common/src/main/java/org/apache/dubbo/common/extension Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change 1919
2020import org .apache .dubbo .common .Constants ;
2121import org .apache .dubbo .common .URL ;
22+ import org .apache .dubbo .common .extension .ExtensionLoader ;
2223import org .apache .dubbo .rpc .Invocation ;
2324import org .apache .dubbo .rpc .Invoker ;
2425import org .apache .dubbo .rpc .Result ;
@@ -68,6 +69,8 @@ public void setUp() throws Exception {
6869 invokers .add (invoker2 );
6970
7071 clusterinvoker = new StickyClusterInvoker <StickyTest >(dic );
72+
73+ ExtensionLoader .resetExtensionLoader (LoadBalance .class );
7174 }
7275
7376 @ Test
Original file line number Diff line number Diff line change @@ -124,6 +124,20 @@ public static <T> ExtensionLoader<T> getExtensionLoader(Class<T> type) {
124124 return loader ;
125125 }
126126
127+ // For testing purposes only
128+ public static void resetExtensionLoader (Class type ) {
129+ ExtensionLoader loader = EXTENSION_LOADERS .get (type );
130+ if (loader != null ) {
131+ // Remove all instances associated with this loader as well
132+ Map <String , Class <?>> classes = loader .getExtensionClasses ();
133+ for (Map .Entry <String , Class <?>> entry : classes .entrySet ()) {
134+ EXTENSION_INSTANCES .remove (entry .getValue ());
135+ }
136+ classes .clear ();
137+ EXTENSION_LOADERS .remove (type );
138+ }
139+ }
140+
127141 private static ClassLoader findClassLoader () {
128142 return ClassHelper .getClassLoader (ExtensionLoader .class );
129143 }
You can’t perform that action at this time.
0 commit comments