Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close all the streams/files even if it is failed to close one stream/file #27

Open
rajubairishetti opened this issue Mar 7, 2014 · 0 comments
Assignees
Labels

Comments

@rajubairishetti
Copy link
Contributor

Code snippet (RetriableFileCopyCommand.java)

} finally {
      if (mustCloseStream) {
        IOUtils.cleanup(LOG, inStream);
        try {
          if (reader != null)
            reader.close();
          if (compressedIn != null)
            compressedIn.close();
          if (commpressedOut != null)
            commpressedOut.close();
          outStream.close();
        }
        catch(IOException exception) {
          LOG.error("Could not close output-stream. ", exception);
          throw exception;
        }
      }
    }

Currently, If we get any error/exception while closing reader then we are not closing the others outputstream, compressedin and compressedout after that.

Code snippet: (FileUtil.java)

finally {
      compressedOut.close();
      in.close();
      out.close();
      CodecPool.returnCompressor(gzipCompressor);

    }

we should close the reader as well and close all the stream separately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant