forked from organicmaps/organicmaps
Fixed possible memory leak ZipLogsTask
If an exception would be thrown, the streams would not be closed. The use-try-with-resources will close the resources. Therefore, the `out.close()` has also become unnecessary.
This commit is contained in:
parent
7086d14316
commit
bebc958510
1 changed files with 3 additions and 4 deletions
|
@ -55,11 +55,11 @@ class ZipLogsTask implements Runnable
|
|||
private boolean zipFileAtPath(@NonNull String sourcePath, @NonNull String toLocation)
|
||||
{
|
||||
File sourceFile = new File(sourcePath);
|
||||
try
|
||||
try(FileOutputStream dest = new FileOutputStream(toLocation, false);
|
||||
ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(dest)))
|
||||
{
|
||||
BufferedInputStream origin;
|
||||
FileOutputStream dest = new FileOutputStream(toLocation, false);
|
||||
ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(dest));
|
||||
|
||||
if (sourceFile.isDirectory())
|
||||
{
|
||||
zipSubFolder(out, sourceFile, sourceFile.getParent().length());
|
||||
|
@ -77,7 +77,6 @@ class ZipLogsTask implements Runnable
|
|||
out.write(data, 0, count);
|
||||
}
|
||||
}
|
||||
out.close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue