You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudberry.apache.org by ma...@apache.org on 2025/07/23 02:58:35 UTC

(cloudberry-go-libs) 21/23: Add length check before returning first index of segmentList (#91)

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

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

commit 0ced619f8d1225877158ad387639c49e5edd18bc
Author: Brandon Tat <ta...@vmware.com>
AuthorDate: Wed May 22 14:06:55 2024 -0700

    Add length check before returning first index of segmentList (#91)
    
    This commit adds a length check on the segmentList within getSegmentByRole() before returning the first index to avoid panicking.
---
 cluster/cluster.go | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/cluster/cluster.go b/cluster/cluster.go
index 6643b97..62ccd85 100644
--- a/cluster/cluster.go
+++ b/cluster/cluster.go
@@ -435,6 +435,9 @@ func getSegmentByRole(segmentList []*SegConfig, role ...string) *SegConfig {
 		}
 		return segmentList[1]
 	}
+	if len(segmentList) == 0 {
+		return nil
+	}
 	return segmentList[0]
 }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cloudberry.apache.org
For additional commands, e-mail: commits-help@cloudberry.apache.org