Skip to content

Commit

Permalink
fix: do not close gocql.iter() on error (#302)
Browse files Browse the repository at this point in the history
  • Loading branch information
venkat1109 authored Aug 7, 2017
1 parent e21f256 commit aafd57d
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions common/persistence/cassandraPersistence.go
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,12 @@ func (d *cassandraPersistence) CreateWorkflowExecution(request *CreateWorkflowEx

previous := make(map[string]interface{})
applied, iter, err := d.session.MapExecuteBatchCAS(batch, previous)
defer iter.Close()
defer func() {
if iter != nil {
iter.Close()
}
}()

if err != nil {
if isTimeoutError(err) {
// Write may have succeeded, but we don't know
Expand Down Expand Up @@ -1019,7 +1024,12 @@ func (d *cassandraPersistence) UpdateWorkflowExecution(request *UpdateWorkflowEx

previous := make(map[string]interface{})
applied, iter, err := d.session.MapExecuteBatchCAS(batch, previous)
defer iter.Close()
defer func() {
if iter != nil {
iter.Close()
}
}()

if err != nil {
if isTimeoutError(err) {
// Write may have succeeded, but we don't know
Expand Down

0 comments on commit aafd57d

Please sign in to comment.