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

Go handler function panics on internal error

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 0.9.2
    • Fix Version/s: 0.9.2
    • Component/s: Go - Compiler
    • Labels:
      None
    • Environment:

      All

    • Patch Info:
      Patch Available

      Description

      The Go compiler is using the wrong err variable when handling an internal error in a handler method. Tested on fd62df75fa17d5c2af12302de6cee78ad7405692.

      The relevant generated code looks like this:

      var err2 error
      if result.Success, err2 = p.handler.RemoveBatchBySource(args.SourceId, args.SourceSystem, args.SourceType, args.UserId); err2 != nil {
      	x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing removeBatchBySource: "+err.Error())
      	oprot.WriteMessageBegin("removeBatchBySource", thrift.EXCEPTION, seqId)
      	x.Write(oprot)
      	oprot.WriteMessageEnd()
      	oprot.Flush()
      	return false, err2
      }
      

      The error in the TApplicationException should be err2.Error() and not err.Error(). Since err is nil at that point the server panics.

      The patch for the Go compiler is a simple one line fix is attached.

        Attachments

        1. THRIFT-2418.patch
          1.0 kB
          Frank Schroeder

          Activity

            People

            • Assignee:
              jensg Jens Geyer
              Reporter:
              magiconair Frank Schroeder
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

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