Skip to content
This repository has been archived by the owner on Oct 17, 2023. It is now read-only.

Commit

Permalink
make a copy of msg.Data before calling client.Write
Browse files Browse the repository at this point in the history
  • Loading branch information
jipperinbham committed Jan 24, 2017
1 parent 19f443d commit 7d8b223
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/adaptor/elasticsearch/elasticsearch.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,12 @@ func (e *Elasticsearch) Stop() error {

func (e *Elasticsearch) applyOp(msg message.Msg) (message.Msg, error) {
_, msgColl, _ := message.SplitNamespace(msg)
err := e.client.Write(message.From(msg.OP(), e.computeNamespace(msgColl), msg.Data()))(nil)
var msgCopy map[string]interface{}
// Copy from the original map to the target map
for key, value := range msg.Data() {
msgCopy[key] = value
}
err := e.client.Write(message.From(msg.OP(), e.computeNamespace(msgColl), msgCopy))(nil)

if err != nil {
e.pipe.Err <- adaptor.NewError(adaptor.ERROR, e.path, fmt.Sprintf("write message error (%s)", err), msg.Data)
Expand Down

0 comments on commit 7d8b223

Please sign in to comment.