[ 
https://issues.apache.org/jira/browse/THRIFT-2104?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jeff Nelson updated THRIFT-2104:
--------------------------------

    Description: 
There seems to be 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
{code}
struct TObject {
        1: required binary data
}
{code}
2. Create a simple service that has a method that returns a TObject
{code}
service TService {

        TObject get();
}
{code}
3. Generate java code for the struct and service
4. Create a server that implements TService.Iface
{code}
@Override
        public TObject get() throws TException {
                return new TObject(ByteBuffer.allocate(8).putLong(0));
        }
{code} 
5. Create a client that calls to get get() function on the server and prints 
out the capacity of the return TObject's bytebuffer
{code}
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());
{code}

Expected: the capacity to be 8
Actual: the capacity is 0, which indicates that the data was somehow lost 
during transmission

  was:
There seems to be 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
{code}
struct TObject {
        1: required binary data
}
{code}
2. Create a simple service that has a method that returns a TObject
{code}
service TService {

        TObject get();
}
{code}
3. Generate java code for the struct and service
4. Create a server that implements TService.Iface
{code}
@Override
        public TObject get() throws TException {
                return new TObject(ByteBuffer.allocate(8).putLong(0));
        }
{code} 
5. Create a client that calls to get get() function on the server and prints 
out the capacity of the return TObject's bytebuffer
{code}
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());
{code}

Expected: the capacity to be 8
Actual: the capacity is 0

    
> Structs lose binary data when transferred from server to client in Java
> -----------------------------------------------------------------------
>
>                 Key: THRIFT-2104
>                 URL: https://issues.apache.org/jira/browse/THRIFT-2104
>             Project: Thrift
>          Issue Type: Bug
>          Components: Java - Compiler
>    Affects Versions: 0.9
>         Environment: Java 1.7
>            Reporter: Jeff Nelson
>            Priority: Critical
>
> There seems to be 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
> {code}
> struct TObject {
>         1: required binary data
> }
> {code}
> 2. Create a simple service that has a method that returns a TObject
> {code}
> service TService {
>         TObject get();
> }
> {code}
> 3. Generate java code for the struct and service
> 4. Create a server that implements TService.Iface
> {code}
> @Override
>       public TObject get() throws TException {
>               return new TObject(ByteBuffer.allocate(8).putLong(0));
>       }
> {code} 
> 5. Create a client that calls to get get() function on the server and prints 
> out the capacity of the return TObject's bytebuffer
> {code}
> 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());
> {code}
> Expected: the capacity to be 8
> Actual: the capacity is 0, which indicates that the data was somehow lost 
> during transmission

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to