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

vinoyang commented on FLINK-11261:
----------------------------------

Hi [~Zentol] what do you think of this changing?
{code:java}
try (FileOutputStream fos = new FileOutputStream(incomingFile)) {
   // read stream
   byte[] buf = new byte[BUFFER_SIZE];
   while (true) {
      final int bytesRead = inputStream.read(buf);
      if (bytesRead == -1) {
         // done
         break;
      }
      fos.write(buf, 0, bytesRead);
      md.update(buf, 0, bytesRead);
   }
} finally {
   try {
      blobKey = moveTempFileToStore(incomingFile, jobId, md.digest(), blobType);

      return blobKey;
   } finally {
      // delete incomingFile from a failed download
      if (!incomingFile.delete() && incomingFile.exists()) {
         LOG.warn("Could not delete the staging file {} for blob key {} and job 
{}.",
            incomingFile, blobKey, jobId);
      }
   }
}
{code}
 

> BlobServer moves file with open OutputStream
> --------------------------------------------
>
>                 Key: FLINK-11261
>                 URL: https://issues.apache.org/jira/browse/FLINK-11261
>             Project: Flink
>          Issue Type: Bug
>          Components: Runtime / Operators
>    Affects Versions: 1.8.0
>            Reporter: Chesnay Schepler
>            Assignee: vinoyang
>            Priority: Major
>             Fix For: 1.8.0
>
>
> Various tests fail on Windows because the BlobServer attempts to move a file 
> while a {{FileOutputStream}} is still open:
> BlobServer#putInputStream():
> {code}
> try (FileOutputStream fos = new FileOutputStream(incomingFile)) {
>       [ ... use fos ... ]
>       // moves file even though fos is still open
>       blobKey = moveTempFileToStore(incomingFile, jobId, md.digest(), 
> blobType);
>       return blobKey;
> } finally {
>       ...
> }
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to