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

JavaScript: null values turn into empty structs in constructor

    XMLWordPrintableJSON

Details

    • Patch Available

    Description

      Given a struct definition with an optional struct field, e.g.

      struct Foo {
        1: Bar bar,
      }
      

      Trying to initialize it to a null value like

      new Foo({"bar": null});
      

      will instead set bar to an empty Bar object.

      This happens because the constructor tests for undefined values, but not for null.

      In addition to direct user calls, the internal copyList and copyMap functions introduced for THRIFT-3122 now often trigger this by initializing one object from another, making it hard to work around.

      Attachments

        1. thrift-3293-null-init.patch
          2 kB
          Håkon Hitland

        Activity

          People

            henrique Henrique Mendonca
            hakon Håkon Hitland
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: