/**
 * Copyright 2017 Palantir Technologies
 *
 * Licensed under the BSD-3 License (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://opensource.org/licenses/BSD-3-Clause
 *
 * 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 com.palantir.atlasdb.persistentlock;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
import com.palantir.atlasdb.keyvalue.api.CheckAndSetException;
import com.palantir.atlasdb.keyvalue.api.KeyValueService;

public class KvsBackedPersistentLockService implements PersistentLockService {
    private static final Logger log = LoggerFactory.getLogger(KvsBackedPersistentLockService.class);

    private final LockStore lockStore;

    @VisibleForTesting
    KvsBackedPersistentLockService(LockStore lockStore) {
        this.lockStore = lockStore;
    }

    public static PersistentLockService create(KeyValueService kvs) {
        LockStore lockStore = LockStore.create(kvs);
        return new KvsBackedPersistentLockService(lockStore);
    }

    @Override
    public LockEntry acquireBackupLock(String reason) {
        Preconditions.checkNotNull(reason, "Please provide a reason for acquiring the lock.");
        return lockStore.acquireBackupLock(reason);
    }

    @Override
    public String releaseLock(LockEntry lockEntry) throws CheckAndSetException {
        Preconditions.checkNotNull(lockEntry, "Please provide a LockEntry to release.");

        try {
            lockStore.releaseLock(lockEntry);
            return "The lock was released successfully.\n";
        } catch (CheckAndSetException e) {
            log.error("Failed to release the persistent lock. This means that somebody already cleared this lock. "
                    + "You should investigate this, as this means your operation didn't necessarily hold the lock when "
                    + "it should have done.", e);
            throw e;
        }
    }

}

@@ -1934,16 +1934,18 @@
  return 
+%22%5C
 %22The loc
@@ -1973,17 +1973,20 @@
 sfully.%5C
-n
+%5Cn%5C%22
 %22;%0A     

Add quotes to String response on lock release success