Merged 5.2.N (5.2.1) to HEAD (5.2)

125775 rmunteanu: Merged 5.1.N (5.1.2) to 5.2.N (5.2.1)
      125593 mward: ACE-5052: close stream


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@127802 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2016-06-03 16:11:53 +00:00
parent 6310574263
commit a1f642e420

View File

@@ -123,9 +123,12 @@ public class FileWipingContentCleanerListener implements ContentStoreCleanerList
throw new ContentIOException("Unable to write to file: " + file);
}
long bytes = file.length();
OutputStream os = new BufferedOutputStream(new FileOutputStream(file));
OutputStream fos = null;
OutputStream bos = null;
try
{
fos = new FileOutputStream(file);
bos = new BufferedOutputStream(fos);
/*
* There are many more efficient ways of writing bytes into the file.
* However, it is likely that implementations will do a lot more than
@@ -133,12 +136,19 @@ public class FileWipingContentCleanerListener implements ContentStoreCleanerList
*/
for (int i = 0; i < bytes; i++)
{
os.write(0);
bos.write(0);
}
}
finally
{
try {os.close(); } catch (Throwable e) {}
if (bos != null)
{
try {bos.close(); } catch (Throwable e) {}
}
if (fos != null)
{
fos.close();
}
}
}
}