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

Serialization does not check types of embedded structures.

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 0.8, 0.9
    • 0.9.2
    • Python - Library
    • Patch Available

    Description

      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.

      Attachments

        1. thrift-py-serialize-check-struct-type.patch
          5 kB
          Avi Flamholz
        2. THRIFT-1772.patch
          4 kB
          Henrique Mendonca

        Issue Links

          Activity

            People

              henrique Henrique Mendonca
              flamholz Avi Flamholz
              Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: