Issue 1:
I have checked the FAQ of this repository and believe that this is not a duplicate.

I have searched the issues of this repository and believe that this is not a duplicate.

Environment

Dubbo version: 2.7.8

Operating System version: macOS Catalina

Java version: 1.8

Steps to reproduce this issue

TreePathDynamicConfiguration#publishConfig will call AbstractDynamicConfiguration.execute() to execute Callable and result type required boolean。execute() will return null when some Exception throw during execute Callable and then NPE will throw. Also AbstractDynamicConfiguration#removeConfig has the same problem.

public final boolean publishConfig(String key, String group, String content) {
String pathKey = buildPathKey(group, key);
// NPE may occur if execute(...) return null
return execute(() -> doPublishConfig(pathKey, content), getDefaultTimeout());
}

protected final <V> V execute(Callable<V> task, long timeout) {
V value = null;
try {
if (timeout < 1) { // less or equal 0
value = task.call();
} else {
Future<V> future = workersThreadPool.submit(task);
value = future.get(timeout, TimeUnit.MILLISECONDS);
}
} catch (Exception e) {
// will return null
if (logger.isErrorEnabled()) {
logger.error(e.getMessage(), e);
}
}
return value;
}

Expected Result

TreePathDynamicConfiguration#publishConfig return false when some Exception happened during execute Callable

Actual Result

throw NPE

If there is an exception, please attach the exception trace:

Caused by: org.apache.zookeeper.KeeperException$NoAuthException: KeeperErrorCode = NoAuth for /home/qianqian/dubbo/metadata
at org.apache.zookeeper.KeeperException.create(KeeperException.java:116)
at org.apache.zookeeper.KeeperException.create(KeeperException.java:54)
at org.apache.zookeeper.ZooKeeper.create(ZooKeeper.java:792)
at org.apache.curator.framework.imps.CreateBuilderImpl$17.call(CreateBuilderImpl.java:1177)
at org.apache.curator.framework.imps.CreateBuilderImpl$17.call(CreateBuilderImpl.java:1158)
at org.apache.curator.connection.StandardConnectionHandlingPolicy.callWithRetry(StandardConnectionHandlingPolicy.java:64)
at org.apache.curator.RetryLoop.callWithRetry(RetryLoop.java:100)
at org.apache.curator.framework.imps.CreateBuilderImpl.pathInForeground(CreateBuilderImpl.java:1155)
at org.apache.curator.framework.imps.CreateBuilderImpl.protectedPathInForeground(CreateBuilderImpl.java:605)
at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:595)
at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:573)
at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:49)
at org.apache.dubbo.remoting.zookeeper.curator.CuratorZookeeperClient.createPersistent(CuratorZookeeperClient.java:90)
... 16 common frames omitted
java.lang.NullPointerException: null
at org.apache.dubbo.common.config.configcenter.TreePathDynamicConfiguration.publishConfig(TreePathDynamicConfiguration.java:90)
at org.apache.dubbo.metadata.report.support.ConfigCenterBasedMetadataReport.saveMetadata(ConfigCenterBasedMetadataReport.java:123)
at org.apache.dubbo.metadata.report.support.ConfigCenterBasedMetadataReport.doStoreConsumerMetadata(ConfigCenterBasedMetadataReport.java:67)
at org.apache.dubbo.metadata.report.support.AbstractMetadataReport.storeConsumerMetadataTask(AbstractMetadataReport.java:309)
at org.apache.dubbo.metadata.report.support.AbstractMetadataReport.lambda$storeConsumerMetadata$1(AbstractMetadataReport.java:295)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)

Issue 2:
I have searched the issues of this repository and believe that this is not a duplicate.

I have checked the FAQ of this repository and believe that this is not a duplicate.

Environment

Dubbo version: 所有版本

Operating System version: 所有版本

Java version: 所有版本

Steps to reproduce this issue

1.使用自定义的classloader去加载一个jar。

2.初始化该jar里面的某个类，通过ReferenceConfig生成该类的rpc服务。

3.出现各种ClassNotFound或者生成代理类失败

Pls. provide [GitHub address] to reproduce this issue.

https://github.com/apache/dubbo/blob/master/dubbo-common/src/main/java/org/apache/dubbo/common/bytecode/Proxy.java

和

https://github.com/apache/dubbo/blob/master/dubbo-common/src/main/java/org/apache/dubbo/common/bytecode/ClassGenerator.java

Expected Result

期望dubbo生成代理类的时候使用Thread.currentThread.getContextClassLoader获得的ClassLoader或者要生成Interface的ClassLoader而不是写死直接使用系统的ClassLoader

