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

Namespace from type is ignored in generated code

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 0.14.0
    • 0.15.0, 0.14.1
    • Go - Compiler
    • None

    Description

      When using the Go compiler 0.14 with the Thrift spec below, the generated function does not use the namespace, causing compilation issues.

       

      
      include "jaeger.thrift"
      include "zipkincore.thrift"
      
      namespace cpp jaegertracing.agent.thrift
      namespace java io.jaegertracing.agent.thrift
      namespace php Jaeger.Thrift.Agent
      namespace netstd Jaeger.Thrift.Agent
      namespace lua jaeger.thrift.agent
      
      service Agent {
          oneway void emitZipkinBatch(1: list<zipkincore.Span> spans)
          oneway void emitBatch(1: jaeger.Batch batch)
      }
      
       

      Here's an excerpt of the generated Go code for this service:

      
      // Code generated by Thrift Compiler (0.14.0). DO NOT EDIT.
      
      package agent
      
      import(
      	"bytes"
      	"context"
      	"fmt"
      	"time"
      	"github.com/apache/thrift/lib/go/thrift"
      	"github.com/jaegertracing/jaeger/thrift-gen/jaeger"
      
      )
      
      // (needed to ensure safety because of naive import list construction.)
      var _ = thrift.ZERO
      var _ = fmt.Printf
      var _ = context.Background
      var _ = time.Now
      var _ = bytes.Equal
      
      var _ = jaeger.GoUnusedProtection__
      type Agent interface {
        // Parameters:
        //  - Spans
        EmitZipkinBatch(ctx context.Context, spans []*Span) (err error)
        // Parameters:
        //  - Batch
        EmitBatch(ctx context.Context, batch *jaeger.Batch) (err error)
      }
      
      

      In previous versions like 0.13, this is how the generated code looks like:

      
      // Autogenerated by Thrift Compiler (0.13.0)
      // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
      
      package agent
      
      import(
      	"bytes"
      	"context"
      	"reflect"
      	"fmt"
      	"github.com/apache/thrift/lib/go/thrift"
      	"github.com/jaegertracing/jaeger/thrift-gen/jaeger"
      	"github.com/jaegertracing/jaeger/thrift-gen/zipkincore"
      
      )
      
      // (needed to ensure safety because of naive import list construction.)
      var _ = thrift.ZERO
      var _ = fmt.Printf
      var _ = context.Background
      var _ = reflect.DeepEqual
      var _ = bytes.Equal
      
      var _ = jaeger.GoUnusedProtection__
      var _ = zipkincore.GoUnusedProtection__
      type Agent interface {
        // Parameters:
        //  - Spans
        EmitZipkinBatch(ctx context.Context, spans []*zipkincore.Span) (err error)
        // Parameters:
        //  - Batch
        EmitBatch(ctx context.Context, batch *jaeger.Batch) (err error)
      }
      
      

      Attachments

        Issue Links

          Activity

            People

              fishywang Yuxuan Wang
              jpkroehling Juraci Paixão Kröhling
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 0.5h
                  0.5h