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

Lua library leaks 43 globals due to lack of module encapsulation

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 0.10.0
    • None
    • Lua - Library
    • None

    Description

      The Lua library defines or clobbers global variables, due to its lack of module encapsulation, making it an intrusive library that is atypically difficult to get working in my application context, and unnecessarily lowering its likelihood of working in other environments with diverse dependencies.

      Ideally callers would access resources like this:

      local TCompactProtocol = require 'Thrift'.TCompactProtocol
      

      And the Thrift library would publish them like this:

      -- Thrift.lua
      
      local M = {}
      M.ttype = function(obj) ...
      M.terror = function(e) ...
      M.version = 0.10
      M.TType = ...
      M.__TObject = ...
      M.TProtocolBase = ...
      M.TCompactProtocol = M.__TObject.new(M.TProtocolBase, {...
      return M
      

      The source codes should survive a check like this:

      $ luacheck --std max+busted --codes src/lua test/lua --no-self --ignore 213 311 611 631
      

      Globals:

      1. __TClient
      2. __tobj_index
      3. __TObject
      4. __TProcessor
      5. base64_encode
      6. ch
      7. client
      8. CompactTypeToTType
      9. EscapeCharVals
      10. JSONCharTable
      11. JSONNode
      12. libluabitwise
      13. libluabpack
      14. liblualongnumber
      15. StringToTType
      16. TBinaryProtocol
      17. TBinaryProtocolFactory
      18. TBufferedTransport
      19. TCompactProtocol
      20. TCompactType
      21. terror
      22. TException
      23. TFramedTransport
      24. TFramedTransportFactory
      25. thrift_print_r
      26. THttpTransport
      27. THttpTransportFactory
      28. TJSONProtocol
      29. TMemoryBuffer
      30. TMessageType
      31. TProtocolBase
      32. TProtocolException
      33. TServer
      34. TSimpleServer
      35. ttable_size
      36. TTransportBase
      37. TTransportException
      38. TTransportFactoryBase
      39. ttype
      40. TType
      41. TTypeToCompactType
      42. TTypeToString
      43. version

      Attachments

        Activity

          People

            Unassigned Unassigned
            drauschenbach David Rauschenbach
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: