code: public AtomicValue<byte[]> compareAndSet(byte[] expectedValue, byte[] newValue) throws Exception
      {
          Stat                        stat = new Stat();
          MutableAtomicValue<byte[]>  result = new MutableAtomicValue<byte[]>(null, null, false);
          boolean                     createIt = getCurrentValue(result, stat);
          if ( !createIt && Arrays.equals(expectedValue, result.preValue) )
          {
              try
              {
                  client.setData().withVersion(stat.getVersion()).forPath(path, newValue);
                  result.succeeded = true;
                  result.postValue = newValue;
              }
              catch ( KeeperException.BadVersionException dummy )
              {
                  result.succeeded = false;
              }
              catch ( KeeperException.NoNodeException dummy )
              {
                  result.succeeded = false;
              }
          }
          else
          {
              result.succeeded = false;
          }
          return result;
      }
docs: Atomically sets the value to the given updated value
  if the current value {@code ==} the expected value.
  Remember to always check {@link AtomicValue#succeeded()}.
  
  
  @param expectedValue the expected value
  @param newValue the new value
  @return value info
  @throws Exception ZooKeeper errors