camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [1/2] git commit: CAMEL-6750: Fixed readLock=fileLock&delete=true for file consumer not being able to delete file on Windows.
Date Mon, 16 Sep 2013 15:36:17 GMT
Updated Branches:
  refs/heads/camel-2.12.x a971b79da -> 6a5fbc126
  refs/heads/master 302133ed3 -> 4737cc841


CAMEL-6750: Fixed readLock=fileLock&delete=true for file consumer not being able to delete
file on Windows.


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

Branch: refs/heads/master
Commit: 4737cc84150397a841210ac5b511c09b33835adc
Parents: 302133e
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Mon Sep 16 17:00:35 2013 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Mon Sep 16 17:01:20 2013 +0200

----------------------------------------------------------------------
 .../file/strategy/GenericFileDeleteProcessStrategy.java   | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/4737cc84/camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileDeleteProcessStrategy.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileDeleteProcessStrategy.java
b/camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileDeleteProcessStrategy.java
index b2ccb8e..524363f 100644
--- a/camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileDeleteProcessStrategy.java
+++ b/camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileDeleteProcessStrategy.java
@@ -50,6 +50,14 @@ public class GenericFileDeleteProcessStrategy<T> extends GenericFileProcessStrat
 
     @Override
     public void commit(GenericFileOperations<T> operations, GenericFileEndpoint<T>
endpoint, Exchange exchange, GenericFile<T> file) throws Exception {
+
+        // special for file lock strategy as we must release that lock first before we can
delete the file
+        boolean releaseEager = exclusiveReadLockStrategy instanceof FileLockExclusiveReadLockStrategy;
+
+        if (releaseEager) {
+            exclusiveReadLockStrategy.releaseExclusiveReadLock(operations, file, exchange);
+        }
+
         try {
             deleteLocalWorkFile(exchange);
             operations.releaseRetreivedFileResources(exchange);
@@ -82,7 +90,7 @@ public class GenericFileDeleteProcessStrategy<T> extends GenericFileProcessStrat
             }
         } finally {
             // must release lock last
-            if (exclusiveReadLockStrategy != null) {
+            if (!releaseEager && exclusiveReadLockStrategy != null) {
                 exclusiveReadLockStrategy.releaseExclusiveReadLock(operations, file, exchange);
             }
         }


Mime
View raw message