You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Avi Flamholz (JIRA)" <ji...@apache.org> on 2012/12/03 17:55:58 UTC

[jira] [Created] (THRIFT-1772) Serialization does not check types of embedded structures.

Avi Flamholz created THRIFT-1772:
------------------------------------

             Summary: Serialization does not check types of embedded structures.
                 Key: THRIFT-1772
                 URL: https://issues.apache.org/jira/browse/THRIFT-1772
             Project: Thrift
          Issue Type: Bug
          Components: Python - Library
    Affects Versions: 0.9, 0.8
            Reporter: Avi Flamholz


Consider the following struct definitions:

struct Point {
	1: required double x;
	2: required double y;
}

struct Review {
	1: required i32 rating;
	2: optional string text;
}

struct Place {
	1: required string name;
	2: required Point location;
	3: optional Review review;
}

If I create a Place object and set the location field to a Review, it will serialize no problem.

place = Place(name="avi's place", location=Review(rating=1.0))
transportOut = TTransport.TMemoryBuffer()
protocolOut = TBinaryProtocol.TBinaryProtocol(transportOut)
place.write(protocolOut)
serialized = transportOut.getvalue()

This is confusing because if I set an i32 field to a string serialization does raise an error.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (THRIFT-1772) Serialization does not check types of embedded structures.

Posted by "Avi Flamholz (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-1772?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13510165#comment-13510165 ] 

Avi Flamholz commented on THRIFT-1772:
--------------------------------------

Henrique --

I have a working and tested patch, but it doesn't fix the fastbinary protocol. I don't really know how to fix that. Should I submit the patch and then you guys can fix fastbinary?

Avi
                
> Serialization does not check types of embedded structures.
> ----------------------------------------------------------
>
>                 Key: THRIFT-1772
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1772
>             Project: Thrift
>          Issue Type: Bug
>          Components: Python - Library
>    Affects Versions: 0.8, 0.9
>            Reporter: Avi Flamholz
>
> Consider the following struct definitions:
> struct Point {
> 	1: required double x;
> 	2: required double y;
> }
> struct Review {
> 	1: required i32 rating;
> 	2: optional string text;
> }
> struct Place {
> 	1: required string name;
> 	2: required Point location;
> 	3: optional Review review;
> }
> If I create a Place object and set the location field to a Review, it will serialize no problem.
> place = Place(name="avi's place", location=Review(rating=1.0))
> transportOut = TTransport.TMemoryBuffer()
> protocolOut = TBinaryProtocol.TBinaryProtocol(transportOut)
> place.write(protocolOut)
> serialized = transportOut.getvalue()
> This is confusing because if I set an i32 field to a string serialization does raise an error.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (THRIFT-1772) Serialization does not check types of embedded structures.

Posted by "Henrique Mendonca (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-1772?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13509987#comment-13509987 ] 

Henrique Mendonca commented on THRIFT-1772:
-------------------------------------------

Thanks Avi, Although it might reduce performance, I think we should consider also checking the object type.
Do you want to send us a patch?
Please see http://wiki.apache.org/thrift/HowToContribute

Moreover, this probably affects the JS lib too, no sure about php and other weakly-typed languages... Can anyone help us?

Cheers,
Henrique
                
> Serialization does not check types of embedded structures.
> ----------------------------------------------------------
>
>                 Key: THRIFT-1772
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1772
>             Project: Thrift
>          Issue Type: Bug
>          Components: Python - Library
>    Affects Versions: 0.8, 0.9
>            Reporter: Avi Flamholz
>
> Consider the following struct definitions:
> struct Point {
> 	1: required double x;
> 	2: required double y;
> }
> struct Review {
> 	1: required i32 rating;
> 	2: optional string text;
> }
> struct Place {
> 	1: required string name;
> 	2: required Point location;
> 	3: optional Review review;
> }
> If I create a Place object and set the location field to a Review, it will serialize no problem.
> place = Place(name="avi's place", location=Review(rating=1.0))
> transportOut = TTransport.TMemoryBuffer()
> protocolOut = TBinaryProtocol.TBinaryProtocol(transportOut)
> place.write(protocolOut)
> serialized = transportOut.getvalue()
> This is confusing because if I set an i32 field to a string serialization does raise an error.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (THRIFT-1772) Serialization does not check types of embedded structures.

Posted by "Avi Flamholz (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/THRIFT-1772?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Avi Flamholz updated THRIFT-1772:
---------------------------------

    Patch Info: Patch Available

I have a patch file. Not sure how to upload it. It adds an assert to .write() that checks the type. However, it does not work for the fastbinary protocol, which short-circuits the Python write() method.
                
> Serialization does not check types of embedded structures.
> ----------------------------------------------------------
>
>                 Key: THRIFT-1772
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1772
>             Project: Thrift
>          Issue Type: Bug
>          Components: Python - Library
>    Affects Versions: 0.8, 0.9
>            Reporter: Avi Flamholz
>
> Consider the following struct definitions:
> struct Point {
> 	1: required double x;
> 	2: required double y;
> }
> struct Review {
> 	1: required i32 rating;
> 	2: optional string text;
> }
> struct Place {
> 	1: required string name;
> 	2: required Point location;
> 	3: optional Review review;
> }
> If I create a Place object and set the location field to a Review, it will serialize no problem.
> place = Place(name="avi's place", location=Review(rating=1.0))
> transportOut = TTransport.TMemoryBuffer()
> protocolOut = TBinaryProtocol.TBinaryProtocol(transportOut)
> place.write(protocolOut)
> serialized = transportOut.getvalue()
> This is confusing because if I set an i32 field to a string serialization does raise an error.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira