Commit b13f6b91 authored by Ard Schrijvers's avatar Ard Schrijvers

CMS-10897 introduce LockManagerException for some methods

For a method like #isLocked or #getLocks, in case of an exception, we
need to throw an exception: Otherwise we need to return true|false or
an empty list: Client code can't handle this right. Then we can choose
between a runtime or checked exception. Since something like #getLocks
is something a client can react on (for example show a failed message in
UI for lock overview or a retry), a checked exception makes most sense
parent 7fafe01a
......@@ -94,15 +94,17 @@ public interface LockManager {
* </p>
* @param key the {@code key} to check whether there is a lock for
* @return {@code true} when locked
* @throws IllegalArgumentException if the {@code key} exceeds 256 chars
* @throws LockManagerException if some irrecoverable error occurs, for example a database request timeout
*/
boolean isLocked(String key);
boolean isLocked(String key) throws LockManagerException;
/**
* @return all the {@link Lock}s that are currently active (including locks that are marked to be aborted but not
* yet aborted)
* @throws RuntimeException in case some error occurs.
* @throws LockManagerException if some irrecoverable error occurs, for example a database request timeout
*/
List<Lock> getLocks();
List<Lock> getLocks() throws LockManagerException;
/**
* <p>
......@@ -121,8 +123,9 @@ public interface LockManager {
* </p>
* @param key the {@code key} to check whether there is a lock for
* @throws IllegalArgumentException if the {@code key} exceeds 256 chars
* @throws LockManagerException if some irrecoverable error occurs, for example a database request timeout
*/
void abort(String key);
void abort(String key) throws LockManagerException;
}
/*
* Copyright 2017 Hippo B.V. (http://www.onehippo.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onehippo.cms7.services.lock;
public class LockManagerException extends Exception {
public LockManagerException() {
super();
}
public LockManagerException(final String message) {
super(message);
}
public LockManagerException(final String message, final Throwable cause) {
super(message, cause);
}
public LockManagerException(final Throwable cause) {
super(cause);
}
protected LockManagerException(final String message, final Throwable cause, final boolean enableSuppression, final boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
}
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