Skip to content

Commit 70d2a69

Browse files
committed
#714 Protect against exceptions on lock release.
1 parent 4268fe1 commit 70d2a69

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

pramen/core/src/main/scala/za/co/absa/pramen/core/lock/TokenLockBase.scala

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,12 @@ abstract class TokenLockBase(override val token: String) extends TokenLock {
100100
if (wasAcquired) {
101101
watcherThreadOpt.foreach(_.interrupt())
102102
watcherThreadOpt = None
103-
releaseGuardLock()
104-
JvmUtils.safeRemoveShutdownHook(shutdownHook)
105-
TokenLockRegistry.unregisterLock(this)
103+
try {
104+
releaseGuardLock()
105+
} finally {
106+
JvmUtils.safeRemoveShutdownHook(shutdownHook)
107+
TokenLockRegistry.unregisterLock(this)
108+
}
106109
log.info(s"Lock released: '$escapedToken'.")
107110
}
108111
}

pramen/core/src/main/scala/za/co/absa/pramen/core/lock/TokenLockRegistry.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ object TokenLockRegistry {
5656
try {
5757
l.release()
5858
} catch {
59-
case NonFatal(ex) => log.warn(s"Unable to release the lock: ${l.token}")
59+
case NonFatal(ex) => log.warn(s"Unable to release the lock: ${l.token}", ex)
6060
}
6161
}
6262
currentLocks.clear()

0 commit comments

Comments
 (0)