You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Joerg Hoh (Jira)" <ji...@apache.org> on 2022/02/07 10:19:00 UTC
[jira] [Resolved] (SLING-3743) BackgroundHttpServletResponse don't flushes the Writer
[ https://issues.apache.org/jira/browse/SLING-3743?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Joerg Hoh resolved SLING-3743.
------------------------------
Resolution: Won't Fix
Closing as won't fix, because the bgservlets bundle is no longer maintained.
> 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)