perwendel / spark

A simple expressive web framework for java. Spark has a kotlin DSL https://github.com/perwendel/spark-kotlin
Apache License 2.0
9.63k stars 1.56k forks source link

Servlet exception mapper cleanup #1213

Open sukolenvo opened 3 years ago

sukolenvo commented 3 years ago

Spark servlet exception mapper is not cleaned after server stopped. I've created a test to illustrate issue we are facing: https://github.com/perwendel/spark/compare/master...sukolenvo:test-servlet-clean

Here you can see I am starting server foo, stopping it, and starting another server bar. Although server foo was stopped, error handler is still returning foo.

I suggest to add something like ExceptionMapper.getServletInstance().clear() to SparkFilter.destory()

Can open PR for test and/or fix if needed.