Merged 5.0.N (5.0.3) to 5.1.N (5.1.1)

112968 mrogers: Merged V4.2-BUG-FIX (4.2.6) to 5.0.N (5.0.3)
      112583: MNT-14817 - Alfresco keeps file handlers on deleted temporary files created by CIFSContentComparator


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.1.N/root@113042 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2015-09-24 20:03:57 +00:00
parent 3f9ad58202
commit dfe03d979b
2 changed files with 97 additions and 24 deletions

View File

@@ -171,6 +171,7 @@ public class CIFSContentComparator implements ContentComparator
* Use POI to compare the content of the MPP file, exluding certain properties
*/
InputStream leftIs = null;
try
{
Collection<String> excludes = new HashSet<String>();
@@ -179,10 +180,35 @@ public class CIFSContentComparator implements ContentComparator
excludes.add("Props9");
leftIs = existingContent.getContentInputStream();
NPOIFSFileSystem fs1 = new NPOIFSFileSystem(leftIs);
NPOIFSFileSystem fs2 = new NPOIFSFileSystem(newFile);
return isContentIdentical(fs1, fs2, excludes);
// this call guarantees that leftIs is closed.
NPOIFSFileSystem fs2 = new NPOIFSFileSystem(leftIs);
// this call keeps an open file handle and needs closing.
NPOIFSFileSystem fs1 = new NPOIFSFileSystem(newFile);
try
{
return isContentIdentical(fs1, fs2, excludes);
}
finally
{
try
{
fs1.close();
}
catch (IOException e)
{
// ignore
}
try
{
fs2.close();
}
catch (IOException e)
{
// ignore
}
}
}
catch (ContentIOException ce)
{
@@ -252,8 +278,24 @@ public class CIFSContentComparator implements ContentComparator
wb1.writeProtectWorkbook("", "CIFSContentComparator");
wb2.writeProtectWorkbook("", "CIFSContentComparator");
wb1.write(new FileOutputStream(tpm1));
wb2.write(new FileOutputStream(tpm2));
FileOutputStream os = new FileOutputStream(tpm1);
try
{
wb1.write(os);
}
finally
{
os.close();
}
FileOutputStream os2 = new FileOutputStream(tpm2);
try
{
wb2.write(os2);
}
finally
{
os2.close();
}
NPOIFSFileSystem fs1 = new NPOIFSFileSystem(tpm1);
NPOIFSFileSystem fs2 = new NPOIFSFileSystem(tpm2);
@@ -359,12 +401,40 @@ public class CIFSContentComparator implements ContentComparator
else
{
//make sure that nothing has been changed except lastEditUsername
tpm1 = TempFileProvider.createTempFile("CIFSContentComparator1", "ppt");
FileOutputStream os = new FileOutputStream(tpm1);
try
{
slideShow1.write(os);
}
finally
{
try
{
os.close();
}
catch (IOException ie)
{
// ignore
}
}
tpm2 = TempFileProvider.createTempFile("CIFSContentComparator2", "ppt");
slideShow1.write(new FileOutputStream(tpm1));
slideShow1.write(new FileOutputStream(tpm2));
FileOutputStream os2 = new FileOutputStream(tpm2);
try
{
slideShow2.write(os2);
}
finally
{
try
{
os2.close();
}
catch (IOException ie)
{
// ignore
}
}
NPOIFSFileSystem fs1 = new NPOIFSFileSystem(tpm1);
NPOIFSFileSystem fs2 = new NPOIFSFileSystem(tpm2);