Skip to content

Commit

Permalink
fix(config): An issue that random ports can't be assgined
Browse files Browse the repository at this point in the history
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.

Fixes: #2382

Signed-off-by: Xuewei Niu <justxuewei@apache.org>
  • Loading branch information
justxuewei committed Aug 15, 2023
1 parent 1e78aaf commit 6a81761
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion config/service_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 6a81761

Please sign in to comment.