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

Required field incorrectly marked as set when fieldType does not match

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 0.11.0
    • Fix Version/s: 0.12.0
    • Component/s: Go - Compiler
    • Labels:
      None

      Description

      The "Read" function that gets generated incorrectly marks required fields as being set when the type of the field does not match what's expected.

      For example, the following IDL:
      struct Foo {
        1: required string id
      }

      The generated Read function has the following:

      switch fieldId {
        case 1:
          if fieldTypeId == thrift.STRING {
            if err := p.ReadField1(iprot); err != nil {
              return err

                   }
          } else {
            if err := iprot.Skip(fieldTypeId); err != nil {
              return err

                  }

              }
          issetID = true
      }

      I ran into a case where I attempted to deserialize another message type into type Foo, and I expected it to return an error, but it did not.

      f : = Foo{}
      err := thrift.NewTDeserializer().Read(&f, bytes)

      I think this code in the generator needs to be moved inside the first "if" block, so that its only set to true if it actually reads the data of the correct type.
       

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                codecraig Craig W
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: