wcy666103 commented on PR #14220:
URL: https://github.com/apache/dubbo/pull/14220#issuecomment-2121792780
> @wcy666103 PTAL
After my investigation, I found a logical bug, the specific error message is
in:
Extensiondirector #testInheritanceAndScope() method, which is used to
initialize fwExtensionDirector,
```java
ExtensionDirector fwExtensionDirector =
new ExtensionDirector(null, ExtensionScope.FRAMEWORK,
FrameworkModel.defaultModel());
```
However, only extensionDirector objects that pass ScopeModel#initialize()
are fully context-aware objects,
```java
protected void initialize() {
synchronized (instLock) {
this.extensionDirector =
new ExtensionDirector(parent != null ?
parent.getExtensionDirector() : null, scope, this);
this.extensionDirector.addExtensionPostProcessor(new
ScopeModelAwareExtensionProcessor(this));
this.beanFactory = new ScopeBeanFactory(parent != null ?
parent.getBeanFactory() : null, extensionDirector);
// Add Framework's ClassLoader by default
ClassLoader dubboClassLoader = ScopeModel.class.getClassLoader();
if (dubboClassLoader != null) {
this.addClassLoader(dubboClassLoader);
}
}
}
```
so the direct new approach has some properties that are null when used in
practice, and this error exists in multiple branches.
So there are two ways to fix this:
1. The developer determines if there are logic holes in the source code
2. Modify the tese use case to:
```java
ExtensionDirector fwExtensionDirector =
new ExtensionDirector(null, ExtensionScope.FRAMEWORK,
FrameworkModel.defaultModel());
fwExtensionDirector.addExtensionPostProcessor(new
ScopeModelAwareExtensionProcessor(FrameworkModel.defaultModel()));
```
or
```java
ExtensionDirector fwExtensionDirector = FrameworkModel.defaultModel()
.getExtensionDirector();
```
Which form should I use?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]