Send Spring response stream immediately rather than wait until method return
<p>I have a request mapping that looks like this:</p>

<pre><code>private final static byte[] byteArray = ...;

@RequestMapping(value=Array("/foobar"))
void sendByteArray(@RequestBody Request request, OutputStream os) {
  os.write(byteArray);
  os.flush();
  doLengthyCleanup();
}
</code></pre>

<p>I'm finding that the request client does not actually receive the response body until after the service has completed <code>doLengthyCleanup()</code>.</p>

<p>Since the cleanup doesn't affect the response itself, I'd like to improve my response time by performing the cleanup <strong>after</strong> sending the response. How can I do this?</p>