是否应在StreamingResponseBody中显式关闭OutputStream?

时间:2018-12-11 11:42:32

标签: java spring spring-mvc spring-rest spring-web

我正在StreamingResponseBody的春季使用@RestController流式传输大量外部资源。

问题:响应正文的OutputStream是否应在此处显式关闭?

@GetMapping("/{filename}")
public ResponseEntity<StreamingResponseBody> getFile(@PathVariable String filename) {
            StreamingResponseBody responseBody = outputStream -> {
                resolveExternally(outputStream, response, filename);

                //TODO should the stream be closed explicit here?
                //outputStream.close();
            };

            return ResponseEntity.ok(responseBody);
}

0 个答案:

没有答案