You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "David Rauschenbach (JIRA)" <ji...@apache.org> on 2017/11/22 16:49:00 UTC

[jira] [Commented] (THRIFT-4391) Lua library leaks 43 globals due to lack of module encapsulation

    [ https://issues.apache.org/jira/browse/THRIFT-4391?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16262906#comment-16262906 ] 

David Rauschenbach commented on THRIFT-4391:
--------------------------------------------

Taking an initial stab at it here: https://github.com/BixData/lua-thrift

It passes luacheck tests, doesn't leak any globals, and Travis is verifying it on Lua 5.1, 5.2, 5.3, and LuaJIT 2.0 and 2.1.

If anyone knows how to port liblualongnumber from C to pure-Lua, help would be greatly appreciated! So far there is only a stub:

https://github.com/BixData/lua-thrift/blob/0.10.0/src/thrift/liblualongnumber.lua

> Lua library leaks 43 globals due to lack of module encapsulation
> ----------------------------------------------------------------
>
>                 Key: THRIFT-4391
>                 URL: https://issues.apache.org/jira/browse/THRIFT-4391
>             Project: Thrift
>          Issue Type: Bug
>          Components: Lua - Library
>    Affects Versions: 0.10.0
>            Reporter: David Rauschenbach
>
> 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:
> {code}
> local TCompactProtocol = require 'Thrift'.TCompactProtocol
> {code}
> And the Thrift library would publish them like this:
> {code}
> -- 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
> {code}
> The source codes should survive a check like this:
> {code}
> $ luacheck --std max+busted --codes src/lua test/lua --no-self --ignore 213 311 611 631
> {code}
> Globals:
> # __TClient
> # __tobj_index
> # __TObject
> # __TProcessor
> # base64_encode
> # ch
> # client
> # CompactTypeToTType
> # EscapeCharVals
> # JSONCharTable
> # JSONNode
> # libluabitwise
> # libluabpack
> # liblualongnumber
> # StringToTType
> # TBinaryProtocol
> # TBinaryProtocolFactory
> # TBufferedTransport
> # TCompactProtocol
> # TCompactType
> # terror
> # TException
> # TFramedTransport
> # TFramedTransportFactory
> # thrift_print_r
> # THttpTransport
> # THttpTransportFactory
> # TJSONProtocol
> # TMemoryBuffer
> # TMessageType
> # TProtocolBase
> # TProtocolException
> # TServer
> # TSimpleServer
> # ttable_size
> # TTransportBase
> # TTransportException
> # TTransportFactoryBase
> # ttype
> # TType
> # TTypeToCompactType
> # TTypeToString
> # version



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)