SOLR-12290,SOLR-12391: Do not close any servlet streams and improve our servlet stream closing prevention code for users and devs.

This commit is contained in:
markrmiller 2018-06-02 00:16:28 -05:00
parent 4888adf08a
commit 1ff24bbb28
2 changed files with 5 additions and 3 deletions

View File

@ -242,7 +242,7 @@ Bug Fixes
non-boolean queries. (James Dyer)
* SOLR-12290: Do not close any servlet streams and improve our servlet stream closing prevention code for users
and devs. (Mark Miller)
and devs. (Mark Miller, janhoy, Andrzej Bialecki)
* SOLR-12293: Updates need to use their own connection pool to maintain connection reuse and prevent spurious
recoveries. (Mark Miller)

View File

@ -17,6 +17,7 @@
package org.apache.solr.servlet;
import org.apache.commons.io.IOUtils;
import org.apache.commons.io.output.CloseShieldOutputStream;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.solr.common.params.CommonParams;
@ -58,8 +59,8 @@ public final class LoadAdminUiServlet extends BaseSolrServlet {
response.setCharacterEncoding("UTF-8");
response.setContentType("text/html");
// Don't close this! - see SOLR-8933
out = new OutputStreamWriter(response.getOutputStream(), StandardCharsets.UTF_8);
// We have to close this to flush OutputStreamWriter buffer
out = new OutputStreamWriter(new CloseShieldOutputStream(response.getOutputStream()), StandardCharsets.UTF_8);
String html = IOUtils.toString(in, "UTF-8");
Package pack = SolrCore.class.getPackage();
@ -78,6 +79,7 @@ public final class LoadAdminUiServlet extends BaseSolrServlet {
out.write( StringUtils.replaceEach(html, search, replace) );
} finally {
IOUtils.closeQuietly(in);
IOUtils.closeQuietly(out);
}
} else {
response.sendError(404);