Skip to content

Commit

Permalink
fix panic when creating new metamap in policies (apache#1040)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zariel authored Dec 30, 2017
1 parent 3688d5f commit 666fb91
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions policies.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,13 @@ func (t *tokenAwareHostPolicy) Init(s *Session) {

func (t *tokenAwareHostPolicy) KeyspaceChanged(update KeyspaceUpdateEvent) {
meta, _ := t.keyspaces.Load().(*keyspaceMeta)
// TODO: avoid recaulating things which havnt changed
var size = 1
if meta != nil {
size = len(meta.replicas)
}

newMeta := &keyspaceMeta{
replicas: make(map[string]map[token][]*HostInfo, len(meta.replicas)),
replicas: make(map[string]map[token][]*HostInfo, size),
}

ks, err := t.session.KeyspaceMetadata(update.Keyspace)
Expand Down

0 comments on commit 666fb91

Please sign in to comment.