ACE-5052: close file

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.1.N/root@125594 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Matt Ward
2016-04-19 15:37:34 +00:00
parent ef9fa5faf6
commit 83e8af3b96

View File

@@ -203,6 +203,7 @@ public class FileContentReader extends AbstractContentReader
@Override
protected ReadableByteChannel getDirectReadableChannel() throws ContentIOException
{
RandomAccessFile randomAccessFile = null;
try
{
// the file must exist
@@ -214,7 +215,7 @@ public class FileContentReader extends AbstractContentReader
ReadableByteChannel channel = null;
if (allowRandomAccess)
{
RandomAccessFile randomAccessFile = new RandomAccessFile(file, "r"); // won't create it
randomAccessFile = new RandomAccessFile(file, "r"); // won't create it
channel = randomAccessFile.getChannel();
}
else
@@ -235,6 +236,20 @@ public class FileContentReader extends AbstractContentReader
{
throw new ContentIOException("Failed to open file channel: " + this, e);
}
finally
{
if (randomAccessFile != null)
{
try
{
randomAccessFile.close();
}
catch (IOException e)
{
logger.error("Problem while closing file.", e);
}
}
}
}
/**