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

liujun pushed a commit to branch feature-triple
in repository https://gitbox.apache.org/repos/asf/dubbo-go.git


The following commit(s) were added to refs/heads/feature-triple by this push:
     new 80a7536f8 fix #2495, panic: http: multiple registrations for 
/triple.reflection.v1alpha.ServerReflection (#2496)
80a7536f8 is described below

commit 80a7536f83cd671087b24a5fbfde5dc990633c12
Author: finalt <finalt1...@163.com>
AuthorDate: Thu Nov 9 21:55:55 2023 +0800

    fix #2495, panic: http: multiple registrations for 
/triple.reflection.v1alpha.ServerReflection (#2496)
---
 protocol/triple/server.go | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/protocol/triple/server.go b/protocol/triple/server.go
index cc0aba2d2..b6ea60a53 100644
--- a/protocol/triple/server.go
+++ b/protocol/triple/server.go
@@ -115,7 +115,7 @@ func (s *Server) Start(invoker protocol.Invoker, info 
*server.ServiceInfo) {
                if info != nil {
                        handleServiceWithInfo(invoker, info, mux, hanOpts...)
                } else {
-                       compatHandleService(mux)
+                       compatHandleService(URL, mux)
                }
                // todo: figure it out this process
                //reflection.Register(server)
@@ -151,7 +151,7 @@ func (s *Server) RefreshService(invoker protocol.Invoker, 
info *server.ServiceIn
        if info != nil {
                handleServiceWithInfo(invoker, info, mux, hanOpts...)
        } else {
-               compatHandleService(mux)
+               compatHandleService(URL, mux)
        }
 }
 
@@ -208,13 +208,16 @@ func waitTripleExporter(providerServices 
map[string]*config.ServiceConfig) {
 
 // *Important*, this function is responsible for being compatible with old 
triple-gen code
 // compatHandleService creates handler based on ServiceConfig and provider 
service.
-func compatHandleService(mux *http.ServeMux, opts ...tri.HandlerOption) {
+func compatHandleService(url *common.URL, mux *http.ServeMux, opts 
...tri.HandlerOption) {
        providerServices := config.GetProviderConfig().Services
        if len(providerServices) == 0 {
                panic("Provider service map is null")
        }
        //waitTripleExporter(providerServices)
        for key, providerService := range providerServices {
+               if providerService.Interface != url.Interface() {
+                       continue
+               }
                // todo(DMwangnima): judge protocol type
                service := config.GetProviderService(key)
                ds, ok := service.(dubbo3.Dubbo3GrpcService)

Reply via email to