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.64k stars 1.56k forks source link

Ensure InputStreams returned by Routes are closed #978

Closed thomaslee closed 3 years ago

thomaslee commented 6 years ago

Howdy -- we ran into a situation where resources could be leaked when returning InputStreams from Route.handle(). Proposed patch below, happy to hook up tests if the approach looks reasonable.

perwendel commented 5 years ago

@thomaslee Thanks for commiting. I've myself never returned InputStreams from a Route. Is it conceivable that the serializer handling the inputstream would be responsible for closing the stream?

ThatJoeMoore commented 5 years ago

We ran into this today, so I created #1121, which incorporates this feedback.