basho/riak-ruby-client — pull request #173 by bkerley (2014-07-08 23:11:08+00:00)
Title: Interrupting a request can cause subsequent requests to get bad values

Example that shows the issue:

```ruby
require 'rubygems'
require 'riak'
require 'timeout'

client = Riak::Client.new(:http_backend => :NetHTTP, :protocol => "pbc", :nodes => [{:host => "127.0.0.1", :http_port => 8098, :pbc_port => 8087}])
bucket = "mybucket"
key = "mykey"
value = "myvalue"
bad_key = "badkey"

object = client.bucket(bucket).new(key)
object.raw_data = value
object.content_type = "application/octet-stream"
object.store

loop do
begin
Timeout.timeout(1) do
loop{ client.bucket(bucket).get(key).raw_data }
end
rescue Timeout::Error
begin
puts "BAD DATA: #{client.bucket(bucket).get(bad_key).raw_data}"
break
rescue ::Riak::FailedRequest
end
end
end
```

When the client code is interrupted between sending on the socket and receiving on the socket, a timeout in this case but any interrupt (Ctrl-C in rails console, for instance) would do, the next request will get the previous request's response.