<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -65,6 +65,11 @@ public class CASMutator&lt;T&gt; extends SpyObject {
 	/**
 	 * CAS a new value in for a key.
 	 *
+	 * &lt;p&gt;
+	 * Note that if initial is null, this method will only update existing
+	 * values.
+	 * &lt;/p&gt;
+	 *
 	 * @param key the key to be CASed
 	 * @param initial the value to use when the object is not cached
 	 * @param initialExp the expiration time to use when initializing
@@ -106,7 +111,10 @@ public class CASMutator&lt;T&gt; extends SpyObject {
 				}
 			} else {
 				// No value found, try an add.
-				if(client.add(key, initialExp, initial, transcoder).get()) {
+				if(initial == null) {
+					done = true;
+					rv = null;
+				} else if(client.add(key, initialExp, initial, transcoder).get()) {
 					done=true;
 					rv=initial;
 				}</diff>
      <filename>src/main/java/net/spy/memcached/CASMutator.java</filename>
    </modified>
    <modified>
      <diff>@@ -49,6 +49,19 @@ public class CASMutatorTest extends ClientBaseCase {
 		}
 	}
 
+	public void testCASUpdateWithNullInitial() throws Throwable {
+		client.set(&quot;x&quot;, 0, 1L);
+		Long rv=mutator.cas(&quot;x&quot;, (Long)null, 0, mutation);
+		assertEquals(rv, (Long)2L);
+	}
+
+	public void testCASUpdateWithNullInitialNoExistingVal() throws Throwable {
+		assertNull(client.get(&quot;x&quot;));
+		Long rv=mutator.cas(&quot;x&quot;, (Long)null, 0, mutation);
+		assertNull(rv);
+		assertNull(client.get(&quot;x&quot;));
+	}
+
 	public void testCASValueToString() {
 		CASValue&lt;String&gt; c=new CASValue&lt;String&gt;(717L, &quot;hi&quot;);
 		assertEquals(&quot;{CasValue 717/hi}&quot;, c.toString());</diff>
      <filename>src/test/java/net/spy/memcached/CASMutatorTest.java</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>4999cc49c3c37aa4d3eac9b4cb2134dc45df7862</id>
    </parent>
  </parents>
  <author>
    <name>Dustin Sallings</name>
    <email>dustin@spy.net</email>
  </author>
  <url>http://github.com/dustin/java-memcached-client/commit/b634d0ae546a299bb570d8877434261ba32f76a7</url>
  <id>b634d0ae546a299bb570d8877434261ba32f76a7</id>
  <committed-date>2009-06-20T18:43:11-07:00</committed-date>
  <authored-date>2009-06-20T18:41:54-07:00</authored-date>
  <message>Allow CAS Mutator to work in a mutation-only mode.

When initial is null, do not initialize the value.</message>
  <tree>8a965a92a1e95e547368153ede4ee9409f60e98d</tree>
  <committer>
    <name>Dustin Sallings</name>
    <email>dustin@spy.net</email>
  </committer>
</commit>
