Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(context): check handler is nil #3413

Merged
merged 4 commits into from May 13, 2024
Merged

Conversation

hktalent
Copy link
Contributor

@hktalent hktalent commented Nov 23, 2022

fix #3404

context.go Outdated
@@ -141,7 +141,9 @@ func (c *Context) HandlerName() string {
func (c *Context) HandlerNames() []string {
hn := make([]string, 0, len(c.handlers))
for _, val := range c.handlers {
hn = append(hn, nameOfFunction(val))
if nil != val {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if val != nil

context.go Outdated Show resolved Hide resolved
@appleboy
Copy link
Member

appleboy commented Dec 1, 2022

Please also add some testing.

@appleboy appleboy added the bug label Dec 1, 2022
@appleboy appleboy added this to the v1.9 milestone Dec 1, 2022
@appleboy appleboy changed the title fixed #3404 2022-11-23 fix(variable): check is nil #3404 Dec 1, 2022
@codecov
Copy link

codecov bot commented Dec 1, 2022

Codecov Report

Attention: Patch coverage is 50.00000% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 99.05%. Comparing base (3dc1cd6) to head (b7e326d).
Report is 56 commits behind head on master.

Files Patch % Lines
context.go 50.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3413      +/-   ##
==========================================
- Coverage   99.21%   99.05%   -0.16%     
==========================================
  Files          42       44       +2     
  Lines        3182     2751     -431     
==========================================
- Hits         3157     2725     -432     
+ Misses         17       15       -2     
- Partials        8       11       +3     
Flag Coverage Δ
?
-tags "sonic avx" 99.04% <50.00%> (?)
-tags go_json 99.04% <50.00%> (?)
-tags nomsgpack 99.03% <50.00%> (?)
go-1.18 ?
go-1.19 ?
go-1.20 ?
go-1.21 99.05% <50.00%> (-0.16%) ⬇️
go-1.22 99.05% <50.00%> (?)
macos-latest 99.04% <50.00%> (-0.17%) ⬇️
ubuntu-latest 99.05% <50.00%> (-0.16%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@thinkerou thinkerou modified the milestones: v1.9, v1.10 Jan 17, 2023
@appleboy
Copy link
Member

@hktalent Any updates?

@appleboy appleboy modified the milestones: v1.10, v1.11 Mar 22, 2024
@appleboy appleboy changed the title fix(variable): check is nil #3404 fix(context): check is nil #3404 May 13, 2024
hktalent and others added 3 commits May 13, 2024 13:38
- Refactor nil checks to improve readability in `context.go`
- Modify the control flow in `HandlerNames` and `Next` methods to continue on nil values before appending or invoking handlers in `context.go`

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
appleboy
appleboy previously approved these changes May 13, 2024
- Insert a `nil` value into the `HandlersChain` array in `context_test.go`
- Remove empty test functions in `context_test.go`

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
@appleboy appleboy changed the title fix(context): check is nil #3404 fix(context): check handler is nil May 13, 2024
@appleboy appleboy merged commit 36b0ded into gin-gonic:master May 13, 2024
23 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

what happened? /github.com/gin-gonic/gin/context.go:173 (0x47f51d3) (*Context).Next: c.handlers[c.index](c)
3 participants