Browse Source

Merge "Ensure GitCommand's "callable" guard is thread-safe"

stable-3.7
Christian Halstrick 10 years ago committed by Gerrit Code Review @ Eclipse.org
parent
commit
e314e42d41
  1. 7
      org.eclipse.jgit/src/org/eclipse/jgit/api/GitCommand.java

7
org.eclipse.jgit/src/org/eclipse/jgit/api/GitCommand.java

@ -39,6 +39,7 @@ package org.eclipse.jgit.api;
import java.text.MessageFormat;
import java.util.concurrent.Callable;
import java.util.concurrent.atomic.AtomicBoolean;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.internal.JGitText;
@ -71,7 +72,7 @@ public abstract class GitCommand<T> implements Callable<T> {
* a state which tells whether it is allowed to call {@link #call()} on this
* instance.
*/
private boolean callable = true;
private AtomicBoolean callable = new AtomicBoolean(true);
/**
* Creates a new command which interacts with a single repository
@ -100,7 +101,7 @@ public abstract class GitCommand<T> implements Callable<T> {
* this instance.
*/
protected void setCallable(boolean callable) {
this.callable = callable;
this.callable.set(callable);
}
/**
@ -112,7 +113,7 @@ public abstract class GitCommand<T> implements Callable<T> {
* is {@code false}
*/
protected void checkCallable() {
if (!callable)
if (!callable.get())
throw new IllegalStateException(MessageFormat.format(
JGitText.get().commandWasCalledInTheWrongState
, this.getClass().getName()));

Loading…
Cancel
Save