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

Assigning default ENUM values results in non-compilable java code if java namespace is not defined

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Pending Closed
    • 0.9.2
    • 0.9.3
    • Java - Compiler
    • None

    Description

      enumtest.thrift
      enum Color {
        BLACK = 5,
        WHITE = 6
      }
      
      struct Params {
        1: optional Color bColor = Color.BLACK;
      }
      

      Running thrift --gen java enumtest.thrift (thrift 0.9.2 on OSX 10.10.3)
      results in non-compilable java code.

        public Params() {
          this.bColor = .Color.BLACK;
      
        }
      
        @Override
        public void clear() {
          this.bColor = .Color.BLACK;
      
        }
      

      Notice the "." before Color.BLACK. If java namespace is defined in the thrift file, it works as expected.

      Attachments

        Issue Links

          Activity

            People

              AnnaDymek Anna Dymek
              thrift_2015 Pavan Chitumalla
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: