On Wed, Sep 8, 2010 at 12:25 PM, Mathias Herberts < mathias.herbe...@gmail.com> wrote:
> > This patch adds new getters and setters. I'd love to hear what others > think of this change. > > The current (pre 0.4) semantics of the getXXX for a binary field is to > return the content of that field, i.e. the byte[] that was set. > ByteBuffer.capacity() returns the size of the backing array which > might be more than the actual content of the buffer, therefore > TBaseHelper.byteBufferToByteArray may return more data than the actual > content of the field with no way to know what part of the returned > byte[] contains the field's binary value. > > Also having setXXX(byte[]) and getXXX which returns byte[] is very > misleading as people might think that the semantics are the same as > before when they are not, indeed: > > byte[] foo = new byte[1]; > struct.setXXX(foo); > foo[0] = 'A'; > byte[] bar = struct.getXXX(); > Assert.assertEquals(foo[0], bar[0]); > I don't think that this test would actually fail - the byte in the first position of both arrays *should* be equal. However, if you were to check if the arrays themselves were equal, indeed, they would not be. > > will fail when it succeeds today. >