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

cached response status #1115

Open WebSabaki opened 5 years ago

WebSabaki commented 5 years ago

Good afternoon.

I am progressively refactoring some old code (so issues is on my side) but I found a strange behavior: sometimes, it seems that spark keep a previously assigned response code as in

response.status(500);
... do something
response.status(200);
return something

may returns an empty message and an error status 500.

I compiled with version 2.8.0 and still faced this issue. Why is that? latest status code shall be the correct one.

For instance, having a per default code to 200 and then assigning another code in case of failure would be a "correct" setup but because of the above, code 200 may still be returned when an error occurred.

Note : I faced this behavior at least when response.status() is called two times in same function.