All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.quarkus.dev.testing.TestScanningLock Maven / Gradle / Ivy

There is a newer version: 3.17.0
Show newest version
package io.quarkus.dev.testing;

import java.util.concurrent.locks.ReentrantLock;

/**
 * lock that is used to prevent scanning while the dev mode test is updating classes
 *
 * This prevents races in the continuous testing tests. It's not an ideal solution
 * but it is the only one I can think of at the moment.
 */
public class TestScanningLock {

    private static final ReentrantLock lock = new ReentrantLock();

    /**
     * There is a race when testing this, where you can see the intermediate empty state of the
     * file, or where the file time changes twice. Dev mode tests hold this lock during modification
     * to avoid the race.
     */
    public static void lockForTests() {
        lock.lock();
    }

    public static void unlockForTests() {
        lock.unlock();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy