[
https://issues.apache.org/jira/browse/SLING-3743?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Joerg Hoh closed SLING-3743.
----------------------------
> BackgroundHttpServletResponse don't flushes the Writer
> ------------------------------------------------------
>
> Key: SLING-3743
> URL: https://issues.apache.org/jira/browse/SLING-3743
> Project: Sling
> Issue Type: Bug
> Reporter: Alexander Berndt
> Priority: Minor
> Labels: easyfix, good-first-issue
> Original Estimate: 2h
> Remaining Estimate: 2h
>
> A sling servlet request can be run as a background service, while appending a
> ?sling:bg=true to the request. This is done in the
> BackgroundServletStarterFilter.
> Unfortunatily this doesn't work for servlets, that use request.getWriter() to
> create the output. The provided BackgroundHttpServletResponse provides also a
> writer, but this isn't flushed during the clean-up.
> So the current code:
> public BackgroundHttpServletResponse(HttpServletResponse hsr, OutputStream os)
> throws IOException {
> stream = new ServletOutputStreamWrapper(os);
> writer = new PrintWriter(new OutputStreamWriter(stream));
> }
> public void cleanup() throws IOException {
> stream.flush();
> stream.close();
> }
> should be changed to:
> public void cleanup() throws IOException {
> writer.flush();
> writer.close();
> }
> as the writer also flushes and closes the underlying stream.
> kind regards,
> Alexander Berndt
--
This message was sent by Atlassian Jira
(v8.20.1#820001)