Closed
Description
In what version(s) of Spring Integration are you seeing this issue?
6.1.3
Describe the bug
Using JDBC Lock Registry on Oracle always throws java.lang.IllegalMonitorStateException: The current thread doesn't own mutex at ...
To Reproduce
Lock lock = lockRegistry.obtain(foo);
try {
if (lock.tryLock(2, TimeUnit.MINUTES)) {
specialService.special(foo, bar);
} else {
throw new RuntimeException("Lock not obtained");
}
} catch (InterruptedException e) {
throw new RuntimeException(e);
} finally {
lock.unlock();
}
Expected behavior
JDBC Lock Registry on Oracle does not throw exception.
Sample
https://github.com/uebelack/spring-integration-lock-oracle
Workaround
List.of("serializableTransactionTemplate", "defaultTransactionTemplate", "readOnlyTransactionTemplate").forEach(templateName -> {
try {
Field declaredField = DefaultLockRepository.class.getDeclaredField(templateName);
declaredField.setAccessible(true);
TransactionTemplate transactionTemplate = (TransactionTemplate) declaredField.get(lockRegistry);
transactionTemplate.setIsolationLevel(TransactionDefinition.ISOLATION_READ_COMMITTED);
} catch (NoSuchFieldException | IllegalAccessException e) {
throw new RuntimeException(e);
}
});