Details
Description
Since the change made in SOLR-12142 ContentStreamUpdateRequest no longer closes the stream that it opens. Therefore if streaming a file, it cannot be deleted until the process exits.
@Override public RequestWriter.ContentWriter getContentWriter(String expectedType) { if (contentStreams == null || contentStreams.isEmpty() || contentStreams.size() > 1) return null; ContentStream stream = contentStreams.get(0); return new RequestWriter.ContentWriter() { @Override public void write(OutputStream os) throws IOException { IOUtils.copy(stream.getStream(), os); } @Override public String getContentType() { return stream.getContentType(); } }; }
IOUtils.copy will not close the stream. Adding a close to the write(), is enough to "fix" it for the test case I've attached, e.g.
@Override public void write(OutputStream os) throws IOException { final InputStream innerStream = stream.getStream(); try { IOUtils.copy(innerStream, os); } finally { IOUtils.closeQuietly(innerStream); } }
I don't know whether any other streaming classes have similar issues
Attachments
Attachments
Issue Links
- is caused by
-
SOLR-12142 EmbeddedSolrServer should use req.getContentWriter
- Closed
- links to