Repository: camel Updated Branches: refs/heads/camel-2.16.x 9ef8327e7 -> 7bc1957e3
[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/7bc1957e Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/7bc1957e Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/7bc1957e Branch: refs/heads/camel-2.16.x Commit: 7bc1957e37daad6c7f81a5abf0f679a2480cb790 Parents: 9ef8327 Author: apoltavt...@gmail.com <apoltavt...@gmail.com> Authored: Tue Nov 22 15:39:11 2016 +0300 Committer: Christian Schneider <ch...@die-schneider.net> Committed: Wed Nov 23 13:51:33 2016 +0100 ---------------------------------------------------------------------- .../GenericFileRenameExclusiveReadLockStrategy.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/7bc1957e/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