I've filed issue #5 on the java client: RiakObject should not present a getValueAsBytes() method
The real problem is that if the caller does not use stream(), RiakClient will call getResponseBodyAsString() on the HttpMethod object. This will of course convert from byte[] to String, which is broken behavior for non-string data and is unexpected if the caller uses getValueAsBytes() in RiakObject. IMHO RiakObject should only hold a byte array and perform byte[] to String conversion only on demand and when explicitly asked to do so (if at all). On Fri, May 28, 2010 at 3:29 PM, Sam Tingleff <s...@tingleff.com> wrote: > > Yeah... looks like the java client is mangling on get. > > On Fri, May 28, 2010 at 3:18 PM, Sean Cribbs <s...@basho.com> wrote: >> >> Your other alternative is to write with the Java client, then download the >> data with an external program like curl, and see if the bytes are mangled >> before they get to Riak (using a hex editor or something). You might even >> use something like Wireshark to see what is sent in the TCP packets, if you >> want to get fancy. >> My suspicion is that they are being modified somewhere in the Java stack. >> Riak is completely agnostic about any binary data you give it. >> >> Sean Cribbs <s...@basho.com> >> Developer Advocate >> Basho Technologies, Inc. >> http://basho.com/ >> On May 28, 2010, at 6:06 PM, Sam Tingleff wrote: >> >> It looks like byte values < 0 are consistently modified on read. >> >> On Fri, May 28, 2010 at 2:58 PM, Sam Tingleff <s...@tingleff.com> wrote: >>> >>> Yeah, you're right... I'm sending as application/octet-stream. Is there >>> some special handling depending on content-type? >>> >>> On Fri, May 28, 2010 at 2:56 PM, Sean Cribbs <s...@basho.com> wrote: >>>> >>>> It seems more than just the first two bytes are changed. What >>>> content-type are you sending the data as? >>>> >>>> Sean Cribbs <s...@basho.com> >>>> Developer Advocate >>>> Basho Technologies, Inc. >>>> http://basho.com/ >>>> >>>> On May 28, 2010, at 5:46 PM, Sam Tingleff wrote: >>>> >>>> > >>>> > It sounds crazy, I know. >>>> > >>>> > I'm using the Java client with riak 0.10.1-1. Sending a byte array seems >>>> > to work if it is a UTF-8 encoded string. But if I send serialized object >>>> > data, or just compressed bytes, the first two bytes seem to come back >>>> > modified on read. >>>> > >>>> > From the debugger... Sending: >>>> > [31, -117, 8, 0, 0, 0, 0, 0, 0, 0, -53, 72, -51, -55, -55, 87, 72, 41, >>>> > 77, 73, 5, 0, 108, 24, 72, 30, 10, 0, 0, 0] >>>> > >>>> > I get back: >>>> > [31, 63, 8, 0, 0, 0, 0, 0, 0, 0, -24, 72, -22, -125, -125, 87, 72, 41, >>>> > 77, 73, 5, 0, 108, 24, 72, 30, 10, 0, 0, 0] >>>> > >>>> > What's going on? Thanks! >>>> > _______________________________________________ >>>> > riak-users mailing list >>>> > riak-users@lists.basho.com >>>> > http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com >>>> >>> >> >> _______________________________________________ >> riak-users mailing list >> riak-users@lists.basho.com >> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com >> > _______________________________________________ riak-users mailing list riak-users@lists.basho.com http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com