Skip to content

Commit

Permalink
fix nil map assignment bug
Browse files Browse the repository at this point in the history
  • Loading branch information
maha-hajja committed Jan 23, 2025
1 parent e8d9532 commit 24d8d9f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions iterator/cdc.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ func NewCDCIterator(ctx context.Context, tableName string, pKey string, sKey str
recordsPollingPeriod: recordsPollingPeriod,
}

// initialize SequenceNumberMap if it is nil
if c.lastPosition.SequenceNumberMap == nil {
c.lastPosition.SequenceNumberMap = make(map[string]string)
}

// start listening to changes
c.tomb, ctx = tomb.WithContext(ctx)
c.tomb.Go(func() error {
Expand Down
2 changes: 1 addition & 1 deletion iterator/combined_iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func NewCombinedIterator(
IteratorType: position.TypeCDC,
Time: now,
AfterSnapshot: true,
SequenceNumberMap: map[string]string{},
SequenceNumberMap: make(map[string]string),
})
if err != nil {
return nil, fmt.Errorf("could not create the CDC iterator: %w", err)
Expand Down

0 comments on commit 24d8d9f

Please sign in to comment.