Skip to content

Commit

Permalink
Fix: Unmarshal error with events removed EvenData
Browse files Browse the repository at this point in the history
  • Loading branch information
Giau Tran Minh authored Mar 19, 2019
1 parent b53ed77 commit 15f96fd
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions json/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,18 @@ func (Encoder) Decode(rawData []byte) (eh.Event, context.Context, error) {

// Create an event of the correct type.
if data, err := eh.CreateEventData(e.EventType); err == nil {
// Manually decode the raw JSON event.
if err := json.Unmarshal(e.RawData, data); err != nil {
return nil, nil, errors.Wrap(err, "could not unmarshal event data")
if data != nil {
// Manually decode the raw JSON event.
if err := json.Unmarshal(e.RawData, data); err != nil {
return nil, nil, errors.Wrap(err, "could not unmarshal event data")
}
}

// Set concrete event and zero out the decoded event.
e.data = data
e.RawData = nil
} else {
return nil, nil, errors.Wrap(err, "could not unmarshal event data")
}

event := event{evtJSON: e}
Expand Down

0 comments on commit 15f96fd

Please sign in to comment.