@@ -0,0 +1,1089 @@
+package com.composum.platform.commons.util;%0A%0Aimport java.util.concurrent.locks.Lock;%0A%0A/**%0A * Allows using a %7B@link java.util.concurrent.locks.Lock%7D with a try with resources, e.g.:%0A * %3Ccode%3E try (LockAsAutoCloseable locked = LockAsAutoCloseable.lock(lock)) %7B ... %7D %3C/code%3E .%0A */%0A@SuppressWarnings(%22LockAcquiredButNotSafelyReleased%22)%0Apublic class LockAsAutoCloseable implements AutoCloseable %7B%0A%0A    protected final Lock lock;%0A%0A    protected LockAsAutoCloseable(Lock lock) %7B%0A        this.lock = lock;%0A        lock.lock();%0A        try (LockAsAutoCloseable locked = LockAsAutoCloseable.lock(lock)) %7B%0A%0A        %7D%0A    %7D%0A%0A    /**%0A     * Acquires a lock on the given lock and allows using it the try-with-resources way. For example:%0A     * %3Ccode%3E try (LockAsAutoCloseable locked = LockAsAutoCloseable.lock(lock)) %7B ... %7D %3C/code%3E .%0A     * Always use in try-with-resource statement.%0A     */%0A    public static LockAsAutoCloseable lock(Lock lock) %7B%0A        return new LockAsAutoCloseable(lock);%0A    %7D%0A%0A    /** Unlocks the lock. */%0A    @Override%0A    public void close() %7B%0A        lock.unlock();%0A    %7D%0A%7D%0A

introduce LockAsAutoCloseable for easy use of locks in try-with-resource statement