hxmhlt commented on a change in pull request #476:
URL: https://github.com/apache/dubbo-go/pull/476#discussion_r416289534



##########
File path: config/service_config.go
##########
@@ -105,6 +107,24 @@ func NewServiceConfig(id string, context context.Context) 
*ServiceConfig {
        }
 }
 
+// Get Random Port
+func getRandomPort(protocolConfigs []*ProtocolConfig) *list.List {
+       ports := list.New()
+       for _, proto := range protocolConfigs {
+               if len(proto.Port) > 0 {
+                       continue
+               }
+
+               tcp, err := gxnet.ListenOnTCPRandomPort(proto.Ip)
+               if err != nil {
+                       panic(perrors.New(fmt.Sprintf("Get tcp port error,err 
is {%v}", err)))
+               }
+               ports.PushBack(strings.Split(tcp.Addr().String(), ":")[1])
+               defer tcp.Close()

Review comment:
       move defer tcp.Close after line 118.

##########
File path: config/service_config.go
##########
@@ -123,10 +143,14 @@ func (c *ServiceConfig) Export() error {
        regUrls := loadRegistries(c.Registry, providerConfig.Registries, 
common.PROVIDER)
        urlMap := c.getUrlMap()
        protocolConfigs := loadProtocol(c.Protocol, providerConfig.Protocols)
-       if len(protocolConfigs) == 0 {
+       protocolSize := len(protocolConfigs)

Review comment:
       Why do this change?

##########
File path: config/service_config_test.go
##########
@@ -23,6 +23,8 @@ import (
 
 import (
        "github.com/apache/dubbo-go/common/extension"
+       gxnet "github.com/dubbogo/gost/net"
+       "github.com/stretchr/testify/assert"

Review comment:
       format




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

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to