You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2016/11/22 19:43:57 UTC

[2/3] camel git commit: [CAMEL-10505] FILE component - resolved FileNotFountException in Generic File Rename Exclusive Read Lock Strategy in case of work file is locked by another application

[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/d1a9f9fb
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/d1a9f9fb
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/d1a9f9fb

Branch: refs/heads/camel-2.18.x
Commit: d1a9f9fb0b65010b46ebe8e5bbbb4188975246ca
Parents: 4cc5bc0
Author: apoltavtsev@gmail.com <ap...@gmail.com>
Authored: Tue Nov 22 15:39:11 2016 +0300
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue Nov 22 20:43:23 2016 +0100

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


http://git-wip-us.apache.org/repos/asf/camel/blob/d1a9f9fb/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