Details
-
Bug
-
Status: Closed
-
Critical
-
Resolution: Fixed
-
0.9
-
None
-
Java 1.7
Description
There seems to be an issue where structs lose their binary data when passed from server to client in Java. This can be illustrated using the repro steps below.
1. Create a simple struct that contains a binary field
struct TObject { 1: required binary data }
2. Create a simple service that has a method that returns a TObject
service TService { TObject get(); }
3. Generate java code for the struct and service
4. Create a server that implements TService.Iface
@Override public TObject get() throws TException { return new TObject(ByteBuffer.allocate(8).putLong(0)); }
5. Create a client that calls to get get() function on the server and prints out the capacity of the return TObject's bytebuffer
TTransport transport = new TSocket("localhost", 1111); transport.open(); TProtocol protocol = new TBinaryProtocol(transport); TService.Client client = new TService.Client(protocol); TObject obj = client.get(); System.out.println(obj.bufferForData().capacity());
Expected: the capacity to be 8
Actual: the capacity is 0, which indicates that the data was somehow lost during transmission