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

Read error value in TCompactProtocol when reading a compact Bool value

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Duplicate
    • 0.9.1
    • 0.10.0
    • PHP - Library
    • None

    Description

      In TCompactProtocol, bool-value and FieldBegin(TFiled)will be encoded in one byte(00010001/00010010, express TRUE and FALSE) .
      In python client lib,the code for decoding is as follows :

      $result = $this->readUByte($field_type);
      if (($field_type & 0x0f) == TType::STOP)

      { $field_id = 0; return $result; }

      $delta = $field_type >> 4;
      if ($delta == 0)

      { $result += $this->readI16($field_id); }

      else

      { $field_id = $this->lastFid + $delta; }

      $this->lastFid = $field_id;
      // Error , this method always returns a constant value(TType::BOOL).
      $field_type = $this->getTType($field_type & 0x0f);
      if ($field_type == TCompactProtocol::COMPACT_TRUE)

      { $this->state = TCompactProtocol::STATE_BOOL_READ; $this->boolValue = true; }

      elseif ($field_type == TCompactProtocol::COMPACT_FALSE)

      { $this->state = TCompactProtocol::STATE_BOOL_READ; $this->boolValue = false; }

      else

      { $this->state = TCompactProtocol::STATE_VALUE_READ; }

      return $result;

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              496601562 Dongchao Ding
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: