From f3339d73130fbd3c48bc3198aef5ce5e07159cef Mon Sep 17 00:00:00 2001 From: Boris Bendyukov Date: Tue, 14 Jan 2014 06:36:04 +0000 Subject: [PATCH 2/2] InboundMessageProcessor.java edited online with Bitbucket --- .../com/sun/jbi/filebc/InboundMessageProcessor.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/ojc-core/filebc/filebcimpl/src/com/sun/jbi/filebc/InboundMessageProcessor.java b/ojc-core/filebc/filebcimpl/src/com/sun/jbi/filebc/InboundMessageProcessor.java index 3b36c92af..b0076ed6c 100755 --- a/ojc-core/filebc/filebcimpl/src/com/sun/jbi/filebc/InboundMessageProcessor.java +++ b/ojc-core/filebc/filebcimpl/src/com/sun/jbi/filebc/InboundMessageProcessor.java @@ -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; }