Copilot commented on code in PR #13369:
URL: https://github.com/apache/apisix/pull/13369#discussion_r3233479245
##########
apisix/control/router.lua:
##########
@@ -190,10 +189,12 @@ function _M.match(uri)
cached_version = plugin_mod.load_times
end
- core.table.clear(match_opts)
+ local match_opts = core.tablepool.fetch("control_router_match_opts", 0, 4)
match_opts.method = get_method()
- return router:dispatch(uri, match_opts)
+ local ok = router:dispatch(uri, match_opts)
+ core.tablepool.release("control_router_match_opts", match_opts)
+ return ok
Review Comment:
`router:dispatch(...)` commonly returns multiple values (e.g., match result
+ error). Capturing only `ok` and returning it drops any additional return
values that callers may rely on, changing behavior versus `return
router:dispatch(...)`. Preserve all return values (e.g., capture `ok, err,
...`, release the table, then return the full tuple).
##########
apisix/api_router.lua:
##########
@@ -105,10 +104,11 @@ function _M.match(api_ctx)
return false
end
- core.table.clear(match_opts)
+ local match_opts = core.tablepool.fetch("api_router_match_opts", 0, 4)
match_opts.method = api_ctx.var.request_method
local ok = api_router:dispatch(api_ctx.var.uri, match_opts, api_ctx)
+ core.tablepool.release("api_router_match_opts", match_opts)
return ok
Review Comment:
Similar to the control router change, this captures and returns only the
first return value from `api_router:dispatch(...)`. If `dispatch` returns
additional values (like an error), they will be silently dropped. Capture all
return values, release `match_opts`, and return the full set to preserve the
previous API/behavior.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]