lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Colvin Cowie (JIRA)" <j...@apache.org>
Subject [jira] [Created] (SOLR-13545) ContentStreamUpdateRequest no longer closes stream
Date Thu, 13 Jun 2019 08:10:00 GMT
Colvin Cowie created SOLR-13545:
-----------------------------------

             Summary: 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: 8.1.1, 8.1, 8.0, 7.7.2, 7.7.1, 7.7, 7.6, 7.5, 7.4
         Environment: Windows - file locking may not cause a visible failure on Linux?
            Reporter: Colvin Cowie
         Attachments: ContentStreamUpdateRequestBug.java

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.3#76005)

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


Mime
View raw message