InboundMessageProcessor.java edited online with Bitbucket

master
Boris Bendyukov 2014-01-14 06:36:04 +00:00
parent 5371d17e3b
commit f3339d7313
1 changed files with 11 additions and 2 deletions

View File

@ -383,7 +383,7 @@ public class InboundMessageProcessor implements Runnable, MessageExchangeReplyLi
*/
private FileLock acquireLockOnTargetDir(/*FileAddress fileAddress, File inDir*/)
throws IOException, FileNotFoundException {
FileLock fLock;
FileLock fLock = null;
// we are the only thread on this process entered this area
// further lock the physical target directory
//File lockFile = new File(inDir, fileAddress.getLockName());
@ -396,7 +396,16 @@ public class InboundMessageProcessor implements Runnable, MessageExchangeReplyLi
FileOutputStream fos = new FileOutputStream(lockFile);
mLock.setChannel(channel = fos.getChannel());
}
fLock = channel.tryLock();
try {
fLock = channel.tryLock();
} catch (IOException e) {
if (mLogger.isLoggable(Level.WARNING)) {
mLogger.log(Level.WARNING, "Exception caught when trying to lock file for inbound target: " + lockFile.getName() + ", destination file :" + mLock.getLockFilePath() + ". Trying to recreate. Exception: " + e.getMessage());
}
FileOutputStream fos = new FileOutputStream(lockFile);
mLock.setChannel(channel = fos.getChannel());
if (fLock == null) fLock = channel.tryLock();
}
return fLock;
}