diff --git a/src/main/java/net/spy/memcached/internal/BulkGetFuture.java b/src/main/java/net/spy/memcached/internal/BulkGetFuture.java index 58172d632..a3156cb7d 100644 --- a/src/main/java/net/spy/memcached/internal/BulkGetFuture.java +++ b/src/main/java/net/spy/memcached/internal/BulkGetFuture.java @@ -25,6 +25,7 @@ import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; +import java.util.concurrent.atomic.AtomicBoolean; import net.spy.memcached.MemcachedConnection; import net.spy.memcached.OperationTimeoutException; @@ -44,7 +45,7 @@ public class BulkGetFuture implements BulkFuture> { private final Collection ops; private final CountDownLatch latch; private final long timeout; - private boolean isTimeout = false; + private AtomicBoolean isTimeout = new AtomicBoolean(false); public BulkGetFuture(Map> rvMap, Collection ops, CountDownLatch latch, Long timeout) { @@ -61,6 +62,7 @@ public BulkGetFuture(BulkGetFuture other) { ops = other.ops; latch = other.latch; timeout = other.timeout; + isTimeout = other.isTimeout; } @Override @@ -87,7 +89,7 @@ public Map getSome(long duration, TimeUnit units) Collection timedoutOps = new HashSet(); Map ret = internalGet(duration, units, timedoutOps); if (!timedoutOps.isEmpty()) { - isTimeout = true; + isTimeout.set(true); LoggerFactory.getLogger(getClass()).warn( new CheckedOperationTimeoutException(duration, units, timedoutOps).getMessage()); } @@ -107,7 +109,7 @@ public Map get(long duration, TimeUnit units) Collection timedoutOps = new HashSet(); Map ret = internalGet(duration, units, timedoutOps); if (!timedoutOps.isEmpty()) { - isTimeout = true; + isTimeout.set(true); throw new CheckedOperationTimeoutException(duration, units, timedoutOps); } return ret; @@ -180,6 +182,6 @@ private Map internalGet(long to, TimeUnit unit, * @see net.spy.memcached.internal.BulkFuture#isTimeout() */ public boolean isTimeout() { - return isTimeout; + return isTimeout.get(); } }