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

type set is handled incorrectly when writing object

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 0.7
    • 0.8
    • None
    • Patch Available

    Description

      Patch provided in https://issues.apache.org/jira/browse/THRIFT-342 doesn't handle object writing correctly:
      if one of the parameters is set

      struct MyStruct {
      10: string id,
      20: string name,
      30: set<string> setOfIDs
      }

      in generated file de-serialization of object is
      public function read($input)
      ...
      $xfer += $input->readString($elem5);
      if (is_scalar($elem5)) {
      $this->setOfIDs[$elem5] = true;
      } else {
      $this->setOfIDs []= $elem5;
      }
      ...

      but when serializing, we are looping only through values of array:
      public function write($input)
      ...
      foreach ($this->setOfIDs as $iter6)
      {
      if (is_scalar($iter6))

      { $this->setOfIDs[$iter6] = true; }

      $xfer += $output->writeString($iter6);
      }
      }
      ...

      But if our element is scalar - we should be iterating through keys.

      it should look like:
      foreach ($this->terminalIds as $iter6 => $iter7)
      {
      if (is_scalar($iter7))

      { $xfer += $output->writeString($iter6); }

      else

      { $xfer += $output->writeString($iter7); }

      }

      Attachments

        1. thrift-1279.patch
          1 kB
          Darius Staisiunas

        Activity

          People

            Unassigned Unassigned
            edast Darius Staisiunas
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: