used cjson.safe instead of pcall.
This commit is contained in:
parent
d968ee9cfd
commit
1d37e83a18
4 changed files with 18 additions and 17 deletions
|
|
@ -1,5 +1,5 @@
|
|||
local ngx_balancer = require("ngx.balancer")
|
||||
local json = require("cjson")
|
||||
local cjson = require("cjson.safe")
|
||||
local util = require("util")
|
||||
local dns_util = require("util.dns")
|
||||
local configuration = require("configuration")
|
||||
|
|
@ -114,9 +114,9 @@ local function sync_backends()
|
|||
return
|
||||
end
|
||||
|
||||
local ok, new_backends = pcall(json.decode, backends_data)
|
||||
if not ok then
|
||||
ngx.log(ngx.ERR, "could not parse backends data: " .. tostring(new_backends))
|
||||
local new_backends, err = cjson.decode(backends_data)
|
||||
if not new_backends then
|
||||
ngx.log(ngx.ERR, "could not parse backends data: ", err)
|
||||
return
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue