529645354 opened a new issue, #15263:
URL: https://github.com/apache/dubbo/issues/15263

   ### Pre-check
   
   - [x] I am sure that all the content I provide is in English.
   
   
   ### Search before asking
   
   - [x] I had searched in the 
[issues](https://github.com/apache/dubbo/issues?q=is%3Aissue) and found no 
similar issues.
   
   
   ### Apache Dubbo Component
   
   Java SDK (apache/dubbo)
   
   ### Dubbo Version
   
   Dubbo3.2
   
   ### Steps to reproduce this issue
   
   public class ProtocolSecurityWrapper implements Protocol {
       private final Protocol protocol;
   
       private static final ErrorTypeAwareLogger logger =
               
LoggerFactory.getErrorTypeAwareLogger(ProtocolSecurityWrapper.class);
   
       public ProtocolSecurityWrapper(Protocol protocol) {
           if (protocol == null) {
               throw new IllegalArgumentException("protocol == null");
           }
           this.protocol = protocol;
       }
   
       @Override
       public int getDefaultPort() {
           return protocol.getDefaultPort();
       }
   
       @Override
       public <T> Exporter<T> export(Invoker<T> invoker) throws RpcException {
           try {
               ServiceModel serviceModel = invoker.getUrl().getServiceModel();
               ScopeModel scopeModel = invoker.getUrl().getScopeModel();
               SerializeSecurityConfigurator serializeSecurityConfigurator = 
ScopeModelUtil.getModuleModel(scopeModel)
                       .getBeanFactory()
                       
.getBean(SerializeSecurityConfigurator.class);//生成SerializeSecurityConfigurator
               serializeSecurityConfigurator.refreshStatus(); //刷新安全状态和检查状态
               serializeSecurityConfigurator.refreshCheck();
               //通过 invoker.getInterface() 注册安全检查
               
Optional.ofNullable(invoker.getInterface()).ifPresent(serializeSecurityConfigurator::registerInterface);
               // 如果 serviceModel 不为空,则进一步注册服务接口
               Optional.ofNullable(serviceModel)
                       .map(ServiceModel::getServiceModel)
                       .map(ServiceDescriptor::getServiceInterfaceClass)
                       
.ifPresent(serializeSecurityConfigurator::registerInterface);
   
               Optional.ofNullable(serviceModel)
                       .map(ServiceModel::getServiceMetadata)
                       .map(ServiceMetadata::getServiceType)
                       
.ifPresent(serializeSecurityConfigurator::registerInterface);
           } catch (Throwable t) {
               logger.error(INTERNAL_ERROR, "", "", "Failed to register 
interface for security check", t);
           }
           return protocol.export(invoker); //返回一个DubboExporter
       }
       //引用远程服务,并执行安全检查,确保调用的接口符合安全序列化策略。
       @Override
       public <T> Invoker<T> refer(Class<T> type, URL url) throws RpcException {
           try {
               ServiceModel serviceModel = url.getServiceModel();
               ScopeModel scopeModel = url.getScopeModel();
               SerializeSecurityConfigurator serializeSecurityConfigurator = 
ScopeModelUtil.getModuleModel(scopeModel)
                       .getBeanFactory()
                       .getBean(SerializeSecurityConfigurator.class);
               serializeSecurityConfigurator.refreshStatus();
               serializeSecurityConfigurator.refreshCheck();
               //这里因为可能是泛华服务接口
               Optional.ofNullable(serviceModel)
                       .map(ServiceModel::getServiceModel)
                       .map(ServiceDescriptor::getServiceInterfaceClass)
                       
.ifPresent(serializeSecurityConfigurator::registerInterface);
               //这里才是真正的服务接口
               Optional.ofNullable(serviceModel)
                       .map(ServiceModel::getServiceMetadata)
                       .map(ServiceMetadata::getServiceType)
                       
.ifPresent(serializeSecurityConfigurator::registerInterface);
               serializeSecurityConfigurator.registerInterface(type);
           } catch (Throwable t) {
               logger.error(INTERNAL_ERROR, "", "", "Failed to register 
interface for security check", t);
           }
   
           return protocol.refer(type, url);
       }
   
       @Override
       public void destroy() {
           protocol.destroy();
       }
   
       @Override
       public List<ProtocolServer> getServers() {
           return protocol.getServers();
       }
   }
   
   
   ### What you expected to happen
   
   ProtocolSecurityWrapper这个过滤器里面
   `  Optional.ofNullable(serviceModel)
                       .map(ServiceModel::getServiceModel)
                       .map(ServiceDescriptor::getServiceInterfaceClass)
                       
.ifPresent(serializeSecurityConfigurator::registerInterface);
   
               Optional.ofNullable(serviceModel)
                       .map(ServiceModel::getServiceMetadata)
                       .map(ServiceMetadata::getServiceType)
                       
.ifPresent(serializeSecurityConfigurator::registerInterface);` 
   
这两段代码里面ServiceDescriptor::getServiceInterfaceClass和ServiceMetadata::getServiceType获取到的类不是一样吗?个人不是很明白这么设计的原因,可否解答下出于什么样的场景下这么设计的
   
   ### Anything else
   
   _No response_
   
   ### Are you willing to submit a pull request to fix on your own?
   
   - [ ] Yes I am willing to submit a pull request on my own!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)
   


-- 
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]

Reply via email to