in src/main/java/com/google/gcs/sdrs/dao/impl/LockDaoImpl.java [101:127]
public void releaseLock(Session lockSession, DistributedLock distributedLock) {
if (distributedLock == null
|| lockSession == null
|| !lockSession.isOpen()
|| lockSession.getTransaction() == null
|| !lockSession.getTransaction().isActive()) {
return;
}
try {
distributedLock.getCreatedAt().toInstant();
long duration =
Instant.now().toEpochMilli() - distributedLock.getCreatedAt().toInstant().toEpochMilli();
distributedLock.setLockDuration(duration);
logger.debug(
String.format(
"tokenName=%s, duration=%d, createdAt=%s",
distributedLock.getLockToken(),
distributedLock.getLockDuration(),
distributedLock.getCreatedAt().toInstant().toString()));
lockSession.update(distributedLock);
closeSessionWithTransaction(lockSession, lockSession.getTransaction());
} catch (Exception e) {
logger.info("Failed to release lock.", e);
}
}