mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-15 15:02:20 +00:00
Merged 5.1.N (5.1.2) to 5.2.N (5.2.1)
125595 mward: ACE-5052: close file git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@125777 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -132,6 +132,7 @@ public class FileContentWriter extends AbstractContentWriter
|
|||||||
@Override
|
@Override
|
||||||
protected WritableByteChannel getDirectWritableChannel() throws ContentIOException
|
protected WritableByteChannel getDirectWritableChannel() throws ContentIOException
|
||||||
{
|
{
|
||||||
|
RandomAccessFile randomAccessFile = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// we may not write to an existing file - EVER!!
|
// we may not write to an existing file - EVER!!
|
||||||
@@ -143,7 +144,7 @@ public class FileContentWriter extends AbstractContentWriter
|
|||||||
WritableByteChannel channel = null;
|
WritableByteChannel channel = null;
|
||||||
if (allowRandomAccess)
|
if (allowRandomAccess)
|
||||||
{
|
{
|
||||||
RandomAccessFile randomAccessFile = new RandomAccessFile(file, "rw"); // will create it
|
randomAccessFile = new RandomAccessFile(file, "rw"); // will create it
|
||||||
channel = randomAccessFile.getChannel();
|
channel = randomAccessFile.getChannel();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -164,6 +165,20 @@ public class FileContentWriter extends AbstractContentWriter
|
|||||||
{
|
{
|
||||||
throw new ContentIOException("Failed to open file channel: " + this, e);
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user