Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Halstrick2015-01-23 07:55:06 +0000
committerGerrit Code Review @ Eclipse.org2015-01-23 07:55:06 +0000
commite314e42d41cca60748a5f4e6dec1682bdb8bdbe4 (patch)
tree97cf362f64b97b42195ed2a162d4de42563274dd
parent8f8724c857d7f6b1184bd81952e3895bba9e3724 (diff)
parent1a729bec9cd7320f2e2e54978ef65efc2c5234d7 (diff)
downloadjgit-e314e42d41cca60748a5f4e6dec1682bdb8bdbe4.tar.gz
jgit-e314e42d41cca60748a5f4e6dec1682bdb8bdbe4.tar.xz
jgit-e314e42d41cca60748a5f4e6dec1682bdb8bdbe4.zip
Merge "Ensure GitCommand's "callable" guard is thread-safe"
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/GitCommand.java7
1 files changed, 4 insertions, 3 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/GitCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/GitCommand.java
index 329b1b5aea..e9751f94a1 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/GitCommand.java
+++ b/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()));

Back to the top