From a9d631665e34fc604277c4c6fdff13dcbe4e3b3f Mon Sep 17 00:00:00 2001
From: lixiaobing10051267
Date: Wed, 27 Jul 2016 21:44:22 +0800
Subject: [PATCH] Add handling empty index key that may cause panic issue
---
pkg/client/cache/index.go | 3 +++
1 file changed, 3 insertions(+)
diff --git a/pkg/client/cache/index.go b/pkg/client/cache/index.go
index 437988050ac..218f3c8a535 100644
--- a/pkg/client/cache/index.go
+++ b/pkg/client/cache/index.go
@@ -55,6 +55,9 @@ func IndexFuncToKeyFuncAdapter(indexFunc IndexFunc) KeyFunc {
if len(indexKeys) > 1 {
return "", fmt.Errorf("too many keys: %v", indexKeys)
}
+ if len(indexKeys) == 0 {
+ return "", fmt.Errorf("unexpected empty indexKeys")
+ }
return indexKeys[0], nil
}
}