Repository: camel
Updated Branches:
  refs/heads/camel-2.17.x b43043757 -> b2b62d06b
  refs/heads/camel-2.18.x 4cc5bc065 -> d1a9f9fb0
  refs/heads/master 9615ed790 -> 8902592b3


[CAMEL-10505] FILE component - resolved FileNotFountException in Generic File 
Rename Exclusive Read Lock Strategy in case of work file is locked by another 
application


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/8902592b
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/8902592b
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/8902592b

Branch: refs/heads/master
Commit: 8902592b3361f6fb195e49669712fd34883640c4
Parents: 9615ed7
Author: apoltavt...@gmail.com <apoltavt...@gmail.com>
Authored: Tue Nov 22 15:39:11 2016 +0300
Committer: Claus Ibsen <davscl...@apache.org>
Committed: Tue Nov 22 20:05:43 2016 +0100

----------------------------------------------------------------------
 .../GenericFileRenameExclusiveReadLockStrategy.java    | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/8902592b/camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileRenameExclusiveReadLockStrategy.java
----------------------------------------------------------------------
diff --git 
a/camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileRenameExclusiveReadLockStrategy.java
 
b/camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileRenameExclusiveReadLockStrategy.java
index 976c965..ef5fdb1 100644
--- 
a/camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileRenameExclusiveReadLockStrategy.java
+++ 
b/camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileRenameExclusiveReadLockStrategy.java
@@ -16,11 +16,14 @@
  */
 package org.apache.camel.component.file.strategy;
 
+import java.io.FileNotFoundException;
+
 import org.apache.camel.Exchange;
 import org.apache.camel.LoggingLevel;
 import org.apache.camel.component.file.GenericFile;
 import org.apache.camel.component.file.GenericFileEndpoint;
 import org.apache.camel.component.file.GenericFileExclusiveReadLockStrategy;
+import org.apache.camel.component.file.GenericFileOperationFailedException;
 import org.apache.camel.component.file.GenericFileOperations;
 import org.apache.camel.util.CamelLogger;
 import org.apache.camel.util.StopWatch;
@@ -70,7 +73,15 @@ public class GenericFileRenameExclusiveReadLockStrategy<T> 
implements GenericFil
                 }
             }
 
-            exclusive = operations.renameFile(file.getAbsoluteFilePath(), 
newFile.getAbsoluteFilePath());
+            try {
+                exclusive = operations.renameFile(file.getAbsoluteFilePath(), 
newFile.getAbsoluteFilePath());
+            } catch (GenericFileOperationFailedException ex) {
+                if (ex.getCause() != null && ex.getCause() instanceof 
FileNotFoundException) {
+                    exclusive = false;
+                } else {
+                    throw ex;
+                }
+            }
             if (exclusive) {
                 LOG.trace("Acquired exclusive read lock to file: {}", file);
                 // rename it back so we can read it

Reply via email to