Skip to content

Commit

Permalink
Fix empty config crash
Browse files Browse the repository at this point in the history
  • Loading branch information
dispensable committed Oct 16, 2023
1 parent ae3b9af commit 145522e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
9 changes: 6 additions & 3 deletions cassandra/prefix_switch.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,12 @@ func GetPrefixSwitchTrieFromCfg(
}

logger.Infof("Loading from cfg: %v", loadedMap)

tr := trie.New[rune, PrefixSwitchStatus](keysString, vStatus)
return &tr, loadedMap, nil
if len(keysString) == len(vStatus) && len(keysString) > 0 {
tr := trie.New[rune, PrefixSwitchStatus](keysString, vStatus)
return &tr, loadedMap, nil
} else {
return nil, loadedMap, nil
}
}

func NewPrefixSwitcher(config *config.CassandraStoreCfg, cqlStore *CassandraStore) (*PrefixSwitcher, error) {
Expand Down
10 changes: 7 additions & 3 deletions cassandra/prefix_table_finder.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,13 @@ func getTableTrieFromCfg(
return nil, nil, fmt.Errorf("prefix cfg duplicate: %v", duplicateKeys)
}
logger.Infof("Loading from cfg: %v", loadedMap)

tr := trie.New[rune, string](keysString, vStrStatus)
prefixTrie = &tr

if len(keysString) == len(vStrStatus) && len(keysString) > 0 {
tr := trie.New[rune, string](keysString, vStrStatus)
prefixTrie = &tr
} else {
prefixTrie = nil
}

return prefixTrie, loadedMap, nil
}
Expand Down
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

const (
Version = "v2.0.2-rc2"
Version = "v2.0.2-rc3"
)

var (
Expand Down

0 comments on commit 145522e

Please sign in to comment.