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

JavaScript: null values turn into empty structs in constructor

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    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

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

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

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment