You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@thrift.apache.org by JKnight JKnight <be...@gmail.com> on 2011/05/23 09:26:35 UTC
Thrift binary data type - Client and server data lenght is different.
Dear all,
My service use binary data type.
Here is my Thrift script. My Server use THaHsServer.
service SimpleService{
oneway void putData(1:binary data),
}
I use Java client. Ex,
client.putData(ByteBuffer.wrap(bytes));
I check the data received by Server. I found that data length of byte array
in client and server is different.
So when I deserialize data from ByteBuffer, the error occur.
Could you help me?
Thank a lot for support.
--
Best regards,
JKnight
Re: Thrift binary data type - Client and server data lenght is different.
Posted by JKnight JKnight <be...@gmail.com>.
I had found the answer.
ByteBuffer received on server also contain some additional data. The real
data is only between position and limit.
Here is my code:
byte[] bytes = ArrayUtils.subarray(data.array, data.position(),
data.limit())
in that, data is ByteBuffer.
Thanks.
On Mon, May 23, 2011 at 3:32 PM, Kevin Clark <ke...@gmail.com> wrote:
> What version of the compiler are you running?
>
> On Mon, May 23, 2011 at 12:26 AM, JKnight JKnight <be...@gmail.com>
> wrote:
> > Dear all,
> >
> > My service use binary data type.
> >
> > Here is my Thrift script. My Server use THaHsServer.
> > service SimpleService{
> > oneway void putData(1:binary data),
> > }
> >
> > I use Java client. Ex,
> > client.putData(ByteBuffer.wrap(bytes));
> >
> > I check the data received by Server. I found that data length of byte
> array
> > in client and server is different.
> >
> > So when I deserialize data from ByteBuffer, the error occur.
> >
> > Could you help me?
> >
> > Thank a lot for support.
> >
> > --
> > Best regards,
> > JKnight
> >
>
>
>
> --
> Kevin Clark
> http://glu.ttono.us
>
--
Best regards,
JKnight
Re: Thrift binary data type - Client and server data lenght is different.
Posted by Kevin Clark <ke...@gmail.com>.
What version of the compiler are you running?
On Mon, May 23, 2011 at 12:26 AM, JKnight JKnight <be...@gmail.com> wrote:
> Dear all,
>
> My service use binary data type.
>
> Here is my Thrift script. My Server use THaHsServer.
> service SimpleService{
> oneway void putData(1:binary data),
> }
>
> I use Java client. Ex,
> client.putData(ByteBuffer.wrap(bytes));
>
> I check the data received by Server. I found that data length of byte array
> in client and server is different.
>
> So when I deserialize data from ByteBuffer, the error occur.
>
> Could you help me?
>
> Thank a lot for support.
>
> --
> Best regards,
> JKnight
>
--
Kevin Clark
http://glu.ttono.us