Fix tests

This commit is contained in:
2024-06-16 15:27:11 +02:00
parent 0127d2148e
commit 804dbcbdef
3 changed files with 7 additions and 7 deletions

View File

@@ -60,10 +60,10 @@ public class DistributedObjectRepository implements ObjectRepository {
var info = infoOpt.get();
return info.runReadLocked(() -> {
if (objectPersistentStore.existsObject(namespace, name).await().indefinitely())
return objectPersistentStore.readObject(namespace, name).await().indefinitely();
if (objectPersistentStore.existsObject(namespace, name).await().indefinitely())
return objectPersistentStore.readObject(namespace, name).await().indefinitely();
return info.runWriteLocked(() -> {
return remoteObjectServiceClient.getObject(namespace, name).map(got -> {
objectPersistentStore.writeObject(namespace, got);
return got;

View File

@@ -29,13 +29,13 @@ public class ObjectIndex implements Serializable {
}
public <R> R runWriteLocked(Callable<R> fn) {
_lock.readLock().lock();
_lock.writeLock().lock();
try {
return fn.call();
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
_lock.readLock().unlock();
_lock.writeLock().unlock();
}
}

View File

@@ -42,13 +42,13 @@ public class ObjectMeta implements Serializable {
}
public <R> R runWriteLocked(Callable<R> fn) {
_lock.readLock().lock();
_lock.writeLock().lock();
try {
return fn.call();
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
_lock.readLock().unlock();
_lock.writeLock().unlock();
}
}
}