You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by li...@apache.org on 2023/08/16 08:29:43 UTC

[dubbo-go] branch main updated: fix(config): An issue that random ports can't be assgined (#2384)

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

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


The following commit(s) were added to refs/heads/main by this push:
     new bf5f2ddf4 fix(config): An issue that random ports can't be assgined (#2384)
bf5f2ddf4 is described below

commit bf5f2ddf40eaf9779355a692bab7842e290b54b2
Author: Xuewei Niu <ju...@apache.org>
AuthorDate: Wed Aug 16 16:29:39 2023 +0800

    fix(config): An issue that random ports can't be assgined (#2384)
    
    Fixes #2382. The condition of assigning a random port for protocols should be that port
    is less than or equal to 0, not the length of the port string.
---
 config/service_config.go | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/config/service_config.go b/config/service_config.go
index fb9723367..976071a2b 100644
--- a/config/service_config.go
+++ b/config/service_config.go
@@ -209,7 +209,12 @@ func (s *ServiceConfig) IsExport() bool {
 func getRandomPort(protocolConfigs []*ProtocolConfig) *list.List {
 	ports := list.New()
 	for _, proto := range protocolConfigs {
-		if len(proto.Port) > 0 {
+		if port, err := strconv.Atoi(proto.Port); err != nil {
+			logger.Infof(
+				"%s will be assgined to a random port, since the port is an invalid number",
+				proto.Name,
+			)
+		} else if port > 0 {
 			continue
 		}