dahernan/goHystrix — pull request #4 by ZeissS (2014-03-25 15:43:50+00:00)
Title: Fixes racecondition

Hi,

this PR fixes a race-condition when the `Run()` method returns a non-nil value and an error. This can happen, if a backend function is just piped-through that has a non-nilable type.

Example:
```

func (client *Client) GetOpenBookings() (int, error) {
// ..of no interest, assume error for example purpose
return -1, fmt.Errorf("Backend unavailable")
}

// Just calls client.GetOpenBookings()
func (cmd *GetOpenBookingsCommand) Run() (interface{}, error) {
return cmd.client.GetOpenBookings()
}
```

Since the previous behavior would now write values into both the `valueChan` and `errorChan`, the behavior might sometimes pick `-1` from the valueChan, and sometimes the error from `errorChan`.

This change interprets a non-nil error value as an error and ensures that a value is never returned.