You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Mikhail Khludnev (JIRA)" <ji...@apache.org> on 2019/07/23 22:31:00 UTC

[jira] [Comment Edited] (SOLR-13545) ContentStreamUpdateRequest no longer closes stream

    [ https://issues.apache.org/jira/browse/SOLR-13545?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16891423#comment-16891423 ] 

Mikhail Khludnev edited comment on SOLR-13545 at 7/23/19 10:30 PM:
-------------------------------------------------------------------

Reproduced for me on branch_8x. I'll check it tomorrow.  
{{ant test  -Dtestcase=BasicAuthIntegrationTest -Dtests.method=testBasicAuth -Dtests.seed=B292FDDCA6F4D6F2 -Dtests.multiplier=3 -Dtests.slow=true -Dtests.locale=et-EE -Dtests.timezone=Pacific/Easter -Dtests.asserts=true -Dtests.file.encoding=US-ASCII}}


was (Author: mkhludnev):
Reproduced for me. I'll check it tomorrow.  

> ContentStreamUpdateRequest no longer closes stream
> --------------------------------------------------
>
>                 Key: SOLR-13545
>                 URL: https://issues.apache.org/jira/browse/SOLR-13545
>             Project: Solr
>          Issue Type: Bug
>      Security Level: Public(Default Security Level. Issues are Public) 
>          Components: SolrJ
>    Affects Versions: 7.4, 7.5, 7.6, 7.7, 7.7.1, 7.7.2, 8.0, 8.1, 8.1.1
>         Environment: Windows - file locking may not cause a visible failure on Linux?
>            Reporter: Colvin Cowie
>            Priority: Major
>             Fix For: 8.2
>
>         Attachments: ContentStreamUpdateRequestBug.java, SOLR-13545.patch, SOLR-13545.patch, SOLR-13545.patch
>
>          Time Spent: 1h 20m
>  Remaining Estimate: 0h
>
> 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.
>  
> {code:java}
> @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();
>       }
>     };
>   }
> {code}
> 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.
>  
> {code:java}
>       @Override
>       public void write(OutputStream os) throws IOException {
>           final InputStream innerStream = stream.getStream();
>           try {
>             IOUtils.copy(innerStream, os);
>           } finally {
>             IOUtils.closeQuietly(innerStream);
>           }
>       }
> {code}
>  
> I don't know whether any other streaming classes have similar issues
>  
>  



--
This message was sent by Atlassian JIRA
(v7.6.14#76016)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org