code.onehippo.org is currently readonly. We are migrating to code.bloomreach.com, please continue working there on Monday 14/12. See: https://docs.bloomreach.com/display/engineering/GitLab

Commit 6938d49c authored by Ard Schrijvers's avatar Ard Schrijvers

REPO-1811 Use auto closeable

parent ac0b839d
......@@ -35,6 +35,7 @@ import org.hippoecm.repository.api.HippoNodeType;
import org.onehippo.cms7.services.HippoServiceRegistry;
import org.onehippo.cms7.services.lock.LockException;
import org.onehippo.cms7.services.lock.LockManager;
import org.onehippo.cms7.services.lock.LockResource;
import org.onehippo.repository.modules.DaemonModule;
import org.onehippo.repository.modules.ProvidesService;
import org.slf4j.Logger;
......@@ -142,10 +143,7 @@ public class UpdaterExecutionModule implements DaemonModule, EventListener {
@Override
public void run() {
boolean locked = false;
try {
lockManager.lock(UPDATE_PATH);
locked = true;
try (LockResource lock = lockManager.lock(UPDATE_PATH)){
executeUpdatersInQueue();
} catch (LockException e) {
log.info("Failed to obtain lock, most likely obtained by other cluster node already", e);
......@@ -153,9 +151,6 @@ public class UpdaterExecutionModule implements DaemonModule, EventListener {
synchronized (monitor) {
task = null;
}
if (locked) {
lockManager.unlock(UPDATE_PATH);
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment