Closed rsslldnphy closed 5 years ago
Thanks! Sorry for the delay, but Github doesn't seem to notify for changes to commits.
The commit message subject is now fine, but it looks like the rest of the commit message could use a little work. It could be more concise, needs to wrap at 72 characters, and because it's plaintext rather than markdown, backticks aren't used.
So perhaps instead:
Prevent 2nd call of handler on unhandled exception
Since version 9.4.12.v20180830, Jetty's AbstractCachingHandler calls
its handle method a second time when an exception is thrown. This
commit prevents Ring's handler function from being called twice as a
result of this change to Jetty.
no worries - updated
Merged. Thanks for the patch!
When this patch will be released?
Since version
9.4.12.v20180830
, Jetty'sAbstractCachingHandler
callshandle
a second time when an exception is thrown. This is so handlers can render custom error pages.However in
ring
this would normally be done elsewhere in middleware - so this causes the normal handler to be called a second time on unhandled error, which causes a duplication of any side-effects of the handler function.The second time
handle
is called, it's caled with aDispatcherType
ofDispatcherType/ERROR
- so this commit checks for thisDispatcherType
and skips calling the user's ring handler in this case. This leads to a generic Jetty error page being returned.Async handlers don't seem to be affected in the same way, so I haven't made the same change there, but I've added a test case so that if the same thing does start happening, it will be caught.
Fixes #364.