-
Notifications
You must be signed in to change notification settings - Fork 8.5k
fix Context.Next() - recheck len of handlers every iteration #1745
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1745 +/- ##
==========================================
+ Coverage 98.48% 98.48% +<.01%
==========================================
Files 41 41
Lines 2041 2042 +1
==========================================
+ Hits 2010 2011 +1
Misses 19 19
Partials 12 12
Continue to review full report at Codecov.
|
|
thanks @vkd can you add test case? |
context.go
Outdated
| func (c *Context) Next() { | ||
| c.index++ | ||
| for s := int8(len(c.handlers)); c.index < s; c.index++ { | ||
| for ; c.index < int8(len(c.handlers)); c.index++ { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use while style?
TestEngineHandleContext TestContextResetInHandler TestRouterStaticFSFileNotFound
thinkerou
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
If gin sometimes reset
Context.indexand.handlersthen needs to recheck len of handlers every iteration on funcContext.Next():gin/context.go
Lines 103 to 111 in 29a145c
Fix #1678, because gin change
c.handlerswhen error on open file.gin/routergroup.go
Lines 195 to 202 in 29a145c
Fix #1744, because gin reset
c.handlersslice onHandleContext()func.gin/gin.go
Lines 354 to 360 in 29a145c
gin/context.go
Lines 67 to 75 in 29a145c