-
Notifications
You must be signed in to change notification settings - Fork 8.1k
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.Next() - recheck len of handlers every iteration #1745
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
@@ -105,7 +105,7 @@ func (c *Context) Handler() HandlerFunc { | |||
// See example in GitHub. | |||
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
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.index
and.handlers
then 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.handlers
when error on open file.gin/routergroup.go
Lines 195 to 202 in 29a145c
Fix #1744, because gin reset
c.handlers
slice onHandleContext()
func.gin/gin.go
Lines 354 to 360 in 29a145c
gin/context.go
Lines 67 to 75 in 29a145c