[ 
https://issues.apache.org/jira/browse/THRIFT-3767?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

James E. King III closed THRIFT-3767.
-------------------------------------
       Resolution: Duplicate
    Fix Version/s: 0.10.0

> Read error value in  TCompactProtocol  when reading a compact Bool value
> ------------------------------------------------------------------------
>
>                 Key: THRIFT-3767
>                 URL: https://issues.apache.org/jira/browse/THRIFT-3767
>             Project: Thrift
>          Issue Type: Bug
>          Components: PHP - Library
>    Affects Versions: 0.9.1
>            Reporter: Dongchao Ding
>            Priority: Critical
>             Fix For: 0.10.0
>
>
> 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;
>     



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to