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 2013/12/20 18:41:00 UTC
[1/3] git commit: CAMEL-7088: Close resources in file read lock.
Thanks to Leonid Marushevskiy for the patch.
Updated Branches:
refs/heads/camel-2.11.x c321cb881 -> 845732586
refs/heads/camel-2.12.x 5a3f2daca -> 0e3ed7f3d
refs/heads/master a2f600851 -> 8ad63b860
CAMEL-7088: Close resources in file read lock. Thanks to Leonid Marushevskiy for the patch.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/8ad63b86
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/8ad63b86
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/8ad63b86
Branch: refs/heads/master
Commit: 8ad63b86070909bbdf4ca45a8ebb2fd0602f5477
Parents: a2f6008
Author: Claus Ibsen <da...@apache.org>
Authored: Fri Dec 20 18:43:18 2013 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Fri Dec 20 18:43:18 2013 +0100
----------------------------------------------------------------------
.../file/strategy/FileLockExclusiveReadLockStrategy.java | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/8ad63b86/camel-core/src/main/java/org/apache/camel/component/file/strategy/FileLockExclusiveReadLockStrategy.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/file/strategy/FileLockExclusiveReadLockStrategy.java b/camel-core/src/main/java/org/apache/camel/component/file/strategy/FileLockExclusiveReadLockStrategy.java
index e229b5f..1d0c4d7 100644
--- a/camel-core/src/main/java/org/apache/camel/component/file/strategy/FileLockExclusiveReadLockStrategy.java
+++ b/camel-core/src/main/java/org/apache/camel/component/file/strategy/FileLockExclusiveReadLockStrategy.java
@@ -63,9 +63,12 @@ public class FileLockExclusiveReadLockStrategy extends MarkerFileExclusiveReadLo
LOG.trace("Waiting for exclusive read lock to file: {}", target);
+ FileChannel channel = null;
+ RandomAccessFile randomAccessFile = null;
try {
+ randomAccessFile = new RandomAccessFile(target, "rw");
// try to acquire rw lock on the file before we can consume it
- FileChannel channel = new RandomAccessFile(target, "rw").getChannel();
+ channel = randomAccessFile.getChannel();
boolean exclusive = false;
StopWatch watch = new StopWatch();
@@ -113,6 +116,9 @@ public class FileLockExclusiveReadLockStrategy extends MarkerFileExclusiveReadLo
// we were interrupted while sleeping, we are likely being shutdown so return false
return false;
}
+ } finally {
+ IOHelper.close(channel, "while acquiring exclusive read lock for file: " + lockFileName, LOG);
+ IOHelper.close(randomAccessFile, "while acquiring exclusive read lock for file: " + lockFileName, LOG);
}
return true;
@@ -131,7 +137,7 @@ public class FileLockExclusiveReadLockStrategy extends MarkerFileExclusiveReadLo
lock.release();
} finally {
// must close channel first
- IOHelper.close(channel, "while acquiring exclusive read lock for file: " + lockFileName, LOG);
+ IOHelper.close(channel, "while releasing exclusive read lock for file: " + lockFileName, LOG);
}
}
}
[2/3] git commit: CAMEL-7088: Close resources in file read lock.
Thanks to Leonid Marushevskiy for the patch.
Posted by da...@apache.org.
CAMEL-7088: Close resources in file read lock. Thanks to Leonid Marushevskiy for the patch.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/0e3ed7f3
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/0e3ed7f3
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/0e3ed7f3
Branch: refs/heads/camel-2.12.x
Commit: 0e3ed7f3d2adcd9c07b25df2b2acc544777382be
Parents: 5a3f2da
Author: Claus Ibsen <da...@apache.org>
Authored: Fri Dec 20 18:43:18 2013 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Fri Dec 20 18:43:40 2013 +0100
----------------------------------------------------------------------
.../file/strategy/FileLockExclusiveReadLockStrategy.java | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/0e3ed7f3/camel-core/src/main/java/org/apache/camel/component/file/strategy/FileLockExclusiveReadLockStrategy.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/file/strategy/FileLockExclusiveReadLockStrategy.java b/camel-core/src/main/java/org/apache/camel/component/file/strategy/FileLockExclusiveReadLockStrategy.java
index e229b5f..1d0c4d7 100644
--- a/camel-core/src/main/java/org/apache/camel/component/file/strategy/FileLockExclusiveReadLockStrategy.java
+++ b/camel-core/src/main/java/org/apache/camel/component/file/strategy/FileLockExclusiveReadLockStrategy.java
@@ -63,9 +63,12 @@ public class FileLockExclusiveReadLockStrategy extends MarkerFileExclusiveReadLo
LOG.trace("Waiting for exclusive read lock to file: {}", target);
+ FileChannel channel = null;
+ RandomAccessFile randomAccessFile = null;
try {
+ randomAccessFile = new RandomAccessFile(target, "rw");
// try to acquire rw lock on the file before we can consume it
- FileChannel channel = new RandomAccessFile(target, "rw").getChannel();
+ channel = randomAccessFile.getChannel();
boolean exclusive = false;
StopWatch watch = new StopWatch();
@@ -113,6 +116,9 @@ public class FileLockExclusiveReadLockStrategy extends MarkerFileExclusiveReadLo
// we were interrupted while sleeping, we are likely being shutdown so return false
return false;
}
+ } finally {
+ IOHelper.close(channel, "while acquiring exclusive read lock for file: " + lockFileName, LOG);
+ IOHelper.close(randomAccessFile, "while acquiring exclusive read lock for file: " + lockFileName, LOG);
}
return true;
@@ -131,7 +137,7 @@ public class FileLockExclusiveReadLockStrategy extends MarkerFileExclusiveReadLo
lock.release();
} finally {
// must close channel first
- IOHelper.close(channel, "while acquiring exclusive read lock for file: " + lockFileName, LOG);
+ IOHelper.close(channel, "while releasing exclusive read lock for file: " + lockFileName, LOG);
}
}
}
[3/3] git commit: CAMEL-7088: Close resources in file read lock.
Thanks to Leonid Marushevskiy for the patch.
Posted by da...@apache.org.
CAMEL-7088: Close resources in file read lock. Thanks to Leonid Marushevskiy for the patch.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/84573258
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/84573258
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/84573258
Branch: refs/heads/camel-2.11.x
Commit: 84573258602f5f8af4a211ee4ab17eac07848880
Parents: c321cb8
Author: Claus Ibsen <da...@apache.org>
Authored: Fri Dec 20 18:43:18 2013 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Fri Dec 20 18:43:56 2013 +0100
----------------------------------------------------------------------
.../file/strategy/FileLockExclusiveReadLockStrategy.java | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/84573258/camel-core/src/main/java/org/apache/camel/component/file/strategy/FileLockExclusiveReadLockStrategy.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/file/strategy/FileLockExclusiveReadLockStrategy.java b/camel-core/src/main/java/org/apache/camel/component/file/strategy/FileLockExclusiveReadLockStrategy.java
index 11f370b..f085b56 100644
--- a/camel-core/src/main/java/org/apache/camel/component/file/strategy/FileLockExclusiveReadLockStrategy.java
+++ b/camel-core/src/main/java/org/apache/camel/component/file/strategy/FileLockExclusiveReadLockStrategy.java
@@ -58,9 +58,12 @@ public class FileLockExclusiveReadLockStrategy extends MarkerFileExclusiveReadLo
LOG.trace("Waiting for exclusive read lock to file: {}", target);
+ FileChannel channel = null;
+ RandomAccessFile randomAccessFile = null;
try {
+ randomAccessFile = new RandomAccessFile(target, "rw");
// try to acquire rw lock on the file before we can consume it
- FileChannel channel = new RandomAccessFile(target, "rw").getChannel();
+ channel = randomAccessFile.getChannel();
boolean exclusive = false;
StopWatch watch = new StopWatch();
@@ -107,6 +110,9 @@ public class FileLockExclusiveReadLockStrategy extends MarkerFileExclusiveReadLo
// we were interrupted while sleeping, we are likely being shutdown so return false
return false;
}
+ } finally {
+ IOHelper.close(channel, "while acquiring exclusive read lock for file: " + lockFileName, LOG);
+ IOHelper.close(randomAccessFile, "while acquiring exclusive read lock for file: " + lockFileName, LOG);
}
return true;
@@ -124,7 +130,7 @@ public class FileLockExclusiveReadLockStrategy extends MarkerFileExclusiveReadLo
lock.release();
} finally {
// must close channel first
- IOHelper.close(channel, "while acquiring exclusive read lock for file: " + lockFileName, LOG);
+ IOHelper.close(channel, "while releasing exclusive read lock for file: " + lockFileName, LOG);
}
}
}