ThisaraWeerakoon commented on code in PR #117:
URL: https://github.com/apache/synapse/pull/117#discussion_r4310940821
##########
modules/transports/core/vfs/src/main/java/org/apache/synapse/transport/vfs/VFSUtils.java:
##########
@@ -196,6 +217,63 @@ public static void releaseLock(FileSystemManager
fsManager, FileObject fo) {
}
}
+ /**
+ * Release a lock file that appears to have been abandoned. The age of the
lock is taken from
+ * the file system rather than from the content of the lock file, so a
lock written by any
+ * party -- including one that is empty or otherwise unreadable -- is aged
out.
+ *
+ * @param lockObject the existing lock file
+ * @param autoLockReleaseInterval age in milliseconds beyond which the
lock is released
+ * @param lInterval the age of the lock file, or -1 if it could not be
determined
+ */
+ private static void releaseLock(FileObject lockObject, Long
autoLockReleaseInterval,
+ long lInterval) {
+ if (lInterval < 0) {
+ // the file system cannot report a last modified time, so the age
of the lock is
+ // unknown; leave it in place rather than removing a lock that may
still be held
+ return;
+ }
+ try {
+ deleteLockFile(lockObject, autoLockReleaseInterval, lInterval);
+ } catch (FileSystemException e) {
+ log.error("Couldn't release the lock file "
+ + maskURLPassword(lockObject.getName().getURI()), e);
+ }
+ }
+
+ private static void deleteLockFile(FileObject lockObject, Long
autoLockReleaseInterval,
+ long lInterval) throws
FileSystemException {
+ if (autoLockReleaseInterval == null || autoLockReleaseInterval <=
lInterval) {
Review Comment:
Addressed, thanks. Moved the elapsed-time check up so releaseLock is only
called once it's actually due.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]