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

Using a default string on a binary field results in invalid Java code.

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 0.9.3, 0.12.0
    • Fix Version/s: 0.13.0
    • Component/s: Java - Compiler
    • Labels:
      None

      Description

      Given the following service definition:

      $ cat Service.thrift 
      service MyService {
          string doWork(
          1: string arg1;
          2: binary arg2 = '';
          3: binary arg3 = '';
          );
      }
      

      And the following compilation:

      /usr/local/Cellar/thrift/0.12.0/bin/thrift -gen java Service.thrift
      

      Results in code that does not compile. This is because we end up with code like the following:

          
          public doWork_args() {
            this.arg2 = "";
      
            this.arg3 = "";
      
          }        
      

      In Java you cannot set a ByteBuffer to a String value.

      Users can run into this situation if they were generating C++ code before (binary and string both resolve to std::string) and then only later decide to use Java with existing files.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                ehiggs Ewan Higgs
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m