import java.util.Locale;
import java.util.Objects;
import java.util.Set;
-import java.util.concurrent.locks.ReentrantLock;
import org.eclipse.jgit.annotations.Nullable;
import org.eclipse.jgit.api.errors.JGitInternalException;
private final RefDatabase refs;
private final ObjectDirectory objectDatabase;
- private final ReentrantLock snapshotLock = new ReentrantLock();
+ private final Object snapshotLock = new Object();
// protected by snapshotLock
private FileSnapshot snapshot;
}
File indexFile = getIndexFile();
- snapshotLock.lock();
- try {
+ synchronized (snapshotLock) {
if (snapshot == null) {
snapshot = FileSnapshot.save(indexFile);
return;
if (!snapshot.isModified(indexFile)) {
return;
}
- } finally {
- snapshotLock.unlock();
}
notifyIndexChanged(false);
}
/** {@inheritDoc} */
@Override
public void notifyIndexChanged(boolean internal) {
- snapshotLock.lock();
- try {
+ synchronized (snapshotLock) {
snapshot = FileSnapshot.save(getIndexFile());
- } finally {
- snapshotLock.unlock();
}
fireEvent(new IndexChangedEvent(internal));
}