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

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 0.9.3, 0.12.0
    • 0.13.0
    • Java - Compiler
    • 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

              Unassigned Unassigned
              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