What do you expected from the above steps？

修改上面两个类的默认ClassLoader获取方式

Actual Result

return getProxy(ClassHelper.getCallerClassLoader(ics[0]), ics);

What actually happens?

生成代理类异常

If there is an exception, please attach the exception trace:

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'recommendDynamicService' defined in file [D:\project\project\vivoshop-recommend\recommend-core\target\classes\com\vivo\internet\recommend\core\service\impl\RecommendDynamicServiceImpl.class]: Invocation of init method failed; nested exception is java.lang.RuntimeException: java.lang.IllegalArgumentException: interface com.bbkmobile.iqoo.vivoshop.facade.recommend.ManualRecommendFacade is not visible from class loader

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1631) ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553) ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:481) ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]

at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:312) ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]

at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]

at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:308) ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]

at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]

at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:522) ~[spring-context-4.3.22.RELEASE.jar:4.3.22.RELEASE]

at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:496) ~[spring-context-4.3.22.RELEASE.jar:4.3.22.RELEASE]

at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:627) ~[spring-context-4.3.22.RELEASE.jar:4.3.22.RELEASE]

at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:171) ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]

at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87) ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]

at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:318) ~[spring-context-4.3.22.RELEASE.jar:4.3.22.RELEASE]

... 29 common frames omitted

Caused by: java.lang.RuntimeException: java.lang.IllegalArgumentException: interface com.bbkmobile.iqoo.vivoshop.facade.recommend.ManualRecommendFacade is not visible from class loader

at com.vivo.internet.recommend.core.service.impl.RecommendDynamicServiceImpl.initAndReplaceDynamicProcessors(RecommendDynamicServiceImpl.java:208) ~[classes/:na]

at com.vivo.internet.recommend.core.service.impl.RecommendDynamicServiceImpl.refreshAllDynamicServices(RecommendDynamicServiceImpl.java:167) ~[classes/:na]

at com.vivo.internet.recommend.core.service.impl.RecommendDynamicServiceImpl.afterPropertiesSet(RecommendDynamicServiceImpl.java:246) ~[classes/:na]

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1689) ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1627) ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]

... 41 common frames omitted

Caused by: java.lang.IllegalArgumentException: interface com.bbkmobile.iqoo.vivoshop.facade.recommend.ManualRecommendFacade is not visible from class loader

at com.alibaba.dubbo.common.bytecode.Proxy.getProxy(Proxy.java:98) ~[dubbo-3.0.7-VIVO.jar:3.0.7-VIVO]

at com.alibaba.dubbo.common.bytecode.Proxy.getProxy(Proxy.java:67) ~[dubbo-3.0.7-VIVO.jar:3.0.7-VIVO]

at com.alibaba.dubbo.rpc.proxy.javassist.JavassistProxyFactory.getProxy(JavassistProxyFactory.java:35) ~[dubbo-3.0.7-VIVO.jar:3.0.7-VIVO]

at com.alibaba.dubbo.rpc.proxy.AbstractProxyFactory.getProxy(AbstractProxyFactory.java:49) ~[dubbo-3.0.7-VIVO.jar:3.0.7-VIVO]

at com.alibaba.dubbo.rpc.proxy.wrapper.StubProxyFactoryWrapper.getProxy(StubProxyFactoryWrapper.java:60) ~[dubbo-3.0.7-VIVO.jar:3.0.7-VIVO]

at com.alibaba.dubbo.rpc.ProxyFactory$Adpative.getProxy(ProxyFactory$Adpative.java) ~[dubbo-3.0.7-VIVO.jar:3.0.7-VIVO]

at com.alibaba.dubbo.config.ReferenceConfig.createProxy(ReferenceConfig.java:438) ~[dubbo-3.0.7-VIVO.jar:3.0.7-VIVO]

at com.alibaba.dubbo.config.ReferenceConfig.init(ReferenceConfig.java:312) ~[dubbo-3.0.7-VIVO.jar:3.0.7-VIVO]

at com.alibaba.dubbo.config.ReferenceConfig.get(ReferenceConfig.java:141) ~[dubbo-3.0.7-VIVO.jar:3.0.7-VIVO]

at com.vivo.internet.recommend.common.utils.DuuboUtils.getReferenceService(DuuboUtils.java:31) ~[classes/:na]

at com.vivo.internet.recommend.core.service.impl.RecommendDynamicServiceImpl.initAndReplaceDynamicProcessors(RecommendDynamicServiceImpl.java:201) ~[classes/:na]

... 45 common frames omitte

Just put your stack trace here!
无