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

Recover middleware should not log panic for aborted handler (fix #2133) #2134

Merged
merged 1 commit into from Mar 15, 2022

Conversation

bbasic
Copy link
Contributor

@bbasic bbasic commented Mar 15, 2022

This is the fix for the issue #2133

The fix is in explicit check in recover middleware defer function to re-throw (panic) the http.ErrAbortHandler error.

This specific error is recovered in net/http/server.go and per default ignored for logging.
https://github.com/golang/go/blob/88be85f18bf0244a2470fdf6719e1b5ca5a5e50a/src/net/http/server.go#L1799

@codecov
Copy link

codecov bot commented Mar 15, 2022

Codecov Report

Merging #2134 (7f2e32b) into master (b445958) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2134   +/-   ##
=======================================
  Coverage   92.10%   92.11%           
=======================================
  Files          37       37           
  Lines        3028     3030    +2     
=======================================
+ Hits         2789     2791    +2     
  Misses        150      150           
  Partials       89       89           
Impacted Files Coverage Δ
middleware/recover.go 85.00% <100.00%> (+0.78%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b445958...7f2e32b. Read the comment docs.

Copy link
Contributor

@aldas aldas left a comment

Choose a reason for hiding this comment

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

LGTM

@aldas aldas requested a review from lammel March 15, 2022 19:11
@aldas
Copy link
Contributor

aldas commented Mar 15, 2022

@lammel please review

Copy link
Contributor

@lammel lammel left a comment

Choose a reason for hiding this comment

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

Also looks good to me.
I think an end2end test is nice to have, but not really required, so let's merge.

@lammel lammel merged commit 5c38c3b into labstack:master Mar 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants