Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-2104

Structs lose binary data when transferred from server to client in Java

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 0.9
    • 0.9.2
    • Java - Compiler
    • 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

      Attachments

        Activity

          People

            Unassigned Unassigned
            jtnelson Jeff Nelson
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: